mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-14 23:07:56 +02:00
Replaced space indentations with tabs
Replaced intermittent space indentations with tabs; removed test.txt file
This commit is contained in:
@@ -82,15 +82,15 @@ public:
|
|||||||
/// The returned reference is valid until the next
|
/// The returned reference is valid until the next
|
||||||
/// time digest() is called, or the engine object is destroyed.
|
/// time digest() is called, or the engine object is destroyed.
|
||||||
|
|
||||||
static std::string digestToHex(const Digest& bytes);
|
static std::string digestToHex(const Digest& bytes);
|
||||||
/// Converts a message digest into a string of hexadecimal numbers.
|
/// Converts a message digest into a string of hexadecimal numbers.
|
||||||
|
|
||||||
static Digest digestFromHex(const std::string& digest);
|
static Digest digestFromHex(const std::string& digest);
|
||||||
/// Converts a string created by digestToHex back to its Digest presentation
|
/// Converts a string created by digestToHex back to its Digest presentation
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void updateImpl(const void* data, std::size_t length) = 0;
|
virtual void updateImpl(const void* data, std::size_t length) = 0;
|
||||||
/// Updates the digest with the given data. Must be implemented
|
/// Updates the digest with the given data. Must be implemented
|
||||||
/// by subclasses.
|
/// by subclasses.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -132,7 +132,7 @@ class Foundation_API FIFOBufferStream: public FIFOIOS, public std::iostream
|
|||||||
/// An output stream for writing to a FIFO.
|
/// An output stream for writing to a FIFO.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Poco::BasicEvent<bool>& readable;
|
Poco::BasicEvent<bool>& readable;
|
||||||
Poco::BasicEvent<bool>& writable;
|
Poco::BasicEvent<bool>& writable;
|
||||||
|
|
||||||
explicit FIFOBufferStream(FIFOBuffer& buffer);
|
explicit FIFOBufferStream(FIFOBuffer& buffer);
|
||||||
|
@@ -206,7 +206,7 @@ public:
|
|||||||
{
|
{
|
||||||
return *_object.get();
|
return *_object.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAutoDelete(B* pObject) const
|
bool isAutoDelete(B* pObject) const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -54,13 +54,13 @@ class Foundation_API StreamCopier
|
|||||||
/// into another.
|
/// into another.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static std::streamsize copyStream(std::istream& istr, std::ostream& ostr, std::size_t bufferSize = 8192);
|
static std::streamsize copyStream(std::istream& istr, std::ostream& ostr, std::size_t bufferSize = 8192);
|
||||||
/// Writes all bytes readable from istr to ostr, using an internal buffer.
|
/// Writes all bytes readable from istr to ostr, using an internal buffer.
|
||||||
///
|
///
|
||||||
/// Returns the number of bytes copied.
|
/// Returns the number of bytes copied.
|
||||||
|
|
||||||
#if defined(POCO_HAVE_INT64)
|
#if defined(POCO_HAVE_INT64)
|
||||||
static Poco::UInt64 copyStream64(std::istream& istr, std::ostream& ostr, std::size_t bufferSize = 8192);
|
static Poco::UInt64 copyStream64(std::istream& istr, std::ostream& ostr, std::size_t bufferSize = 8192);
|
||||||
/// Writes all bytes readable from istr to ostr, using an internal buffer.
|
/// Writes all bytes readable from istr to ostr, using an internal buffer.
|
||||||
///
|
///
|
||||||
/// Returns the number of bytes copied as a 64-bit unsigned integer.
|
/// Returns the number of bytes copied as a 64-bit unsigned integer.
|
||||||
@@ -69,13 +69,13 @@ public:
|
|||||||
/// integer is used to count the number of bytes copied.
|
/// integer is used to count the number of bytes copied.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static std::streamsize copyStreamUnbuffered(std::istream& istr, std::ostream& ostr);
|
static std::streamsize copyStreamUnbuffered(std::istream& istr, std::ostream& ostr);
|
||||||
/// Writes all bytes readable from istr to ostr.
|
/// Writes all bytes readable from istr to ostr.
|
||||||
///
|
///
|
||||||
/// Returns the number of bytes copied.
|
/// Returns the number of bytes copied.
|
||||||
|
|
||||||
#if defined(POCO_HAVE_INT64)
|
#if defined(POCO_HAVE_INT64)
|
||||||
static Poco::UInt64 copyStreamUnbuffered64(std::istream& istr, std::ostream& ostr);
|
static Poco::UInt64 copyStreamUnbuffered64(std::istream& istr, std::ostream& ostr);
|
||||||
/// Writes all bytes readable from istr to ostr.
|
/// Writes all bytes readable from istr to ostr.
|
||||||
///
|
///
|
||||||
/// Returns the number of bytes copied as a 64-bit unsigned integer.
|
/// Returns the number of bytes copied as a 64-bit unsigned integer.
|
||||||
@@ -84,13 +84,13 @@ public:
|
|||||||
/// integer is used to count the number of bytes copied.
|
/// integer is used to count the number of bytes copied.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static std::streamsize copyToString(std::istream& istr, std::string& str, std::size_t bufferSize = 8192);
|
static std::streamsize copyToString(std::istream& istr, std::string& str, std::size_t bufferSize = 8192);
|
||||||
/// Appends all bytes readable from istr to the given string, using an internal buffer.
|
/// Appends all bytes readable from istr to the given string, using an internal buffer.
|
||||||
///
|
///
|
||||||
/// Returns the number of bytes copied.
|
/// Returns the number of bytes copied.
|
||||||
|
|
||||||
#if defined(POCO_HAVE_INT64)
|
#if defined(POCO_HAVE_INT64)
|
||||||
static Poco::UInt64 copyToString64(std::istream& istr, std::string& str, std::size_t bufferSize = 8192);
|
static Poco::UInt64 copyToString64(std::istream& istr, std::string& str, std::size_t bufferSize = 8192);
|
||||||
/// Appends all bytes readable from istr to the given string, using an internal buffer.
|
/// Appends all bytes readable from istr to the given string, using an internal buffer.
|
||||||
///
|
///
|
||||||
/// Returns the number of bytes copied as a 64-bit unsigned integer.
|
/// Returns the number of bytes copied as a 64-bit unsigned integer.
|
||||||
|
@@ -64,7 +64,7 @@ namespace Poco {
|
|||||||
class Foundation_API ThreadImpl
|
class Foundation_API ThreadImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef pthread_t TIDImpl;
|
typedef pthread_t TIDImpl;
|
||||||
typedef void (*Callable)(void*);
|
typedef void (*Callable)(void*);
|
||||||
|
|
||||||
enum Priority
|
enum Priority
|
||||||
@@ -91,9 +91,9 @@ public:
|
|||||||
void* pData;
|
void* pData;
|
||||||
};
|
};
|
||||||
|
|
||||||
ThreadImpl();
|
ThreadImpl();
|
||||||
~ThreadImpl();
|
~ThreadImpl();
|
||||||
|
|
||||||
TIDImpl tidImpl() const;
|
TIDImpl tidImpl() const;
|
||||||
void setPriorityImpl(int prio);
|
void setPriorityImpl(int prio);
|
||||||
int getPriorityImpl() const;
|
int getPriorityImpl() const;
|
||||||
|
@@ -51,7 +51,7 @@ namespace Poco {
|
|||||||
class Foundation_API ThreadImpl
|
class Foundation_API ThreadImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef DWORD TIDImpl;
|
typedef DWORD TIDImpl;
|
||||||
typedef void (*Callable)(void*);
|
typedef void (*Callable)(void*);
|
||||||
|
|
||||||
#if defined(_DLL)
|
#if defined(_DLL)
|
||||||
|
@@ -173,10 +173,10 @@ struct TypeListType
|
|||||||
/// typeList is a TypeList of T0, T1, ... , Tn
|
/// typeList is a TypeList of T0, T1, ... , Tn
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef typename TypeListType<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>::HeadType TailType;
|
typedef typename TypeListType<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>::HeadType TailType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef TypeList<T0, TailType> HeadType;
|
typedef TypeList<T0, TailType> HeadType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -66,9 +66,9 @@ bool Debugger::isAvailable()
|
|||||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||||
#if defined(_WIN32_WCE)
|
#if defined(_WIN32_WCE)
|
||||||
#if (_WIN32_WCE >= 0x600)
|
#if (_WIN32_WCE >= 0x600)
|
||||||
BOOL isDebuggerPresent;
|
BOOL isDebuggerPresent;
|
||||||
if (CheckRemoteDebuggerPresent(GetCurrentProcess(), &isDebuggerPresent))
|
if (CheckRemoteDebuggerPresent(GetCurrentProcess(), &isDebuggerPresent))
|
||||||
{
|
{
|
||||||
return isDebuggerPresent ? true : false;
|
return isDebuggerPresent ? true : false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@@ -193,7 +193,7 @@ Timestamp File::getLastModified() const
|
|||||||
File& File::setLastModified(const Timestamp& ts)
|
File& File::setLastModified(const Timestamp& ts)
|
||||||
{
|
{
|
||||||
setLastModifiedImpl(ts);
|
setLastModifiedImpl(ts);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -206,28 +206,28 @@ File::FileSize File::getSize() const
|
|||||||
File& File::setSize(FileSizeImpl size)
|
File& File::setSize(FileSizeImpl size)
|
||||||
{
|
{
|
||||||
setSizeImpl(size);
|
setSizeImpl(size);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
File& File::setWriteable(bool flag)
|
File& File::setWriteable(bool flag)
|
||||||
{
|
{
|
||||||
setWriteableImpl(flag);
|
setWriteableImpl(flag);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
File& File::setReadOnly(bool flag)
|
File& File::setReadOnly(bool flag)
|
||||||
{
|
{
|
||||||
setWriteableImpl(!flag);
|
setWriteableImpl(!flag);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
File& File::setExecutable(bool flag)
|
File& File::setExecutable(bool flag)
|
||||||
{
|
{
|
||||||
setExecutableImpl(flag);
|
setExecutableImpl(flag);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -226,7 +226,7 @@ ThreadImpl* ThreadImpl::currentImpl()
|
|||||||
|
|
||||||
ThreadImpl::TIDImpl ThreadImpl::currentTidImpl()
|
ThreadImpl::TIDImpl ThreadImpl::currentTidImpl()
|
||||||
{
|
{
|
||||||
return GetCurrentThreadId();
|
return GetCurrentThreadId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -78,47 +78,47 @@ public:
|
|||||||
std::memset(&st1, 0, sizeof(SYSTEMTIME));
|
std::memset(&st1, 0, sizeof(SYSTEMTIME));
|
||||||
std::memset(&st2, 0, sizeof(SYSTEMTIME));
|
std::memset(&st2, 0, sizeof(SYSTEMTIME));
|
||||||
GetSystemTime(&st1);
|
GetSystemTime(&st1);
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
GetSystemTime(&st2);
|
GetSystemTime(&st2);
|
||||||
|
|
||||||
// wait for a rollover
|
// wait for a rollover
|
||||||
if (st1.wSecond != st2.wSecond)
|
if (st1.wSecond != st2.wSecond)
|
||||||
{
|
{
|
||||||
_offset = GetTickCount() % 1000;
|
_offset = GetTickCount() % 1000;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void calibrate(int seconds)
|
void calibrate(int seconds)
|
||||||
{
|
{
|
||||||
SYSTEMTIME st1, st2;
|
SYSTEMTIME st1, st2;
|
||||||
systemTime(&st1);
|
systemTime(&st1);
|
||||||
|
|
||||||
WORD s = st1.wSecond;
|
WORD s = st1.wSecond;
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
int remaining = seconds;
|
int remaining = seconds;
|
||||||
while (remaining > 0)
|
while (remaining > 0)
|
||||||
{
|
{
|
||||||
systemTime(&st2);
|
systemTime(&st2);
|
||||||
WORD s2 = st2.wSecond;
|
WORD s2 = st2.wSecond;
|
||||||
|
|
||||||
if (s != s2)
|
if (s != s2)
|
||||||
{
|
{
|
||||||
remaining--;
|
remaining--;
|
||||||
// store the offset from zero
|
// store the offset from zero
|
||||||
sum += (st2.wMilliseconds > 500) ? (st2.wMilliseconds - 1000) : st2.wMilliseconds;
|
sum += (st2.wMilliseconds > 500) ? (st2.wMilliseconds - 1000) : st2.wMilliseconds;
|
||||||
s = st2.wSecond;
|
s = st2.wSecond;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// adjust the offset by the average deviation from zero (round to the integer farthest from zero)
|
// adjust the offset by the average deviation from zero (round to the integer farthest from zero)
|
||||||
if (sum < 0)
|
if (sum < 0)
|
||||||
_offset += (int) std::floor(sum / (float)seconds);
|
_offset += (int) std::floor(sum / (float)seconds);
|
||||||
else
|
else
|
||||||
_offset += (int) std::ceil(sum / (float)seconds);
|
_offset += (int) std::ceil(sum / (float)seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
void systemTime(SYSTEMTIME* pST)
|
void systemTime(SYSTEMTIME* pST)
|
||||||
{
|
{
|
||||||
|
@@ -62,19 +62,19 @@ int UTF8::icompare(const std::string& str, std::string::size_type pos, std::stri
|
|||||||
TextIterator uend2(end2);
|
TextIterator uend2(end2);
|
||||||
while (uit1 != uend1 && uit2 != uend2)
|
while (uit1 != uend1 && uit2 != uend2)
|
||||||
{
|
{
|
||||||
int c1 = Unicode::toLower(*uit1);
|
int c1 = Unicode::toLower(*uit1);
|
||||||
int c2 = Unicode::toLower(*uit2);
|
int c2 = Unicode::toLower(*uit2);
|
||||||
if (c1 < c2)
|
if (c1 < c2)
|
||||||
return -1;
|
return -1;
|
||||||
else if (c1 > c2)
|
else if (c1 > c2)
|
||||||
return 1;
|
return 1;
|
||||||
++uit1; ++uit2;
|
++uit1; ++uit2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uit1 == uend1)
|
if (uit1 == uend1)
|
||||||
return uit2 == uend2 ? 0 : -1;
|
return uit2 == uend2 ? 0 : -1;
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -132,19 +132,19 @@ int UTF8::icompare(const std::string& str, std::string::size_type pos, std::stri
|
|||||||
TextIterator uend(str.begin() + pos + n);
|
TextIterator uend(str.begin() + pos + n);
|
||||||
while (uit != uend && *ptr)
|
while (uit != uend && *ptr)
|
||||||
{
|
{
|
||||||
int c1 = Unicode::toLower(*uit);
|
int c1 = Unicode::toLower(*uit);
|
||||||
int c2 = Unicode::toLower(*ptr);
|
int c2 = Unicode::toLower(*ptr);
|
||||||
if (c1 < c2)
|
if (c1 < c2)
|
||||||
return -1;
|
return -1;
|
||||||
else if (c1 > c2)
|
else if (c1 > c2)
|
||||||
return 1;
|
return 1;
|
||||||
++uit; ++ptr;
|
++uit; ++ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uit == uend)
|
if (uit == uend)
|
||||||
return *ptr == 0 ? 0 : -1;
|
return *ptr == 0 ? 0 : -1;
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -121,17 +121,17 @@ void DateTimeTest::testJulian()
|
|||||||
assert (dt.dayOfWeek() == 1);
|
assert (dt.dayOfWeek() == 1);
|
||||||
assert (dt.julianDay() == 0);
|
assert (dt.julianDay() == 0);
|
||||||
|
|
||||||
// Test that we can represent down to the microsecond.
|
// Test that we can represent down to the microsecond.
|
||||||
dt = DateTime(2010, 1, 31, 17, 30, 15, 800, 3);
|
dt = DateTime(2010, 1, 31, 17, 30, 15, 800, 3);
|
||||||
|
|
||||||
assert (dt.year() == 2010);
|
assert (dt.year() == 2010);
|
||||||
assert (dt.month() == 1);
|
assert (dt.month() == 1);
|
||||||
assert (dt.day() == 31);
|
assert (dt.day() == 31);
|
||||||
assert (dt.hour() == 17);
|
assert (dt.hour() == 17);
|
||||||
assert (dt.minute() == 30);
|
assert (dt.minute() == 30);
|
||||||
assert (dt.second() == 15);
|
assert (dt.second() == 15);
|
||||||
assert (dt.millisecond() == 800);
|
assert (dt.millisecond() == 800);
|
||||||
assert (dt.microsecond() == 3);
|
assert (dt.microsecond() == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -341,245 +341,245 @@ void DateTimeTest::testAMPM()
|
|||||||
|
|
||||||
void DateTimeTest::testRelational()
|
void DateTimeTest::testRelational()
|
||||||
{
|
{
|
||||||
DateTime dt1(2005, 1, 1, 0, 15, 30);
|
DateTime dt1(2005, 1, 1, 0, 15, 30);
|
||||||
DateTime dt2(2005, 1, 2, 0, 15, 30);
|
DateTime dt2(2005, 1, 2, 0, 15, 30);
|
||||||
DateTime dt3(dt1);
|
DateTime dt3(dt1);
|
||||||
|
|
||||||
assert (dt1 < dt2);
|
assert (dt1 < dt2);
|
||||||
assert (dt1 <= dt2);
|
assert (dt1 <= dt2);
|
||||||
assert (dt2 > dt1);
|
assert (dt2 > dt1);
|
||||||
assert (dt2 >= dt1);
|
assert (dt2 >= dt1);
|
||||||
assert (dt1 != dt2);
|
assert (dt1 != dt2);
|
||||||
assert (!(dt1 == dt2));
|
assert (!(dt1 == dt2));
|
||||||
|
|
||||||
assert (dt1 == dt3);
|
assert (dt1 == dt3);
|
||||||
assert (!(dt1 != dt3));
|
assert (!(dt1 != dt3));
|
||||||
assert (dt1 >= dt3);
|
assert (dt1 >= dt3);
|
||||||
assert (dt1 <= dt3);
|
assert (dt1 <= dt3);
|
||||||
assert (!(dt1 > dt3));
|
assert (!(dt1 > dt3));
|
||||||
assert (!(dt1 < dt3));
|
assert (!(dt1 < dt3));
|
||||||
|
|
||||||
static const struct
|
static const struct
|
||||||
{
|
{
|
||||||
int year;
|
int year;
|
||||||
int month;
|
int month;
|
||||||
int day;
|
int day;
|
||||||
} values[] =
|
} values[] =
|
||||||
{
|
{
|
||||||
{ 1, 1, 1 },
|
{ 1, 1, 1 },
|
||||||
{ 10, 4, 5 },
|
{ 10, 4, 5 },
|
||||||
{ 100, 6, 7 },
|
{ 100, 6, 7 },
|
||||||
{ 1000, 8, 9 },
|
{ 1000, 8, 9 },
|
||||||
{ 2000, 1, 31 },
|
{ 2000, 1, 31 },
|
||||||
{ 2002, 7, 4 },
|
{ 2002, 7, 4 },
|
||||||
{ 2002, 12, 31 },
|
{ 2002, 12, 31 },
|
||||||
{ 2003, 1, 1 },
|
{ 2003, 1, 1 },
|
||||||
{ 2003, 1, 2 },
|
{ 2003, 1, 2 },
|
||||||
{ 2003, 8, 5 },
|
{ 2003, 8, 5 },
|
||||||
{ 2003, 8, 6 },
|
{ 2003, 8, 6 },
|
||||||
{ 2003, 8, 7 },
|
{ 2003, 8, 7 },
|
||||||
{ 2004, 9, 3 },
|
{ 2004, 9, 3 },
|
||||||
{ 2004, 9, 4 },
|
{ 2004, 9, 4 },
|
||||||
};
|
};
|
||||||
|
|
||||||
const int num_values = sizeof values / sizeof *values;
|
const int num_values = sizeof values / sizeof *values;
|
||||||
for (int i = 0; i < num_values; ++i)
|
for (int i = 0; i < num_values; ++i)
|
||||||
{
|
{
|
||||||
DateTime v;
|
DateTime v;
|
||||||
const DateTime& V = v;
|
const DateTime& V = v;
|
||||||
v.assign(values[i].year, values[i].month, values[i].day);
|
v.assign(values[i].year, values[i].month, values[i].day);
|
||||||
for (int j = 0; j < num_values; ++j)
|
for (int j = 0; j < num_values; ++j)
|
||||||
{
|
{
|
||||||
DateTime u;
|
DateTime u;
|
||||||
const DateTime& U = u;
|
const DateTime& U = u;
|
||||||
u.assign(values[j].year, values[j].month, values[j].day);
|
u.assign(values[j].year, values[j].month, values[j].day);
|
||||||
|
|
||||||
loop_2_assert(i, j, (j < i) == (U < V));
|
loop_2_assert(i, j, (j < i) == (U < V));
|
||||||
loop_2_assert(i, j, (j <= i) == (U <= V));
|
loop_2_assert(i, j, (j <= i) == (U <= V));
|
||||||
loop_2_assert(i, j, (j >= i) == (U >= V));
|
loop_2_assert(i, j, (j >= i) == (U >= V));
|
||||||
loop_2_assert(i, j, (j > i) == (U > V));
|
loop_2_assert(i, j, (j > i) == (U > V));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DateTimeTest::testArithmetics()
|
void DateTimeTest::testArithmetics()
|
||||||
{
|
{
|
||||||
DateTime dt1(2005, 1, 1, 0, 15, 30);
|
DateTime dt1(2005, 1, 1, 0, 15, 30);
|
||||||
DateTime dt2(2005, 1, 2, 0, 15, 30);
|
DateTime dt2(2005, 1, 2, 0, 15, 30);
|
||||||
|
|
||||||
Timespan s = dt2 - dt1;
|
Timespan s = dt2 - dt1;
|
||||||
assert (s.days() == 1);
|
assert (s.days() == 1);
|
||||||
|
|
||||||
DateTime dt3 = dt1 + s;
|
DateTime dt3 = dt1 + s;
|
||||||
assert (dt3 == dt2);
|
assert (dt3 == dt2);
|
||||||
|
|
||||||
dt3 -= s;
|
dt3 -= s;
|
||||||
assert (dt3 == dt1);
|
assert (dt3 == dt1);
|
||||||
dt1 += s;
|
dt1 += s;
|
||||||
assert (dt1 == dt2);
|
assert (dt1 == dt2);
|
||||||
|
|
||||||
static const struct
|
static const struct
|
||||||
{
|
{
|
||||||
int lineNum; // source line number
|
int lineNum; // source line number
|
||||||
int year1; // operand/result date1 year
|
int year1; // operand/result date1 year
|
||||||
int month1; // operand/result date1 month
|
int month1; // operand/result date1 month
|
||||||
unsigned int day1; // operand/result date1 day
|
unsigned int day1; // operand/result date1 day
|
||||||
int numDays; // operand/result 'int' number of days
|
int numDays; // operand/result 'int' number of days
|
||||||
int year2; // operand/result date2 year
|
int year2; // operand/result date2 year
|
||||||
int month2; // operand/result date2 month
|
int month2; // operand/result date2 month
|
||||||
unsigned int day2; // operand/result date2 day
|
unsigned int day2; // operand/result date2 day
|
||||||
} data[] =
|
} data[] =
|
||||||
{
|
{
|
||||||
// - - - -first- - - - - - - second - - -
|
// - - - -first- - - - - - - second - - -
|
||||||
//line no. year month day numDays year month day
|
//line no. year month day numDays year month day
|
||||||
//------- ----- ----- ----- ------- ----- ----- -----
|
//------- ----- ----- ----- ------- ----- ----- -----
|
||||||
{ __LINE__, 1, 1, 1, 1, 1, 1, 2 },
|
{ __LINE__, 1, 1, 1, 1, 1, 1, 2 },
|
||||||
{ __LINE__, 10, 2, 28, 1, 10, 3, 1 },
|
{ __LINE__, 10, 2, 28, 1, 10, 3, 1 },
|
||||||
{ __LINE__, 100, 3, 31, 2, 100, 4, 2 },
|
{ __LINE__, 100, 3, 31, 2, 100, 4, 2 },
|
||||||
{ __LINE__, 1000, 4, 30, 4, 1000, 5, 4 },
|
{ __LINE__, 1000, 4, 30, 4, 1000, 5, 4 },
|
||||||
{ __LINE__, 1000, 6, 1, -31, 1000, 5, 1 },
|
{ __LINE__, 1000, 6, 1, -31, 1000, 5, 1 },
|
||||||
{ __LINE__, 1001, 1, 1, -365, 1000, 1, 1 },
|
{ __LINE__, 1001, 1, 1, -365, 1000, 1, 1 },
|
||||||
{ __LINE__, 1100, 5, 31, 30, 1100, 6, 30 },
|
{ __LINE__, 1100, 5, 31, 30, 1100, 6, 30 },
|
||||||
{ __LINE__, 1200, 6, 30, 32, 1200, 8, 1 },
|
{ __LINE__, 1200, 6, 30, 32, 1200, 8, 1 },
|
||||||
{ __LINE__, 1996, 2, 28, 367, 1997, 3, 1 },
|
{ __LINE__, 1996, 2, 28, 367, 1997, 3, 1 },
|
||||||
{ __LINE__, 1997, 2, 28, 366, 1998, 3, 1 },
|
{ __LINE__, 1997, 2, 28, 366, 1998, 3, 1 },
|
||||||
{ __LINE__, 1998, 2, 28, 365, 1999, 2, 28 },
|
{ __LINE__, 1998, 2, 28, 365, 1999, 2, 28 },
|
||||||
{ __LINE__, 1999, 2, 28, 364, 2000, 2, 27 },
|
{ __LINE__, 1999, 2, 28, 364, 2000, 2, 27 },
|
||||||
{ __LINE__, 1999, 2, 28, 1096, 2002, 2, 28 },
|
{ __LINE__, 1999, 2, 28, 1096, 2002, 2, 28 },
|
||||||
{ __LINE__, 2002, 2, 28, -1096, 1999, 2, 28 },
|
{ __LINE__, 2002, 2, 28, -1096, 1999, 2, 28 },
|
||||||
};
|
};
|
||||||
|
|
||||||
const int num_data = sizeof data / sizeof *data;
|
const int num_data = sizeof data / sizeof *data;
|
||||||
for (int di = 0; di < num_data; ++di)
|
for (int di = 0; di < num_data; ++di)
|
||||||
{
|
{
|
||||||
const int line = data[di].lineNum;
|
const int line = data[di].lineNum;
|
||||||
const int num_days = data[di].numDays;
|
const int num_days = data[di].numDays;
|
||||||
DateTime x = DateTime(data[di].year1, data[di].month1, data[di].day1);
|
DateTime x = DateTime(data[di].year1, data[di].month1, data[di].day1);
|
||||||
const DateTime& X = x;
|
const DateTime& X = x;
|
||||||
x += Timespan(num_days, 0, 0, 0, 0);
|
x += Timespan(num_days, 0, 0, 0, 0);
|
||||||
loop_1_assert(line, data[di].year2 == X.year());
|
loop_1_assert(line, data[di].year2 == X.year());
|
||||||
loop_1_assert(line, data[di].month2 == X.month());
|
loop_1_assert(line, data[di].month2 == X.month());
|
||||||
loop_1_assert(line, data[di].day2 == X.day());
|
loop_1_assert(line, data[di].day2 == X.day());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DateTimeTest::testIncrementDecrement()
|
void DateTimeTest::testIncrementDecrement()
|
||||||
{
|
{
|
||||||
static const struct
|
static const struct
|
||||||
{
|
{
|
||||||
int lineNum; // source line number
|
int lineNum; // source line number
|
||||||
int year1; // (first) date year
|
int year1; // (first) date year
|
||||||
int month1; // (first) date month
|
int month1; // (first) date month
|
||||||
unsigned int day1; // (first) date day
|
unsigned int day1; // (first) date day
|
||||||
int year2; // (second) date year
|
int year2; // (second) date year
|
||||||
int month2; // (second) date month
|
int month2; // (second) date month
|
||||||
unsigned int day2; // (second) date day
|
unsigned int day2; // (second) date day
|
||||||
} data[] =
|
} data[] =
|
||||||
{
|
{
|
||||||
// - - - -first- - - - - - - second - - -
|
// - - - -first- - - - - - - second - - -
|
||||||
//line no. year month day year month day
|
//line no. year month day year month day
|
||||||
//------- ----- ----- ----- ----- ----- -----
|
//------- ----- ----- ----- ----- ----- -----
|
||||||
{ __LINE__, 1, 1, 1, 1, 1, 2 },
|
{ __LINE__, 1, 1, 1, 1, 1, 2 },
|
||||||
{ __LINE__, 10, 2, 28, 10, 3, 1 },
|
{ __LINE__, 10, 2, 28, 10, 3, 1 },
|
||||||
{ __LINE__, 100, 3, 31, 100, 4, 1 },
|
{ __LINE__, 100, 3, 31, 100, 4, 1 },
|
||||||
{ __LINE__, 1000, 4, 30, 1000, 5, 1 },
|
{ __LINE__, 1000, 4, 30, 1000, 5, 1 },
|
||||||
{ __LINE__, 1100, 5, 31, 1100, 6, 1 },
|
{ __LINE__, 1100, 5, 31, 1100, 6, 1 },
|
||||||
{ __LINE__, 1200, 6, 30, 1200, 7, 1 },
|
{ __LINE__, 1200, 6, 30, 1200, 7, 1 },
|
||||||
{ __LINE__, 1300, 7, 31, 1300, 8, 1 },
|
{ __LINE__, 1300, 7, 31, 1300, 8, 1 },
|
||||||
{ __LINE__, 1400, 8, 31, 1400, 9, 1 },
|
{ __LINE__, 1400, 8, 31, 1400, 9, 1 },
|
||||||
{ __LINE__, 1500, 9, 30, 1500, 10, 1 },
|
{ __LINE__, 1500, 9, 30, 1500, 10, 1 },
|
||||||
{ __LINE__, 1600, 10, 31, 1600, 11, 1 },
|
{ __LINE__, 1600, 10, 31, 1600, 11, 1 },
|
||||||
{ __LINE__, 1700, 11, 30, 1700, 12, 1 },
|
{ __LINE__, 1700, 11, 30, 1700, 12, 1 },
|
||||||
{ __LINE__, 1800, 12, 31, 1801, 1, 1 },
|
{ __LINE__, 1800, 12, 31, 1801, 1, 1 },
|
||||||
{ __LINE__, 1996, 2, 28, 1996, 2, 29 },
|
{ __LINE__, 1996, 2, 28, 1996, 2, 29 },
|
||||||
{ __LINE__, 1997, 2, 28, 1997, 3, 1 },
|
{ __LINE__, 1997, 2, 28, 1997, 3, 1 },
|
||||||
{ __LINE__, 1998, 2, 28, 1998, 3, 1 },
|
{ __LINE__, 1998, 2, 28, 1998, 3, 1 },
|
||||||
{ __LINE__, 1999, 2, 28, 1999, 3, 1 },
|
{ __LINE__, 1999, 2, 28, 1999, 3, 1 },
|
||||||
{ __LINE__, 2000, 2, 28, 2000, 2, 29 },
|
{ __LINE__, 2000, 2, 28, 2000, 2, 29 },
|
||||||
{ __LINE__, 2001, 2, 28, 2001, 3, 1 },
|
{ __LINE__, 2001, 2, 28, 2001, 3, 1 },
|
||||||
{ __LINE__, 2004, 2, 28, 2004, 2, 29 },
|
{ __LINE__, 2004, 2, 28, 2004, 2, 29 },
|
||||||
{ __LINE__, 2100, 2, 28, 2100, 3, 1 },
|
{ __LINE__, 2100, 2, 28, 2100, 3, 1 },
|
||||||
{ __LINE__, 2400, 2, 28, 2400, 2, 29 },
|
{ __LINE__, 2400, 2, 28, 2400, 2, 29 },
|
||||||
};
|
};
|
||||||
|
|
||||||
const int num_data = sizeof data / sizeof *data;
|
const int num_data = sizeof data / sizeof *data;
|
||||||
int di;
|
int di;
|
||||||
|
|
||||||
for (di = 0; di < num_data; ++di)
|
for (di = 0; di < num_data; ++di)
|
||||||
{
|
{
|
||||||
const int line = data[di].lineNum;
|
const int line = data[di].lineNum;
|
||||||
DateTime x = DateTime(data[di].year1, data[di].month1,
|
DateTime x = DateTime(data[di].year1, data[di].month1,
|
||||||
data[di].day1);
|
data[di].day1);
|
||||||
// Would do pre-increment of x here.
|
// Would do pre-increment of x here.
|
||||||
const DateTime& X = x;
|
const DateTime& X = x;
|
||||||
x = x + Timespan(1,0,0,0,0);
|
x = x + Timespan(1,0,0,0,0);
|
||||||
DateTime y = x; const DateTime& Y = y;
|
DateTime y = x; const DateTime& Y = y;
|
||||||
|
|
||||||
loop_1_assert(line, data[di].year2 == X.year());
|
loop_1_assert(line, data[di].year2 == X.year());
|
||||||
loop_1_assert(line, data[di].month2 == X.month());
|
loop_1_assert(line, data[di].month2 == X.month());
|
||||||
loop_1_assert(line, data[di].day2 == X.day());
|
loop_1_assert(line, data[di].day2 == X.day());
|
||||||
|
|
||||||
loop_1_assert(line, data[di].year2 == Y.year());
|
loop_1_assert(line, data[di].year2 == Y.year());
|
||||||
loop_1_assert(line, data[di].month2 == Y.month());
|
loop_1_assert(line, data[di].month2 == Y.month());
|
||||||
loop_1_assert(line, data[di].day2 == Y.day());
|
loop_1_assert(line, data[di].day2 == Y.day());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (di = 0; di < num_data; ++di)
|
for (di = 0; di < num_data; ++di)
|
||||||
{
|
{
|
||||||
const int line = data[di].lineNum;
|
const int line = data[di].lineNum;
|
||||||
DateTime x = DateTime(data[di].year1, data[di].month1, data[di].day1);
|
DateTime x = DateTime(data[di].year1, data[di].month1, data[di].day1);
|
||||||
DateTime x1 = DateTime(data[di].year1, data[di].month1, data[di].day1);
|
DateTime x1 = DateTime(data[di].year1, data[di].month1, data[di].day1);
|
||||||
DateTime x2 = DateTime(data[di].year2, data[di].month2, data[di].day2);
|
DateTime x2 = DateTime(data[di].year2, data[di].month2, data[di].day2);
|
||||||
DateTime y = x; const DateTime& Y = y;
|
DateTime y = x; const DateTime& Y = y;
|
||||||
|
|
||||||
// Would do post increment of x here.
|
// Would do post increment of x here.
|
||||||
const DateTime& X = x;
|
const DateTime& X = x;
|
||||||
x = x + Timespan(1,0,0,0,0);
|
x = x + Timespan(1,0,0,0,0);
|
||||||
|
|
||||||
loop_1_assert(line, data[di].year2 == X.year());
|
loop_1_assert(line, data[di].year2 == X.year());
|
||||||
loop_1_assert(line, data[di].month2 == X.month());
|
loop_1_assert(line, data[di].month2 == X.month());
|
||||||
loop_1_assert(line, data[di].day2 == X.day());
|
loop_1_assert(line, data[di].day2 == X.day());
|
||||||
loop_1_assert(line, data[di].year1 == Y.year());
|
loop_1_assert(line, data[di].year1 == Y.year());
|
||||||
loop_1_assert(line, data[di].month1 == Y.month());
|
loop_1_assert(line, data[di].month1 == Y.month());
|
||||||
loop_1_assert(line, data[di].day1 == Y.day());
|
loop_1_assert(line, data[di].day1 == Y.day());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (di = 0; di < num_data; ++di)
|
for (di = 0; di < num_data; ++di)
|
||||||
{
|
{
|
||||||
const int line = data[di].lineNum;
|
const int line = data[di].lineNum;
|
||||||
DateTime x = DateTime(data[di].year2, data[di].month2, data[di].day2);
|
DateTime x = DateTime(data[di].year2, data[di].month2, data[di].day2);
|
||||||
const DateTime& X = x;
|
const DateTime& X = x;
|
||||||
x = x - Timespan(1,0,0,0,0);
|
x = x - Timespan(1,0,0,0,0);
|
||||||
DateTime y = x; DateTime Y = y;
|
DateTime y = x; DateTime Y = y;
|
||||||
|
|
||||||
loop_1_assert(line, data[di].year1 == X.year());
|
loop_1_assert(line, data[di].year1 == X.year());
|
||||||
loop_1_assert(line, data[di].month1 == X.month());
|
loop_1_assert(line, data[di].month1 == X.month());
|
||||||
loop_1_assert(line, data[di].day1 == X.day());
|
loop_1_assert(line, data[di].day1 == X.day());
|
||||||
|
|
||||||
loop_1_assert(line, data[di].year1 == Y.year());
|
loop_1_assert(line, data[di].year1 == Y.year());
|
||||||
loop_1_assert(line, data[di].month1 == Y.month());
|
loop_1_assert(line, data[di].month1 == Y.month());
|
||||||
loop_1_assert(line, data[di].day1 == Y.day());
|
loop_1_assert(line, data[di].day1 == Y.day());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (di = 0; di < num_data; ++di)
|
for (di = 0; di < num_data; ++di)
|
||||||
{
|
{
|
||||||
const int line = data[di].lineNum;
|
const int line = data[di].lineNum;
|
||||||
DateTime x1 = DateTime(data[di].year1, data[di].month1, data[di].day1);
|
DateTime x1 = DateTime(data[di].year1, data[di].month1, data[di].day1);
|
||||||
DateTime x = DateTime(data[di].year2, data[di].month2, data[di].day2);
|
DateTime x = DateTime(data[di].year2, data[di].month2, data[di].day2);
|
||||||
DateTime y = x; DateTime Y = y;
|
DateTime y = x; DateTime Y = y;
|
||||||
const DateTime& X = x;
|
const DateTime& X = x;
|
||||||
// would post-decrement x here.
|
// would post-decrement x here.
|
||||||
x = x - Timespan(1,0,0,0,0);
|
x = x - Timespan(1,0,0,0,0);
|
||||||
|
|
||||||
loop_1_assert(line, data[di].year1 == X.year());
|
loop_1_assert(line, data[di].year1 == X.year());
|
||||||
loop_1_assert(line, data[di].month1 == X.month());
|
loop_1_assert(line, data[di].month1 == X.month());
|
||||||
loop_1_assert(line, data[di].day1 == X.day());
|
loop_1_assert(line, data[di].day1 == X.day());
|
||||||
|
|
||||||
loop_1_assert(line, data[di].year2 == Y.year());
|
loop_1_assert(line, data[di].year2 == Y.year());
|
||||||
loop_1_assert(line, data[di].month2 == Y.month());
|
loop_1_assert(line, data[di].month2 == Y.month());
|
||||||
loop_1_assert(line, data[di].day2 == Y.day());
|
loop_1_assert(line, data[di].day2 == Y.day());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -598,37 +598,37 @@ void DateTimeTest::testSwap()
|
|||||||
|
|
||||||
void DateTimeTest::testUsage()
|
void DateTimeTest::testUsage()
|
||||||
{
|
{
|
||||||
DateTime dt1(1776, 7, 4);
|
DateTime dt1(1776, 7, 4);
|
||||||
assert (dt1.year() == 1776);
|
assert (dt1.year() == 1776);
|
||||||
assert (dt1.month() == 7);
|
assert (dt1.month() == 7);
|
||||||
assert (dt1.day() == 4);
|
assert (dt1.day() == 4);
|
||||||
|
|
||||||
DateTime dt2(dt1);
|
DateTime dt2(dt1);
|
||||||
dt2 += Timespan(6, 0, 0, 0, 0);
|
dt2 += Timespan(6, 0, 0, 0, 0);
|
||||||
assert (dt2.year() == 1776);
|
assert (dt2.year() == 1776);
|
||||||
assert (dt2.month() == 7);
|
assert (dt2.month() == 7);
|
||||||
assert (dt2.day() == 10);
|
assert (dt2.day() == 10);
|
||||||
|
|
||||||
Timespan span = dt2 - dt1;
|
Timespan span = dt2 - dt1;
|
||||||
assert (span.days() == 6);
|
assert (span.days() == 6);
|
||||||
|
|
||||||
// TODO - When adding months and years we need to be
|
// TODO - When adding months and years we need to be
|
||||||
// able to specify the end-end convention.
|
// able to specify the end-end convention.
|
||||||
// We cannot do this in POCO at the moment.
|
// We cannot do this in POCO at the moment.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DateTimeTest::testSetYearDay()
|
void DateTimeTest::testSetYearDay()
|
||||||
{
|
{
|
||||||
static const struct
|
static const struct
|
||||||
{
|
{
|
||||||
int d_lineNum; // source line number
|
int d_lineNum; // source line number
|
||||||
int d_year; // year under test
|
int d_year; // year under test
|
||||||
unsigned int d_day; // day-of-year under test
|
unsigned int d_day; // day-of-year under test
|
||||||
int d_expMonth; // expected month
|
int d_expMonth; // expected month
|
||||||
unsigned int d_expDay; // expected day
|
unsigned int d_expDay; // expected day
|
||||||
} data[] =
|
} data[] =
|
||||||
{
|
{
|
||||||
//line no. year dayOfYr exp. month exp. day
|
//line no. year dayOfYr exp. month exp. day
|
||||||
//------- ----- ------- ---------- --------
|
//------- ----- ------- ---------- --------
|
||||||
{ __LINE__, 1, 1, 1, 1 },
|
{ __LINE__, 1, 1, 1, 1 },
|
||||||
@@ -638,93 +638,93 @@ void DateTimeTest::testSetYearDay()
|
|||||||
{ __LINE__, 1996, 2, 1, 2 },
|
{ __LINE__, 1996, 2, 1, 2 },
|
||||||
{ __LINE__, 1996, 365, 12, 30 },
|
{ __LINE__, 1996, 365, 12, 30 },
|
||||||
{ __LINE__, 1996, 366, 12, 31 }
|
{ __LINE__, 1996, 366, 12, 31 }
|
||||||
};
|
|
||||||
|
|
||||||
const int num_data = sizeof data / sizeof *data;
|
|
||||||
for (int di = 0; di < num_data; ++di)
|
|
||||||
{
|
|
||||||
const int line = data[di].d_lineNum;
|
|
||||||
const int year = data[di].d_year;
|
|
||||||
const unsigned int day = data[di].d_day;
|
|
||||||
|
|
||||||
const int exp_month = data[di].d_expMonth;
|
|
||||||
const unsigned int exp_day = data[di].d_expDay;
|
|
||||||
const DateTime r(year, exp_month, exp_day);
|
|
||||||
DateTime x;
|
|
||||||
const DateTime& X = x;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
// TODO - need to be able to assign a day number in the year
|
|
||||||
// but POCO is not able to do this.
|
|
||||||
|
|
||||||
x.assign(year, day);
|
|
||||||
|
|
||||||
// TODO - need to be able to assert with the loop counter
|
|
||||||
// but cppUnit is not able to do this.
|
|
||||||
|
|
||||||
assert (r == x);
|
|
||||||
assert (day == X.dayOfYear());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct
|
|
||||||
{
|
|
||||||
int d_lineNum; // source line number
|
|
||||||
int d_year; // year under test
|
|
||||||
int d_day; // day-of-year under test
|
|
||||||
int d_exp; // expected status
|
|
||||||
} data2[] =
|
|
||||||
{
|
|
||||||
//line no. year dayOfYr expected value
|
|
||||||
//------- ----- ------- --------------
|
|
||||||
{ __LINE__, 1, 1, 1 },
|
|
||||||
{ __LINE__, 1, -1, 0 },
|
|
||||||
{ __LINE__, 1, 0, 0 },
|
|
||||||
{ __LINE__, 1, 365, 1 },
|
|
||||||
{ __LINE__, 1, 366, 0 },
|
|
||||||
{ __LINE__, 1, 367, 0 },
|
|
||||||
{ __LINE__, 0, 0, 0 },
|
|
||||||
{ __LINE__, -1, -1, 0 },
|
|
||||||
{ __LINE__, 1996, 1, 1 },
|
|
||||||
{ __LINE__, 1996, 2, 1 },
|
|
||||||
{ __LINE__, 1996, 32, 1 },
|
|
||||||
{ __LINE__, 1996, 365, 1 },
|
|
||||||
{ __LINE__, 1996, 366, 1 },
|
|
||||||
{ __LINE__, 1996, 367, 0 },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const int num_data2 = sizeof data2 / sizeof *data2;
|
const int num_data = sizeof data / sizeof *data;
|
||||||
for (int di = 0; di < num_data2; ++di)
|
for (int di = 0; di < num_data; ++di)
|
||||||
{
|
{
|
||||||
const int line = data2[di].d_lineNum;
|
const int line = data[di].d_lineNum;
|
||||||
const int year = data2[di].d_year;
|
const int year = data[di].d_year;
|
||||||
const int day = data2[di].d_day;
|
const unsigned int day = data[di].d_day;
|
||||||
const int exp = data2[di].d_exp;
|
|
||||||
DateTime x;
|
const int exp_month = data[di].d_expMonth;
|
||||||
const DateTime& X = x;
|
const unsigned int exp_day = data[di].d_expDay;
|
||||||
if (1 == exp)
|
const DateTime r(year, exp_month, exp_day);
|
||||||
{
|
DateTime x;
|
||||||
DateTime r;
|
const DateTime& X = x;
|
||||||
const DateTime& r2 = r;
|
|
||||||
#if 0
|
#if 0
|
||||||
r.set(year, day);
|
// TODO - need to be able to assign a day number in the year
|
||||||
|
// but POCO is not able to do this.
|
||||||
|
|
||||||
|
x.assign(year, day);
|
||||||
|
|
||||||
|
// TODO - need to be able to assert with the loop counter
|
||||||
|
// but cppUnit is not able to do this.
|
||||||
|
|
||||||
|
assert (r == x);
|
||||||
|
assert (day == X.dayOfYear());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
static const struct
|
||||||
|
{
|
||||||
|
int d_lineNum; // source line number
|
||||||
|
int d_year; // year under test
|
||||||
|
int d_day; // day-of-year under test
|
||||||
|
int d_exp; // expected status
|
||||||
|
} data2[] =
|
||||||
|
{
|
||||||
|
//line no. year dayOfYr expected value
|
||||||
|
//------- ----- ------- --------------
|
||||||
|
{ __LINE__, 1, 1, 1 },
|
||||||
|
{ __LINE__, 1, -1, 0 },
|
||||||
|
{ __LINE__, 1, 0, 0 },
|
||||||
|
{ __LINE__, 1, 365, 1 },
|
||||||
|
{ __LINE__, 1, 366, 0 },
|
||||||
|
{ __LINE__, 1, 367, 0 },
|
||||||
|
{ __LINE__, 0, 0, 0 },
|
||||||
|
{ __LINE__, -1, -1, 0 },
|
||||||
|
{ __LINE__, 1996, 1, 1 },
|
||||||
|
{ __LINE__, 1996, 2, 1 },
|
||||||
|
{ __LINE__, 1996, 32, 1 },
|
||||||
|
{ __LINE__, 1996, 365, 1 },
|
||||||
|
{ __LINE__, 1996, 366, 1 },
|
||||||
|
{ __LINE__, 1996, 367, 0 },
|
||||||
|
};
|
||||||
|
|
||||||
|
const int num_data2 = sizeof data2 / sizeof *data2;
|
||||||
|
for (int di = 0; di < num_data2; ++di)
|
||||||
|
{
|
||||||
|
const int line = data2[di].d_lineNum;
|
||||||
|
const int year = data2[di].d_year;
|
||||||
|
const int day = data2[di].d_day;
|
||||||
|
const int exp = data2[di].d_exp;
|
||||||
|
DateTime x;
|
||||||
|
const DateTime& X = x;
|
||||||
|
if (1 == exp)
|
||||||
|
{
|
||||||
|
DateTime r;
|
||||||
|
const DateTime& r2 = r;
|
||||||
|
#if 0
|
||||||
|
r.set(year, day);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DateTimeTest::testIsValid()
|
void DateTimeTest::testIsValid()
|
||||||
{
|
{
|
||||||
static const struct
|
static const struct
|
||||||
{
|
{
|
||||||
int d_lineNum; // source line number
|
int d_lineNum; // source line number
|
||||||
int d_year; // year under test
|
int d_year; // year under test
|
||||||
int d_month; // month under test
|
int d_month; // month under test
|
||||||
int d_day; // day under test
|
int d_day; // day under test
|
||||||
bool d_exp; // expected value
|
bool d_exp; // expected value
|
||||||
} data[] =
|
} data[] =
|
||||||
{
|
{
|
||||||
//line no. year month day expected value
|
//line no. year month day expected value
|
||||||
//------- ----- ----- ----- --------------
|
//------- ----- ----- ----- --------------
|
||||||
{ __LINE__, 0, 0, 0, false },
|
{ __LINE__, 0, 0, 0, false },
|
||||||
@@ -761,34 +761,34 @@ void DateTimeTest::testIsValid()
|
|||||||
{ __LINE__, 2100, 2, 29, false },
|
{ __LINE__, 2100, 2, 29, false },
|
||||||
};
|
};
|
||||||
|
|
||||||
const int num_data = sizeof data / sizeof *data;
|
const int num_data = sizeof data / sizeof *data;
|
||||||
for (int di = 0; di < num_data; ++di)
|
for (int di = 0; di < num_data; ++di)
|
||||||
{
|
{
|
||||||
const int line = data[di].d_lineNum;
|
const int line = data[di].d_lineNum;
|
||||||
const int year = data[di].d_year;
|
const int year = data[di].d_year;
|
||||||
const int month = data[di].d_month;
|
const int month = data[di].d_month;
|
||||||
const int day = data[di].d_day;
|
const int day = data[di].d_day;
|
||||||
const bool exp = data[di].d_exp;
|
const bool exp = data[di].d_exp;
|
||||||
|
|
||||||
bool isValid = DateTime::isValid(year, month, day);
|
bool isValid = DateTime::isValid(year, month, day);
|
||||||
loop_1_assert(line, exp == isValid);
|
loop_1_assert(line, exp == isValid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DateTimeTest::testDayOfWeek()
|
void DateTimeTest::testDayOfWeek()
|
||||||
{
|
{
|
||||||
typedef DateTime::DaysOfWeek DOW;
|
typedef DateTime::DaysOfWeek DOW;
|
||||||
|
|
||||||
static const struct
|
static const struct
|
||||||
{
|
{
|
||||||
int d_lineNum; // source line number
|
int d_lineNum; // source line number
|
||||||
int d_year; // year under test
|
int d_year; // year under test
|
||||||
int d_month; // month under test
|
int d_month; // month under test
|
||||||
int d_day; // day under test
|
int d_day; // day under test
|
||||||
DOW d_expDay; // number of days to be added
|
DOW d_expDay; // number of days to be added
|
||||||
} data[] =
|
} data[] =
|
||||||
{
|
{
|
||||||
//Line no. year month day expDay
|
//Line no. year month day expDay
|
||||||
//------- ----- ----- ----- -------
|
//------- ----- ----- ----- -------
|
||||||
{ __LINE__, 1600, 1, 1, DateTime::SATURDAY },
|
{ __LINE__, 1600, 1, 1, DateTime::SATURDAY },
|
||||||
@@ -820,16 +820,16 @@ void DateTimeTest::testDayOfWeek()
|
|||||||
{ __LINE__, 2000, 1, 2, DateTime::SUNDAY },
|
{ __LINE__, 2000, 1, 2, DateTime::SUNDAY },
|
||||||
{ __LINE__, 2000, 1, 3, DateTime::MONDAY },
|
{ __LINE__, 2000, 1, 3, DateTime::MONDAY },
|
||||||
{ __LINE__, 2000, 1, 4, DateTime::TUESDAY },
|
{ __LINE__, 2000, 1, 4, DateTime::TUESDAY },
|
||||||
};
|
};
|
||||||
|
|
||||||
const int num_data = sizeof data / sizeof *data;
|
const int num_data = sizeof data / sizeof *data;
|
||||||
for (int di = 0; di < num_data ; ++di)
|
for (int di = 0; di < num_data ; ++di)
|
||||||
{
|
{
|
||||||
const int line = data[di].d_lineNum;
|
const int line = data[di].d_lineNum;
|
||||||
DateTime x = DateTime(data[di].d_year, data[di].d_month, data[di].d_day);
|
DateTime x = DateTime(data[di].d_year, data[di].d_month, data[di].d_day);
|
||||||
const DateTime& X = x;
|
const DateTime& X = x;
|
||||||
loop_1_assert(line, data[di].d_expDay == X.dayOfWeek());
|
loop_1_assert(line, data[di].d_expDay == X.dayOfWeek());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -446,17 +446,17 @@ void FileChannelTest::noPurgeAge(const std::string& npa)
|
|||||||
|
|
||||||
void FileChannelTest::testPurgeAge()
|
void FileChannelTest::testPurgeAge()
|
||||||
{
|
{
|
||||||
purgeAge("5 seconds");
|
purgeAge("5 seconds");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
noPurgeAge("0 seconds");
|
noPurgeAge("0 seconds");
|
||||||
fail ("must fail");
|
fail ("must fail");
|
||||||
} catch (InvalidArgumentException&)
|
} catch (InvalidArgumentException&)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
noPurgeAge("");
|
noPurgeAge("");
|
||||||
noPurgeAge("none");
|
noPurgeAge("none");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -72,14 +72,14 @@ public:
|
|||||||
static CppUnit::Test* suite();
|
static CppUnit::Test* suite();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <class D> std::string rotation(TimeRotation rtype) const;
|
template <class D> std::string rotation(TimeRotation rtype) const;
|
||||||
void remove(const std::string& baseName);
|
void remove(const std::string& baseName);
|
||||||
std::string filename() const;
|
std::string filename() const;
|
||||||
|
|
||||||
void purgeAge(const std::string& purgeAge);
|
void purgeAge(const std::string& purgeAge);
|
||||||
void noPurgeAge(const std::string& purgeAge);
|
void noPurgeAge(const std::string& purgeAge);
|
||||||
void purgeCount(const std::string& pc);
|
void purgeCount(const std::string& pc);
|
||||||
void noPurgeCount(const std::string& pc);
|
void noPurgeCount(const std::string& pc);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -73,17 +73,17 @@ void NamedTuplesTest::testNamedTuple1()
|
|||||||
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
||||||
catch (NotFoundException&) { }
|
catch (NotFoundException&) { }
|
||||||
assert (aTuple.length == 1);
|
assert (aTuple.length == 1);
|
||||||
|
|
||||||
TupleType aTuple2("string1", "1");
|
TupleType aTuple2("string1", "1");
|
||||||
assert (aTuple2["string1"] == "1");
|
assert (aTuple2["string1"] == "1");
|
||||||
|
|
||||||
assert (aTuple != aTuple2);
|
assert (aTuple != aTuple2);
|
||||||
aTuple = aTuple2;
|
aTuple = aTuple2;
|
||||||
assert (aTuple == aTuple2);
|
assert (aTuple == aTuple2);
|
||||||
aTuple2.set<0>("2");
|
aTuple2.set<0>("2");
|
||||||
assert (aTuple < aTuple2);
|
assert (aTuple < aTuple2);
|
||||||
|
|
||||||
TupleType aTuple3(aTuple2.names());
|
TupleType aTuple3(aTuple2.names());
|
||||||
assert (aTuple3.names() == aTuple2.names());
|
assert (aTuple3.names() == aTuple2.names());
|
||||||
assert (aTuple3["string1"] == "");
|
assert (aTuple3["string1"] == "");
|
||||||
assert (aTuple3.length == 1);
|
assert (aTuple3.length == 1);
|
||||||
@@ -109,19 +109,19 @@ void NamedTuplesTest::testNamedTuple2()
|
|||||||
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
||||||
catch (NotFoundException&) { }
|
catch (NotFoundException&) { }
|
||||||
assert (aTuple.length == 2);
|
assert (aTuple.length == 2);
|
||||||
|
|
||||||
TupleType aTuple2("string1", "1",
|
TupleType aTuple2("string1", "1",
|
||||||
"int1", 1);
|
"int1", 1);
|
||||||
assert (aTuple2["string1"] == "1");
|
assert (aTuple2["string1"] == "1");
|
||||||
assert (aTuple2["int1"] == 1);
|
assert (aTuple2["int1"] == 1);
|
||||||
|
|
||||||
assert (aTuple != aTuple2);
|
assert (aTuple != aTuple2);
|
||||||
aTuple = aTuple2;
|
aTuple = aTuple2;
|
||||||
assert (aTuple == aTuple2);
|
assert (aTuple == aTuple2);
|
||||||
aTuple2.get<1>()++;
|
aTuple2.get<1>()++;
|
||||||
assert (aTuple < aTuple2);
|
assert (aTuple < aTuple2);
|
||||||
|
|
||||||
TupleType aTuple3(aTuple2.names());
|
TupleType aTuple3(aTuple2.names());
|
||||||
assert (aTuple3.names() == aTuple2.names());
|
assert (aTuple3.names() == aTuple2.names());
|
||||||
assert (aTuple3["string1"] == "");
|
assert (aTuple3["string1"] == "");
|
||||||
assert (aTuple3["int1"] == 0);
|
assert (aTuple3["int1"] == 0);
|
||||||
@@ -151,21 +151,21 @@ void NamedTuplesTest::testNamedTuple3()
|
|||||||
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
||||||
catch (NotFoundException&) { }
|
catch (NotFoundException&) { }
|
||||||
assert (aTuple.length == 3);
|
assert (aTuple.length == 3);
|
||||||
|
|
||||||
TupleType aTuple2("string1", "1",
|
TupleType aTuple2("string1", "1",
|
||||||
"int1", 1,
|
"int1", 1,
|
||||||
"bool1", true);
|
"bool1", true);
|
||||||
assert (aTuple2["string1"] == "1");
|
assert (aTuple2["string1"] == "1");
|
||||||
assert (aTuple2["int1"] == 1);
|
assert (aTuple2["int1"] == 1);
|
||||||
assert (aTuple2["bool1"] == true);
|
assert (aTuple2["bool1"] == true);
|
||||||
|
|
||||||
assert (aTuple != aTuple2);
|
assert (aTuple != aTuple2);
|
||||||
aTuple = aTuple2;
|
aTuple = aTuple2;
|
||||||
assert (aTuple == aTuple2);
|
assert (aTuple == aTuple2);
|
||||||
aTuple2.get<1>()++;
|
aTuple2.get<1>()++;
|
||||||
assert (aTuple < aTuple2);
|
assert (aTuple < aTuple2);
|
||||||
|
|
||||||
TupleType aTuple3(aTuple2.names());
|
TupleType aTuple3(aTuple2.names());
|
||||||
assert (aTuple3.names() == aTuple2.names());
|
assert (aTuple3.names() == aTuple2.names());
|
||||||
assert (aTuple3["string1"] == "");
|
assert (aTuple3["string1"] == "");
|
||||||
assert (aTuple3["int1"] == 0);
|
assert (aTuple3["int1"] == 0);
|
||||||
@@ -197,23 +197,23 @@ void NamedTuplesTest::testNamedTuple4()
|
|||||||
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
||||||
catch (NotFoundException&) { }
|
catch (NotFoundException&) { }
|
||||||
assert (aTuple.length == 4);
|
assert (aTuple.length == 4);
|
||||||
|
|
||||||
TupleType aTuple2("string1", "1",
|
TupleType aTuple2("string1", "1",
|
||||||
"int1", 1,
|
"int1", 1,
|
||||||
"bool1", true,
|
"bool1", true,
|
||||||
"float1", 1.5f);
|
"float1", 1.5f);
|
||||||
assert (aTuple2["string1"] == "1");
|
assert (aTuple2["string1"] == "1");
|
||||||
assert (aTuple2["int1"] == 1);
|
assert (aTuple2["int1"] == 1);
|
||||||
assert (aTuple2["bool1"] == true);
|
assert (aTuple2["bool1"] == true);
|
||||||
assert (aTuple2["float1"] == 1.5);
|
assert (aTuple2["float1"] == 1.5);
|
||||||
|
|
||||||
assert (aTuple != aTuple2);
|
assert (aTuple != aTuple2);
|
||||||
aTuple = aTuple2;
|
aTuple = aTuple2;
|
||||||
assert (aTuple == aTuple2);
|
assert (aTuple == aTuple2);
|
||||||
aTuple2.get<1>()++;
|
aTuple2.get<1>()++;
|
||||||
assert (aTuple < aTuple2);
|
assert (aTuple < aTuple2);
|
||||||
|
|
||||||
TupleType aTuple3(aTuple2.names());
|
TupleType aTuple3(aTuple2.names());
|
||||||
assert (aTuple3.names() == aTuple2.names());
|
assert (aTuple3.names() == aTuple2.names());
|
||||||
assert (aTuple3["string1"] == "");
|
assert (aTuple3["string1"] == "");
|
||||||
assert (aTuple3["int1"] == 0);
|
assert (aTuple3["int1"] == 0);
|
||||||
@@ -247,12 +247,12 @@ void NamedTuplesTest::testNamedTuple5()
|
|||||||
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
||||||
catch (NotFoundException&) { }
|
catch (NotFoundException&) { }
|
||||||
assert (aTuple.length == 5);
|
assert (aTuple.length == 5);
|
||||||
|
|
||||||
TupleType aTuple2("string1", "1",
|
TupleType aTuple2("string1", "1",
|
||||||
"int1", 1,
|
"int1", 1,
|
||||||
"bool1", true,
|
"bool1", true,
|
||||||
"float1", 1.5f,
|
"float1", 1.5f,
|
||||||
"char1", 'c');
|
"char1", 'c');
|
||||||
assert (aTuple2["string1"] == "1");
|
assert (aTuple2["string1"] == "1");
|
||||||
assert (aTuple2["int1"] == 1);
|
assert (aTuple2["int1"] == 1);
|
||||||
assert (aTuple2["bool1"] == true);
|
assert (aTuple2["bool1"] == true);
|
||||||
@@ -260,12 +260,12 @@ void NamedTuplesTest::testNamedTuple5()
|
|||||||
assert (aTuple2["char1"] == 'c');
|
assert (aTuple2["char1"] == 'c');
|
||||||
|
|
||||||
assert (aTuple != aTuple2);
|
assert (aTuple != aTuple2);
|
||||||
aTuple = aTuple2;
|
aTuple = aTuple2;
|
||||||
assert (aTuple == aTuple2);
|
assert (aTuple == aTuple2);
|
||||||
aTuple2.get<1>()++;
|
aTuple2.get<1>()++;
|
||||||
assert (aTuple < aTuple2);
|
assert (aTuple < aTuple2);
|
||||||
|
|
||||||
TupleType aTuple3(aTuple2.names());
|
TupleType aTuple3(aTuple2.names());
|
||||||
assert (aTuple3.names() == aTuple2.names());
|
assert (aTuple3.names() == aTuple2.names());
|
||||||
assert (aTuple3["string1"] == "");
|
assert (aTuple3["string1"] == "");
|
||||||
assert (aTuple3["int1"] == 0);
|
assert (aTuple3["int1"] == 0);
|
||||||
@@ -302,13 +302,13 @@ void NamedTuplesTest::testNamedTuple6()
|
|||||||
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
||||||
catch (NotFoundException&) { }
|
catch (NotFoundException&) { }
|
||||||
assert (aTuple.length == 6);
|
assert (aTuple.length == 6);
|
||||||
|
|
||||||
TupleType aTuple2("string1", "1",
|
TupleType aTuple2("string1", "1",
|
||||||
"int1", 1,
|
"int1", 1,
|
||||||
"bool1", true,
|
"bool1", true,
|
||||||
"float1", 1.5f,
|
"float1", 1.5f,
|
||||||
"char1", 'c',
|
"char1", 'c',
|
||||||
"long1", 999);
|
"long1", 999);
|
||||||
assert (aTuple2["string1"] == "1");
|
assert (aTuple2["string1"] == "1");
|
||||||
assert (aTuple2["int1"] == 1);
|
assert (aTuple2["int1"] == 1);
|
||||||
assert (aTuple2["bool1"] == true);
|
assert (aTuple2["bool1"] == true);
|
||||||
@@ -317,12 +317,12 @@ void NamedTuplesTest::testNamedTuple6()
|
|||||||
assert (aTuple2["long1"] == 999);
|
assert (aTuple2["long1"] == 999);
|
||||||
|
|
||||||
assert (aTuple != aTuple2);
|
assert (aTuple != aTuple2);
|
||||||
aTuple = aTuple2;
|
aTuple = aTuple2;
|
||||||
assert (aTuple == aTuple2);
|
assert (aTuple == aTuple2);
|
||||||
aTuple2.get<1>()++;
|
aTuple2.get<1>()++;
|
||||||
assert (aTuple < aTuple2);
|
assert (aTuple < aTuple2);
|
||||||
|
|
||||||
TupleType aTuple3(aTuple2.names());
|
TupleType aTuple3(aTuple2.names());
|
||||||
assert (aTuple3.names() == aTuple2.names());
|
assert (aTuple3.names() == aTuple2.names());
|
||||||
assert (aTuple3["string1"] == "");
|
assert (aTuple3["string1"] == "");
|
||||||
assert (aTuple3["int1"] == 0);
|
assert (aTuple3["int1"] == 0);
|
||||||
@@ -361,14 +361,14 @@ void NamedTuplesTest::testNamedTuple7()
|
|||||||
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
||||||
catch (NotFoundException&) { }
|
catch (NotFoundException&) { }
|
||||||
assert (aTuple.length == 7);
|
assert (aTuple.length == 7);
|
||||||
|
|
||||||
TupleType aTuple2("string1", "1",
|
TupleType aTuple2("string1", "1",
|
||||||
"int1", 1,
|
"int1", 1,
|
||||||
"bool1", true,
|
"bool1", true,
|
||||||
"float1", 1.5f,
|
"float1", 1.5f,
|
||||||
"char1", 'c',
|
"char1", 'c',
|
||||||
"long1", 999,
|
"long1", 999,
|
||||||
"double1", 1.5);
|
"double1", 1.5);
|
||||||
assert (aTuple2["string1"] == "1");
|
assert (aTuple2["string1"] == "1");
|
||||||
assert (aTuple2["int1"] == 1);
|
assert (aTuple2["int1"] == 1);
|
||||||
assert (aTuple2["bool1"] == true);
|
assert (aTuple2["bool1"] == true);
|
||||||
@@ -378,12 +378,12 @@ void NamedTuplesTest::testNamedTuple7()
|
|||||||
assert (aTuple2["double1"] == 1.5);
|
assert (aTuple2["double1"] == 1.5);
|
||||||
|
|
||||||
assert (aTuple != aTuple2);
|
assert (aTuple != aTuple2);
|
||||||
aTuple = aTuple2;
|
aTuple = aTuple2;
|
||||||
assert (aTuple == aTuple2);
|
assert (aTuple == aTuple2);
|
||||||
aTuple2.get<1>()++;
|
aTuple2.get<1>()++;
|
||||||
assert (aTuple < aTuple2);
|
assert (aTuple < aTuple2);
|
||||||
|
|
||||||
TupleType aTuple3(aTuple2.names());
|
TupleType aTuple3(aTuple2.names());
|
||||||
assert (aTuple3.names() == aTuple2.names());
|
assert (aTuple3.names() == aTuple2.names());
|
||||||
assert (aTuple3["string1"] == "");
|
assert (aTuple3["string1"] == "");
|
||||||
assert (aTuple3["int1"] == 0);
|
assert (aTuple3["int1"] == 0);
|
||||||
@@ -424,15 +424,15 @@ void NamedTuplesTest::testNamedTuple8()
|
|||||||
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
||||||
catch (NotFoundException&) { }
|
catch (NotFoundException&) { }
|
||||||
assert (aTuple.length == 8);
|
assert (aTuple.length == 8);
|
||||||
|
|
||||||
TupleType aTuple2("string1", "1",
|
TupleType aTuple2("string1", "1",
|
||||||
"int1", 1,
|
"int1", 1,
|
||||||
"bool1", true,
|
"bool1", true,
|
||||||
"float1", 1.5f,
|
"float1", 1.5f,
|
||||||
"char1", 'c',
|
"char1", 'c',
|
||||||
"long1", 999,
|
"long1", 999,
|
||||||
"double1", 1.5,
|
"double1", 1.5,
|
||||||
"short1", 32700);
|
"short1", 32700);
|
||||||
assert (aTuple2["string1"] == "1");
|
assert (aTuple2["string1"] == "1");
|
||||||
assert (aTuple2["int1"] == 1);
|
assert (aTuple2["int1"] == 1);
|
||||||
assert (aTuple2["bool1"] == true);
|
assert (aTuple2["bool1"] == true);
|
||||||
@@ -443,12 +443,12 @@ void NamedTuplesTest::testNamedTuple8()
|
|||||||
assert (aTuple2["short1"] == 32700);
|
assert (aTuple2["short1"] == 32700);
|
||||||
|
|
||||||
assert (aTuple != aTuple2);
|
assert (aTuple != aTuple2);
|
||||||
aTuple = aTuple2;
|
aTuple = aTuple2;
|
||||||
assert (aTuple == aTuple2);
|
assert (aTuple == aTuple2);
|
||||||
aTuple2.get<1>()++;
|
aTuple2.get<1>()++;
|
||||||
assert (aTuple < aTuple2);
|
assert (aTuple < aTuple2);
|
||||||
|
|
||||||
TupleType aTuple3(aTuple2.names());
|
TupleType aTuple3(aTuple2.names());
|
||||||
assert (aTuple3.names() == aTuple2.names());
|
assert (aTuple3.names() == aTuple2.names());
|
||||||
assert (aTuple3["string1"] == "");
|
assert (aTuple3["string1"] == "");
|
||||||
assert (aTuple3["int1"] == 0);
|
assert (aTuple3["int1"] == 0);
|
||||||
@@ -493,16 +493,16 @@ void NamedTuplesTest::testNamedTuple9()
|
|||||||
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
||||||
catch (NotFoundException&) { }
|
catch (NotFoundException&) { }
|
||||||
assert (aTuple.length == 9);
|
assert (aTuple.length == 9);
|
||||||
|
|
||||||
TupleType aTuple2("string1", "1",
|
TupleType aTuple2("string1", "1",
|
||||||
"int1", 1,
|
"int1", 1,
|
||||||
"bool1", true,
|
"bool1", true,
|
||||||
"float1", 1.5f,
|
"float1", 1.5f,
|
||||||
"char1", 'c',
|
"char1", 'c',
|
||||||
"long1", 999,
|
"long1", 999,
|
||||||
"double1", 1.5,
|
"double1", 1.5,
|
||||||
"short1", 32700,
|
"short1", 32700,
|
||||||
"string2", "2");
|
"string2", "2");
|
||||||
assert (aTuple2["string1"] == "1");
|
assert (aTuple2["string1"] == "1");
|
||||||
assert (aTuple2["int1"] == 1);
|
assert (aTuple2["int1"] == 1);
|
||||||
assert (aTuple2["bool1"] == true);
|
assert (aTuple2["bool1"] == true);
|
||||||
@@ -514,12 +514,12 @@ void NamedTuplesTest::testNamedTuple9()
|
|||||||
assert (aTuple2["string2"] == "2");
|
assert (aTuple2["string2"] == "2");
|
||||||
|
|
||||||
assert (aTuple != aTuple2);
|
assert (aTuple != aTuple2);
|
||||||
aTuple = aTuple2;
|
aTuple = aTuple2;
|
||||||
assert (aTuple == aTuple2);
|
assert (aTuple == aTuple2);
|
||||||
aTuple2.get<1>()++;
|
aTuple2.get<1>()++;
|
||||||
assert (aTuple < aTuple2);
|
assert (aTuple < aTuple2);
|
||||||
|
|
||||||
TupleType aTuple3(aTuple2.names());
|
TupleType aTuple3(aTuple2.names());
|
||||||
assert (aTuple3.names() == aTuple2.names());
|
assert (aTuple3.names() == aTuple2.names());
|
||||||
assert (aTuple3["string1"] == "");
|
assert (aTuple3["string1"] == "");
|
||||||
assert (aTuple3["int1"] == 0);
|
assert (aTuple3["int1"] == 0);
|
||||||
@@ -566,17 +566,17 @@ void NamedTuplesTest::testNamedTuple10()
|
|||||||
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
||||||
catch (NotFoundException&) { }
|
catch (NotFoundException&) { }
|
||||||
assert (aTuple.length == 10);
|
assert (aTuple.length == 10);
|
||||||
|
|
||||||
TupleType aTuple2("string1", "1",
|
TupleType aTuple2("string1", "1",
|
||||||
"int1", 1,
|
"int1", 1,
|
||||||
"bool1", true,
|
"bool1", true,
|
||||||
"float1", 1.5f,
|
"float1", 1.5f,
|
||||||
"char1", 'c',
|
"char1", 'c',
|
||||||
"long1", 999,
|
"long1", 999,
|
||||||
"double1", 1.5,
|
"double1", 1.5,
|
||||||
"short1", 32700,
|
"short1", 32700,
|
||||||
"string2", "2",
|
"string2", "2",
|
||||||
"int2", 2 );
|
"int2", 2 );
|
||||||
assert (aTuple2["string1"] == "1");
|
assert (aTuple2["string1"] == "1");
|
||||||
assert (aTuple2["int1"] == 1);
|
assert (aTuple2["int1"] == 1);
|
||||||
assert (aTuple2["bool1"] == true);
|
assert (aTuple2["bool1"] == true);
|
||||||
@@ -589,12 +589,12 @@ void NamedTuplesTest::testNamedTuple10()
|
|||||||
assert (aTuple2["int2"] == 2);
|
assert (aTuple2["int2"] == 2);
|
||||||
|
|
||||||
assert (aTuple != aTuple2);
|
assert (aTuple != aTuple2);
|
||||||
aTuple = aTuple2;
|
aTuple = aTuple2;
|
||||||
assert (aTuple == aTuple2);
|
assert (aTuple == aTuple2);
|
||||||
aTuple2.get<1>()++;
|
aTuple2.get<1>()++;
|
||||||
assert (aTuple < aTuple2);
|
assert (aTuple < aTuple2);
|
||||||
|
|
||||||
TupleType aTuple3(aTuple2.names());
|
TupleType aTuple3(aTuple2.names());
|
||||||
assert (aTuple3.names() == aTuple2.names());
|
assert (aTuple3.names() == aTuple2.names());
|
||||||
assert (aTuple3["string1"] == "");
|
assert (aTuple3["string1"] == "");
|
||||||
assert (aTuple3["int1"] == 0);
|
assert (aTuple3["int1"] == 0);
|
||||||
@@ -644,17 +644,17 @@ void NamedTuplesTest::testNamedTuple11()
|
|||||||
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
||||||
catch (NotFoundException&) { }
|
catch (NotFoundException&) { }
|
||||||
assert (aTuple.length == 11);
|
assert (aTuple.length == 11);
|
||||||
|
|
||||||
TupleType aTuple2("string1", "1",
|
TupleType aTuple2("string1", "1",
|
||||||
"int1", 1,
|
"int1", 1,
|
||||||
"bool1", true,
|
"bool1", true,
|
||||||
"float1", 1.5f,
|
"float1", 1.5f,
|
||||||
"char1", 'c',
|
"char1", 'c',
|
||||||
"long1", 999,
|
"long1", 999,
|
||||||
"double1", 1.5,
|
"double1", 1.5,
|
||||||
"short1", 32700,
|
"short1", 32700,
|
||||||
"string2", "2",
|
"string2", "2",
|
||||||
"int2", 2,
|
"int2", 2,
|
||||||
"string3", "3");
|
"string3", "3");
|
||||||
assert (aTuple2["string1"] == "1");
|
assert (aTuple2["string1"] == "1");
|
||||||
assert (aTuple2["int1"] == 1);
|
assert (aTuple2["int1"] == 1);
|
||||||
@@ -669,12 +669,12 @@ void NamedTuplesTest::testNamedTuple11()
|
|||||||
assert (aTuple2["string3"] == "3");
|
assert (aTuple2["string3"] == "3");
|
||||||
|
|
||||||
assert (aTuple != aTuple2);
|
assert (aTuple != aTuple2);
|
||||||
aTuple = aTuple2;
|
aTuple = aTuple2;
|
||||||
assert (aTuple == aTuple2);
|
assert (aTuple == aTuple2);
|
||||||
aTuple2.get<1>()++;
|
aTuple2.get<1>()++;
|
||||||
assert (aTuple < aTuple2);
|
assert (aTuple < aTuple2);
|
||||||
|
|
||||||
TupleType aTuple3(aTuple2.names());
|
TupleType aTuple3(aTuple2.names());
|
||||||
assert (aTuple3.names() == aTuple2.names());
|
assert (aTuple3.names() == aTuple2.names());
|
||||||
assert (aTuple3["string1"] == "");
|
assert (aTuple3["string1"] == "");
|
||||||
assert (aTuple3["int1"] == 0);
|
assert (aTuple3["int1"] == 0);
|
||||||
@@ -727,19 +727,19 @@ void NamedTuplesTest::testNamedTuple12()
|
|||||||
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
||||||
catch (NotFoundException&) { }
|
catch (NotFoundException&) { }
|
||||||
assert (aTuple.length == 12);
|
assert (aTuple.length == 12);
|
||||||
|
|
||||||
TupleType aTuple2("string1", "1",
|
TupleType aTuple2("string1", "1",
|
||||||
"int1", 1,
|
"int1", 1,
|
||||||
"bool1", true,
|
"bool1", true,
|
||||||
"float1", 1.5f,
|
"float1", 1.5f,
|
||||||
"char1", 'c',
|
"char1", 'c',
|
||||||
"long1", 999,
|
"long1", 999,
|
||||||
"double1", 1.5,
|
"double1", 1.5,
|
||||||
"short1", 32700,
|
"short1", 32700,
|
||||||
"string2", "2",
|
"string2", "2",
|
||||||
"int2", 2,
|
"int2", 2,
|
||||||
"string3", "3",
|
"string3", "3",
|
||||||
"int3", 3);
|
"int3", 3);
|
||||||
assert (aTuple2["string1"] == "1");
|
assert (aTuple2["string1"] == "1");
|
||||||
assert (aTuple2["int1"] == 1);
|
assert (aTuple2["int1"] == 1);
|
||||||
assert (aTuple2["bool1"] == true);
|
assert (aTuple2["bool1"] == true);
|
||||||
@@ -754,12 +754,12 @@ void NamedTuplesTest::testNamedTuple12()
|
|||||||
assert (aTuple2["int3"] == 3);
|
assert (aTuple2["int3"] == 3);
|
||||||
|
|
||||||
assert (aTuple != aTuple2);
|
assert (aTuple != aTuple2);
|
||||||
aTuple = aTuple2;
|
aTuple = aTuple2;
|
||||||
assert (aTuple == aTuple2);
|
assert (aTuple == aTuple2);
|
||||||
aTuple2.get<1>()++;
|
aTuple2.get<1>()++;
|
||||||
assert (aTuple < aTuple2);
|
assert (aTuple < aTuple2);
|
||||||
|
|
||||||
TupleType aTuple3(aTuple2.names());
|
TupleType aTuple3(aTuple2.names());
|
||||||
assert (aTuple3.names() == aTuple2.names());
|
assert (aTuple3.names() == aTuple2.names());
|
||||||
assert (aTuple3["string1"] == "");
|
assert (aTuple3["string1"] == "");
|
||||||
assert (aTuple3["int1"] == 0);
|
assert (aTuple3["int1"] == 0);
|
||||||
@@ -814,20 +814,20 @@ void NamedTuplesTest::testNamedTuple13()
|
|||||||
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
||||||
catch (NotFoundException&) { }
|
catch (NotFoundException&) { }
|
||||||
assert (aTuple.length == 13);
|
assert (aTuple.length == 13);
|
||||||
|
|
||||||
TupleType aTuple2("string1", "1",
|
TupleType aTuple2("string1", "1",
|
||||||
"int1", 1,
|
"int1", 1,
|
||||||
"bool1", true,
|
"bool1", true,
|
||||||
"float1", 1.5f,
|
"float1", 1.5f,
|
||||||
"char1", 'c',
|
"char1", 'c',
|
||||||
"long1", 999,
|
"long1", 999,
|
||||||
"double1", 1.5,
|
"double1", 1.5,
|
||||||
"short1", 32700,
|
"short1", 32700,
|
||||||
"string2", "2",
|
"string2", "2",
|
||||||
"int2", 2,
|
"int2", 2,
|
||||||
"string3", "3",
|
"string3", "3",
|
||||||
"int3", 3,
|
"int3", 3,
|
||||||
"bool2", true);
|
"bool2", true);
|
||||||
assert (aTuple2["string1"] == "1");
|
assert (aTuple2["string1"] == "1");
|
||||||
assert (aTuple2["int1"] == 1);
|
assert (aTuple2["int1"] == 1);
|
||||||
assert (aTuple2["bool1"] == true);
|
assert (aTuple2["bool1"] == true);
|
||||||
@@ -843,12 +843,12 @@ void NamedTuplesTest::testNamedTuple13()
|
|||||||
assert (aTuple2["bool2"] == true);
|
assert (aTuple2["bool2"] == true);
|
||||||
|
|
||||||
assert (aTuple != aTuple2);
|
assert (aTuple != aTuple2);
|
||||||
aTuple = aTuple2;
|
aTuple = aTuple2;
|
||||||
assert (aTuple == aTuple2);
|
assert (aTuple == aTuple2);
|
||||||
aTuple2.get<1>()++;
|
aTuple2.get<1>()++;
|
||||||
assert (aTuple < aTuple2);
|
assert (aTuple < aTuple2);
|
||||||
|
|
||||||
TupleType aTuple3(aTuple2.names());
|
TupleType aTuple3(aTuple2.names());
|
||||||
assert (aTuple3.names() == aTuple2.names());
|
assert (aTuple3.names() == aTuple2.names());
|
||||||
assert (aTuple3["string1"] == "");
|
assert (aTuple3["string1"] == "");
|
||||||
assert (aTuple3["int1"] == 0);
|
assert (aTuple3["int1"] == 0);
|
||||||
@@ -904,21 +904,21 @@ void NamedTuplesTest::testNamedTuple14()
|
|||||||
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
||||||
catch (NotFoundException&) { }
|
catch (NotFoundException&) { }
|
||||||
assert (aTuple.length == 14);
|
assert (aTuple.length == 14);
|
||||||
|
|
||||||
TupleType aTuple2("string1", "1",
|
TupleType aTuple2("string1", "1",
|
||||||
"int1", 1,
|
"int1", 1,
|
||||||
"bool1", true,
|
"bool1", true,
|
||||||
"float1", 1.5f,
|
"float1", 1.5f,
|
||||||
"char1", 'c',
|
"char1", 'c',
|
||||||
"long1", 999,
|
"long1", 999,
|
||||||
"double1", 1.5,
|
"double1", 1.5,
|
||||||
"short1", 32700,
|
"short1", 32700,
|
||||||
"string2", "2",
|
"string2", "2",
|
||||||
"int2", 2,
|
"int2", 2,
|
||||||
"string3", "3",
|
"string3", "3",
|
||||||
"int3", 3,
|
"int3", 3,
|
||||||
"bool2", true,
|
"bool2", true,
|
||||||
"float2", 2.5);
|
"float2", 2.5);
|
||||||
assert (aTuple2["string1"] == "1");
|
assert (aTuple2["string1"] == "1");
|
||||||
assert (aTuple2["int1"] == 1);
|
assert (aTuple2["int1"] == 1);
|
||||||
assert (aTuple2["bool1"] == true);
|
assert (aTuple2["bool1"] == true);
|
||||||
@@ -935,12 +935,12 @@ void NamedTuplesTest::testNamedTuple14()
|
|||||||
assert (aTuple2["float2"] == 2.5);
|
assert (aTuple2["float2"] == 2.5);
|
||||||
|
|
||||||
assert (aTuple != aTuple2);
|
assert (aTuple != aTuple2);
|
||||||
aTuple = aTuple2;
|
aTuple = aTuple2;
|
||||||
assert (aTuple == aTuple2);
|
assert (aTuple == aTuple2);
|
||||||
aTuple2.get<1>()++;
|
aTuple2.get<1>()++;
|
||||||
assert (aTuple < aTuple2);
|
assert (aTuple < aTuple2);
|
||||||
|
|
||||||
TupleType aTuple3(aTuple2.names());
|
TupleType aTuple3(aTuple2.names());
|
||||||
assert (aTuple3.names() == aTuple2.names());
|
assert (aTuple3.names() == aTuple2.names());
|
||||||
assert (aTuple3["string1"] == "");
|
assert (aTuple3["string1"] == "");
|
||||||
assert (aTuple3["int1"] == 0);
|
assert (aTuple3["int1"] == 0);
|
||||||
@@ -998,22 +998,22 @@ void NamedTuplesTest::testNamedTuple15()
|
|||||||
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
||||||
catch (NotFoundException&) { }
|
catch (NotFoundException&) { }
|
||||||
assert (aTuple.length == 15);
|
assert (aTuple.length == 15);
|
||||||
|
|
||||||
TupleType aTuple2("string1", "1",
|
TupleType aTuple2("string1", "1",
|
||||||
"int1", 1,
|
"int1", 1,
|
||||||
"bool1", true,
|
"bool1", true,
|
||||||
"float1", 1.5f,
|
"float1", 1.5f,
|
||||||
"char1", 'c',
|
"char1", 'c',
|
||||||
"long1", 999,
|
"long1", 999,
|
||||||
"double1", 1.5,
|
"double1", 1.5,
|
||||||
"short1", 32700,
|
"short1", 32700,
|
||||||
"string2", "2",
|
"string2", "2",
|
||||||
"int2", 2,
|
"int2", 2,
|
||||||
"string3", "3",
|
"string3", "3",
|
||||||
"int3", 3,
|
"int3", 3,
|
||||||
"bool2", true,
|
"bool2", true,
|
||||||
"float2", 2.5,
|
"float2", 2.5,
|
||||||
"char2", 'c');
|
"char2", 'c');
|
||||||
assert (aTuple2["string1"] == "1");
|
assert (aTuple2["string1"] == "1");
|
||||||
assert (aTuple2["int1"] == 1);
|
assert (aTuple2["int1"] == 1);
|
||||||
assert (aTuple2["bool1"] == true);
|
assert (aTuple2["bool1"] == true);
|
||||||
@@ -1031,12 +1031,12 @@ void NamedTuplesTest::testNamedTuple15()
|
|||||||
assert (aTuple2["char2"] == 'c');
|
assert (aTuple2["char2"] == 'c');
|
||||||
|
|
||||||
assert (aTuple != aTuple2);
|
assert (aTuple != aTuple2);
|
||||||
aTuple = aTuple2;
|
aTuple = aTuple2;
|
||||||
assert (aTuple == aTuple2);
|
assert (aTuple == aTuple2);
|
||||||
aTuple2.get<1>()++;
|
aTuple2.get<1>()++;
|
||||||
assert (aTuple < aTuple2);
|
assert (aTuple < aTuple2);
|
||||||
|
|
||||||
TupleType aTuple3(aTuple2.names());
|
TupleType aTuple3(aTuple2.names());
|
||||||
assert (aTuple3.names() == aTuple2.names());
|
assert (aTuple3.names() == aTuple2.names());
|
||||||
assert (aTuple3["string1"] == "");
|
assert (aTuple3["string1"] == "");
|
||||||
assert (aTuple3["int1"] == 0);
|
assert (aTuple3["int1"] == 0);
|
||||||
@@ -1097,23 +1097,23 @@ void NamedTuplesTest::testNamedTuple16()
|
|||||||
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
||||||
catch (NotFoundException&) { }
|
catch (NotFoundException&) { }
|
||||||
assert (aTuple.length == 16);
|
assert (aTuple.length == 16);
|
||||||
|
|
||||||
TupleType aTuple2("string1", "1",
|
TupleType aTuple2("string1", "1",
|
||||||
"int1", 1,
|
"int1", 1,
|
||||||
"bool1", true,
|
"bool1", true,
|
||||||
"float1", 1.5f,
|
"float1", 1.5f,
|
||||||
"char1", 'c',
|
"char1", 'c',
|
||||||
"long1", 999,
|
"long1", 999,
|
||||||
"double1", 1.5,
|
"double1", 1.5,
|
||||||
"short1", 32700,
|
"short1", 32700,
|
||||||
"string2", "2",
|
"string2", "2",
|
||||||
"int2", 2,
|
"int2", 2,
|
||||||
"string3", "3",
|
"string3", "3",
|
||||||
"int3", 3,
|
"int3", 3,
|
||||||
"bool2", true,
|
"bool2", true,
|
||||||
"float2", 2.5,
|
"float2", 2.5,
|
||||||
"char2", 'c',
|
"char2", 'c',
|
||||||
"long2", 999);
|
"long2", 999);
|
||||||
assert (aTuple2["string1"] == "1");
|
assert (aTuple2["string1"] == "1");
|
||||||
assert (aTuple2["int1"] == 1);
|
assert (aTuple2["int1"] == 1);
|
||||||
assert (aTuple2["bool1"] == true);
|
assert (aTuple2["bool1"] == true);
|
||||||
@@ -1133,12 +1133,12 @@ void NamedTuplesTest::testNamedTuple16()
|
|||||||
assert (aTuple2.length == 16);
|
assert (aTuple2.length == 16);
|
||||||
|
|
||||||
assert (aTuple != aTuple2);
|
assert (aTuple != aTuple2);
|
||||||
aTuple = aTuple2;
|
aTuple = aTuple2;
|
||||||
assert (aTuple == aTuple2);
|
assert (aTuple == aTuple2);
|
||||||
aTuple2.get<1>()++;
|
aTuple2.get<1>()++;
|
||||||
assert (aTuple < aTuple2);
|
assert (aTuple < aTuple2);
|
||||||
|
|
||||||
TupleType aTuple3(aTuple2.names());
|
TupleType aTuple3(aTuple2.names());
|
||||||
assert (aTuple3.names() == aTuple2.names());
|
assert (aTuple3.names() == aTuple2.names());
|
||||||
assert (aTuple3["string1"] == "");
|
assert (aTuple3["string1"] == "");
|
||||||
assert (aTuple3["int1"] == 0);
|
assert (aTuple3["int1"] == 0);
|
||||||
@@ -1202,24 +1202,24 @@ void NamedTuplesTest::testNamedTuple17()
|
|||||||
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
||||||
catch (NotFoundException&) { }
|
catch (NotFoundException&) { }
|
||||||
assert (aTuple.length == 17);
|
assert (aTuple.length == 17);
|
||||||
|
|
||||||
TupleType aTuple2("string1", "1",
|
TupleType aTuple2("string1", "1",
|
||||||
"int1", 1,
|
"int1", 1,
|
||||||
"bool1", true,
|
"bool1", true,
|
||||||
"float1", 1.5f,
|
"float1", 1.5f,
|
||||||
"char1", 'c',
|
"char1", 'c',
|
||||||
"long1", 999,
|
"long1", 999,
|
||||||
"double1", 1.5,
|
"double1", 1.5,
|
||||||
"short1", 32700,
|
"short1", 32700,
|
||||||
"string2", "2",
|
"string2", "2",
|
||||||
"int2", 2,
|
"int2", 2,
|
||||||
"string3", "3",
|
"string3", "3",
|
||||||
"int3", 3,
|
"int3", 3,
|
||||||
"bool2", true,
|
"bool2", true,
|
||||||
"float2", 2.5,
|
"float2", 2.5,
|
||||||
"char2", 'c',
|
"char2", 'c',
|
||||||
"long2", 999,
|
"long2", 999,
|
||||||
"double2", 2.5);
|
"double2", 2.5);
|
||||||
assert (aTuple2["string1"] == "1");
|
assert (aTuple2["string1"] == "1");
|
||||||
assert (aTuple2["int1"] == 1);
|
assert (aTuple2["int1"] == 1);
|
||||||
assert (aTuple2["bool1"] == true);
|
assert (aTuple2["bool1"] == true);
|
||||||
@@ -1240,12 +1240,12 @@ void NamedTuplesTest::testNamedTuple17()
|
|||||||
assert (aTuple2.length == 17);
|
assert (aTuple2.length == 17);
|
||||||
|
|
||||||
assert (aTuple != aTuple2);
|
assert (aTuple != aTuple2);
|
||||||
aTuple = aTuple2;
|
aTuple = aTuple2;
|
||||||
assert (aTuple == aTuple2);
|
assert (aTuple == aTuple2);
|
||||||
aTuple2.get<1>()++;
|
aTuple2.get<1>()++;
|
||||||
assert (aTuple < aTuple2);
|
assert (aTuple < aTuple2);
|
||||||
|
|
||||||
TupleType aTuple3(aTuple2.names());
|
TupleType aTuple3(aTuple2.names());
|
||||||
assert (aTuple3.names() == aTuple2.names());
|
assert (aTuple3.names() == aTuple2.names());
|
||||||
assert (aTuple3["string1"] == "");
|
assert (aTuple3["string1"] == "");
|
||||||
assert (aTuple3["int1"] == 0);
|
assert (aTuple3["int1"] == 0);
|
||||||
@@ -1312,25 +1312,25 @@ void NamedTuplesTest::testNamedTuple18()
|
|||||||
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
||||||
catch (NotFoundException&) { }
|
catch (NotFoundException&) { }
|
||||||
assert (aTuple.length == 18);
|
assert (aTuple.length == 18);
|
||||||
|
|
||||||
TupleType aTuple2("string1", "1",
|
TupleType aTuple2("string1", "1",
|
||||||
"int1", 1,
|
"int1", 1,
|
||||||
"bool1", true,
|
"bool1", true,
|
||||||
"float1", 1.5f,
|
"float1", 1.5f,
|
||||||
"char1", 'c',
|
"char1", 'c',
|
||||||
"long1", 999,
|
"long1", 999,
|
||||||
"double1", 1.5,
|
"double1", 1.5,
|
||||||
"short1", 32700,
|
"short1", 32700,
|
||||||
"string2", "2",
|
"string2", "2",
|
||||||
"int2", 2,
|
"int2", 2,
|
||||||
"string3", "3",
|
"string3", "3",
|
||||||
"int3", 3,
|
"int3", 3,
|
||||||
"bool2", true,
|
"bool2", true,
|
||||||
"float2", 2.5,
|
"float2", 2.5,
|
||||||
"char2", 'c',
|
"char2", 'c',
|
||||||
"long2", 999,
|
"long2", 999,
|
||||||
"double2", 2.5,
|
"double2", 2.5,
|
||||||
"short2", 32700);
|
"short2", 32700);
|
||||||
assert (aTuple2["string1"] == "1");
|
assert (aTuple2["string1"] == "1");
|
||||||
assert (aTuple2["int1"] == 1);
|
assert (aTuple2["int1"] == 1);
|
||||||
assert (aTuple2["bool1"] == true);
|
assert (aTuple2["bool1"] == true);
|
||||||
@@ -1352,12 +1352,12 @@ void NamedTuplesTest::testNamedTuple18()
|
|||||||
assert (aTuple2.length == 18);
|
assert (aTuple2.length == 18);
|
||||||
|
|
||||||
assert (aTuple != aTuple2);
|
assert (aTuple != aTuple2);
|
||||||
aTuple = aTuple2;
|
aTuple = aTuple2;
|
||||||
assert (aTuple == aTuple2);
|
assert (aTuple == aTuple2);
|
||||||
aTuple2.get<1>()++;
|
aTuple2.get<1>()++;
|
||||||
assert (aTuple < aTuple2);
|
assert (aTuple < aTuple2);
|
||||||
|
|
||||||
TupleType aTuple3(aTuple2.names());
|
TupleType aTuple3(aTuple2.names());
|
||||||
assert (aTuple3.names() == aTuple2.names());
|
assert (aTuple3.names() == aTuple2.names());
|
||||||
assert (aTuple3["string1"] == "");
|
assert (aTuple3["string1"] == "");
|
||||||
assert (aTuple3["int1"] == 0);
|
assert (aTuple3["int1"] == 0);
|
||||||
@@ -1427,26 +1427,26 @@ void NamedTuplesTest::testNamedTuple19()
|
|||||||
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
||||||
catch (NotFoundException&) { }
|
catch (NotFoundException&) { }
|
||||||
assert (aTuple.length == 19);
|
assert (aTuple.length == 19);
|
||||||
|
|
||||||
TupleType aTuple2("string1", "1",
|
TupleType aTuple2("string1", "1",
|
||||||
"int1", 1,
|
"int1", 1,
|
||||||
"bool1", true,
|
"bool1", true,
|
||||||
"float1", 1.5f,
|
"float1", 1.5f,
|
||||||
"char1", 'c',
|
"char1", 'c',
|
||||||
"long1", 999,
|
"long1", 999,
|
||||||
"double1", 1.5,
|
"double1", 1.5,
|
||||||
"short1", 32700,
|
"short1", 32700,
|
||||||
"string2", "2",
|
"string2", "2",
|
||||||
"int2", 2,
|
"int2", 2,
|
||||||
"string3", "3",
|
"string3", "3",
|
||||||
"int3", 3,
|
"int3", 3,
|
||||||
"bool2", true,
|
"bool2", true,
|
||||||
"float2", 2.5,
|
"float2", 2.5,
|
||||||
"char2", 'c',
|
"char2", 'c',
|
||||||
"long2", 999,
|
"long2", 999,
|
||||||
"double2", 2.5,
|
"double2", 2.5,
|
||||||
"short2", 32700,
|
"short2", 32700,
|
||||||
"string4", "4");
|
"string4", "4");
|
||||||
assert (aTuple2["string1"] == "1");
|
assert (aTuple2["string1"] == "1");
|
||||||
assert (aTuple2["int1"] == 1);
|
assert (aTuple2["int1"] == 1);
|
||||||
assert (aTuple2["bool1"] == true);
|
assert (aTuple2["bool1"] == true);
|
||||||
@@ -1469,12 +1469,12 @@ void NamedTuplesTest::testNamedTuple19()
|
|||||||
assert (aTuple2.length == 19);
|
assert (aTuple2.length == 19);
|
||||||
|
|
||||||
assert (aTuple != aTuple2);
|
assert (aTuple != aTuple2);
|
||||||
aTuple = aTuple2;
|
aTuple = aTuple2;
|
||||||
assert (aTuple == aTuple2);
|
assert (aTuple == aTuple2);
|
||||||
aTuple2.get<1>()++;
|
aTuple2.get<1>()++;
|
||||||
assert (aTuple < aTuple2);
|
assert (aTuple < aTuple2);
|
||||||
|
|
||||||
TupleType aTuple3(aTuple2.names());
|
TupleType aTuple3(aTuple2.names());
|
||||||
assert (aTuple3.names() == aTuple2.names());
|
assert (aTuple3.names() == aTuple2.names());
|
||||||
assert (aTuple3["string1"] == "");
|
assert (aTuple3["string1"] == "");
|
||||||
assert (aTuple3["int1"] == 0);
|
assert (aTuple3["int1"] == 0);
|
||||||
@@ -1546,27 +1546,27 @@ void NamedTuplesTest::testNamedTuple20()
|
|||||||
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
try { int xyz; xyz = aTuple["XYZ"]; fail ("must fail"); }
|
||||||
catch (NotFoundException&) { }
|
catch (NotFoundException&) { }
|
||||||
assert (aTuple.length == 20);
|
assert (aTuple.length == 20);
|
||||||
|
|
||||||
TupleType aTuple2("string1", "1",
|
TupleType aTuple2("string1", "1",
|
||||||
"int1", 1,
|
"int1", 1,
|
||||||
"bool1", true,
|
"bool1", true,
|
||||||
"float1", 1.5f,
|
"float1", 1.5f,
|
||||||
"char1", 'c',
|
"char1", 'c',
|
||||||
"long1", 999,
|
"long1", 999,
|
||||||
"double1", 1.5,
|
"double1", 1.5,
|
||||||
"short1", 32700,
|
"short1", 32700,
|
||||||
"string2", "2",
|
"string2", "2",
|
||||||
"int2", 2,
|
"int2", 2,
|
||||||
"string3", "3",
|
"string3", "3",
|
||||||
"int3", 3,
|
"int3", 3,
|
||||||
"bool2", true,
|
"bool2", true,
|
||||||
"float2", 2.5,
|
"float2", 2.5,
|
||||||
"char2", 'c',
|
"char2", 'c',
|
||||||
"long2", 999,
|
"long2", 999,
|
||||||
"double2", 2.5,
|
"double2", 2.5,
|
||||||
"short2", 32700,
|
"short2", 32700,
|
||||||
"string4", "4",
|
"string4", "4",
|
||||||
"int4", 4);
|
"int4", 4);
|
||||||
assert (aTuple2["string1"] == "1");
|
assert (aTuple2["string1"] == "1");
|
||||||
assert (aTuple2["int1"] == 1);
|
assert (aTuple2["int1"] == 1);
|
||||||
assert (aTuple2["bool1"] == true);
|
assert (aTuple2["bool1"] == true);
|
||||||
@@ -1590,12 +1590,12 @@ void NamedTuplesTest::testNamedTuple20()
|
|||||||
assert (aTuple2.length == 20);
|
assert (aTuple2.length == 20);
|
||||||
|
|
||||||
assert (aTuple != aTuple2);
|
assert (aTuple != aTuple2);
|
||||||
aTuple = aTuple2;
|
aTuple = aTuple2;
|
||||||
assert (aTuple == aTuple2);
|
assert (aTuple == aTuple2);
|
||||||
aTuple2.get<1>()++;
|
aTuple2.get<1>()++;
|
||||||
assert (aTuple < aTuple2);
|
assert (aTuple < aTuple2);
|
||||||
|
|
||||||
TupleType aTuple3(aTuple2.names());
|
TupleType aTuple3(aTuple2.names());
|
||||||
assert (aTuple3.names() == aTuple2.names());
|
assert (aTuple3.names() == aTuple2.names());
|
||||||
assert (aTuple3["string1"] == "");
|
assert (aTuple3["string1"] == "");
|
||||||
assert (aTuple3["int1"] == 0);
|
assert (aTuple3["int1"] == 0);
|
||||||
|
@@ -740,30 +740,30 @@ void URITest::testSwap()
|
|||||||
|
|
||||||
void URITest::testOther()
|
void URITest::testOther()
|
||||||
{
|
{
|
||||||
// The search string is "hello%world"; google happens to ignore the '%'
|
// The search string is "hello%world"; google happens to ignore the '%'
|
||||||
// character, so it finds lots of hits for "hello world" programs. This is
|
// character, so it finds lots of hits for "hello world" programs. This is
|
||||||
// a convenient reproduction case, and a URL that actually works.
|
// a convenient reproduction case, and a URL that actually works.
|
||||||
Poco::URI uri("http://google.com/search?q=hello%25world#frag%20ment");
|
Poco::URI uri("http://google.com/search?q=hello%25world#frag%20ment");
|
||||||
|
|
||||||
assert(uri.getHost() == "google.com");
|
assert(uri.getHost() == "google.com");
|
||||||
assert(uri.getPath() == "/search");
|
assert(uri.getPath() == "/search");
|
||||||
assert(uri.getQuery() == "q=hello%world");
|
assert(uri.getQuery() == "q=hello%world");
|
||||||
assert(uri.getRawQuery() == "q=hello%25world");
|
assert(uri.getRawQuery() == "q=hello%25world");
|
||||||
assert(uri.getFragment() == "frag ment");
|
assert(uri.getFragment() == "frag ment");
|
||||||
assert(uri.toString() == "http://google.com/search?q=hello%25world#frag%20ment");
|
assert(uri.toString() == "http://google.com/search?q=hello%25world#frag%20ment");
|
||||||
assert(uri.getPathEtc() == "/search?q=hello%25world#frag%20ment");
|
assert(uri.getPathEtc() == "/search?q=hello%25world#frag%20ment");
|
||||||
|
|
||||||
uri.setQuery("q=goodbye cruel world");
|
uri.setQuery("q=goodbye cruel world");
|
||||||
assert(uri.getQuery() == "q=goodbye cruel world");
|
assert(uri.getQuery() == "q=goodbye cruel world");
|
||||||
assert(uri.getRawQuery() == "q=goodbye%20cruel%20world");
|
assert(uri.getRawQuery() == "q=goodbye%20cruel%20world");
|
||||||
assert(uri.toString() == "http://google.com/search?q=goodbye%20cruel%20world#frag%20ment");
|
assert(uri.toString() == "http://google.com/search?q=goodbye%20cruel%20world#frag%20ment");
|
||||||
assert(uri.getPathEtc() == "/search?q=goodbye%20cruel%20world#frag%20ment");
|
assert(uri.getPathEtc() == "/search?q=goodbye%20cruel%20world#frag%20ment");
|
||||||
|
|
||||||
uri.setRawQuery("q=pony%7eride");
|
uri.setRawQuery("q=pony%7eride");
|
||||||
assert(uri.getQuery() == "q=pony~ride");
|
assert(uri.getQuery() == "q=pony~ride");
|
||||||
assert(uri.getRawQuery() == "q=pony%7eride");
|
assert(uri.getRawQuery() == "q=pony%7eride");
|
||||||
assert(uri.toString() == "http://google.com/search?q=pony%7eride#frag%20ment");
|
assert(uri.toString() == "http://google.com/search?q=pony%7eride#frag%20ment");
|
||||||
assert(uri.getPathEtc() == "/search?q=pony%7eride#frag%20ment");
|
assert(uri.getPathEtc() == "/search?q=pony%7eride#frag%20ment");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,3 +0,0 @@
|
|||||||
0123456789
|
|
||||||
abcdefghij
|
|
||||||
klmnopqrst
|
|
Reference in New Issue
Block a user