mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-08-28 10:47:10 +02:00
Update POCO to 1.11.0
This commit is contained in:
28
vendor/POCO/Foundation/testsuite/src/AnyTest.cpp
vendored
28
vendor/POCO/Foundation/testsuite/src/AnyTest.cpp
vendored
@@ -53,7 +53,7 @@ AnyTest::~AnyTest()
|
||||
void AnyTest::testDefaultCtor()
|
||||
{
|
||||
const Any value;
|
||||
|
||||
|
||||
assertTrue (value.empty());
|
||||
assertTrue (0 == AnyCast<int>(&value));
|
||||
assertTrue (value.type() == typeid(void));
|
||||
@@ -64,7 +64,7 @@ void AnyTest::testConvertingCtor()
|
||||
{
|
||||
std::string text = "test message";
|
||||
Any value = text;
|
||||
|
||||
|
||||
assertTrue (!value.empty());
|
||||
assertTrue (value.type() == typeid(std::string));
|
||||
assertTrue (0 == AnyCast<int>(&value));
|
||||
@@ -78,7 +78,7 @@ void AnyTest::testCopyCtor()
|
||||
{
|
||||
std::string text = "test message";
|
||||
Any original = text, copy = original;
|
||||
|
||||
|
||||
assertTrue (!copy.empty());
|
||||
assertTrue (original.type() == copy.type());
|
||||
assertTrue (AnyCast<std::string>(original) == AnyCast<std::string>(copy));
|
||||
@@ -92,7 +92,7 @@ void AnyTest::testCopyAssign()
|
||||
std::string text = "test message";
|
||||
Any original = text, copy;
|
||||
Any* assignResult = &(copy = original);
|
||||
|
||||
|
||||
assertTrue (!copy.empty());
|
||||
assertTrue (original.type() == copy.type());
|
||||
assertTrue (AnyCast<std::string>(original) == AnyCast<std::string>(copy));
|
||||
@@ -114,7 +114,7 @@ void AnyTest::testConvertingAssign()
|
||||
std::string text = "test message";
|
||||
Any value;
|
||||
Any* assignResult = &(value = text);
|
||||
|
||||
|
||||
assertTrue (!value.empty());
|
||||
assertTrue (value.type() == typeid(std::string));
|
||||
assertTrue (0 == AnyCast<int>(&value));
|
||||
@@ -129,21 +129,23 @@ void AnyTest::testCastToReference()
|
||||
{
|
||||
Any a(137);
|
||||
const Any b(a);
|
||||
|
||||
|
||||
int& ra = AnyCast<int &>(a);
|
||||
int const& ra_c = AnyCast<int const &>(a);
|
||||
// NOTE: The following two AnyCasts will trigger the
|
||||
// undefined behavior sanitizer.
|
||||
int volatile& ra_v = AnyCast<int volatile &>(a);
|
||||
int const volatile& ra_cv = AnyCast<int const volatile&>(a);
|
||||
|
||||
|
||||
// cv references to same obj
|
||||
assertTrue (&ra == &ra_c && &ra == &ra_v && &ra == &ra_cv);
|
||||
|
||||
|
||||
int const & rb_c = AnyCast<int const &>(b);
|
||||
int const volatile & rb_cv = AnyCast<int const volatile &>(b);
|
||||
|
||||
assertTrue (&rb_c == &rb_cv); // cv references to copied const obj
|
||||
assertTrue (&ra != &rb_c); // copies hold different objects
|
||||
|
||||
|
||||
++ra;
|
||||
int incremented = AnyCast<int>(a);
|
||||
assertTrue (incremented == 138); // increment by reference changes value
|
||||
@@ -168,7 +170,7 @@ void AnyTest::testBadCast()
|
||||
{
|
||||
std::string text = "test message";
|
||||
Any value = text;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
AnyCast<const char *>(value);
|
||||
@@ -184,7 +186,7 @@ void AnyTest::testSwap()
|
||||
Any original = text, swapped;
|
||||
std::string* originalPtr = AnyCast<std::string>(&original);
|
||||
Any* swapResult = &original.swap(swapped);
|
||||
|
||||
|
||||
assertTrue (original.empty());
|
||||
assertTrue (!swapped.empty());
|
||||
assertTrue (swapped.type() == typeid(std::string));
|
||||
@@ -202,7 +204,7 @@ void AnyTest::testEmptyCopy()
|
||||
const Any null;
|
||||
Any copied = null, assigned;
|
||||
assigned = null;
|
||||
|
||||
|
||||
assertTrue (null.empty());
|
||||
assertTrue (copied.empty());
|
||||
assertTrue (assigned.empty());
|
||||
@@ -261,7 +263,7 @@ void AnyTest::testVector()
|
||||
assertTrue (tmp2.size() == 3);
|
||||
const std::vector<int>& vecCRef = RefAnyCast<std::vector<int> >(a);
|
||||
std::vector<int>& vecRef = RefAnyCast<std::vector<int> >(a);
|
||||
|
||||
|
||||
assertTrue (vecRef[0] == 1);
|
||||
assertTrue (vecRef[1] == 2);
|
||||
assertTrue (vecRef[2] == 3);
|
||||
|
@@ -34,6 +34,7 @@ BasicEventTest::~BasicEventTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void BasicEventTest::testNoDelegate()
|
||||
{
|
||||
int tmp = 0;
|
||||
@@ -66,12 +67,12 @@ void BasicEventTest::testNoDelegate()
|
||||
Simple -= delegate(this, &BasicEventTest::onSimpleNoSender);
|
||||
Simple.notify(this, tmp);
|
||||
assertTrue (_count == 0);
|
||||
|
||||
|
||||
ConstSimple += delegate(this, &BasicEventTest::onConstSimple);
|
||||
ConstSimple -= delegate(this, &BasicEventTest::onConstSimple);
|
||||
ConstSimple.notify(this, tmp);
|
||||
assertTrue (_count == 0);
|
||||
|
||||
|
||||
//Note: passing &args will not work due to &
|
||||
EventArgs* pArgs = &args;
|
||||
Complex += delegate(this, &BasicEventTest::onComplex);
|
||||
@@ -99,7 +100,7 @@ void BasicEventTest::testNoDelegate()
|
||||
Simple += delegate(&BasicEventTest::onStaticSimple);
|
||||
Simple += delegate(&BasicEventTest::onStaticSimple2);
|
||||
Simple += delegate(&BasicEventTest::onStaticSimple3);
|
||||
|
||||
|
||||
Simple.notify(this, tmp);
|
||||
assertTrue (_count == 3);
|
||||
Simple -= delegate(BasicEventTest::onStaticSimple);
|
||||
@@ -112,6 +113,7 @@ void BasicEventTest::testNoDelegate()
|
||||
Void -= delegate(BasicEventTest::onStaticVoid);
|
||||
}
|
||||
|
||||
|
||||
void BasicEventTest::testSingleDelegate()
|
||||
{
|
||||
int tmp = 0;
|
||||
@@ -126,11 +128,11 @@ void BasicEventTest::testSingleDelegate()
|
||||
Simple += delegate(this, &BasicEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
assertTrue (_count == 2);
|
||||
|
||||
|
||||
ConstSimple += delegate(this, &BasicEventTest::onConstSimple);
|
||||
ConstSimple.notify(this, tmp);
|
||||
assertTrue (_count == 3);
|
||||
|
||||
|
||||
EventArgs* pArgs = &args;
|
||||
Complex += delegate(this, &BasicEventTest::onComplex);
|
||||
Complex.notify(this, pArgs);
|
||||
@@ -151,13 +153,13 @@ void BasicEventTest::testSingleDelegate()
|
||||
// check if 2nd notify also works
|
||||
Const2Complex.notify(this, pArgs);
|
||||
assertTrue (_count == 8);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void BasicEventTest::testDuplicateRegister()
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
|
||||
assertTrue (_count == 0);
|
||||
|
||||
Simple += delegate(this, &BasicEventTest::onSimple);
|
||||
@@ -174,7 +176,7 @@ void BasicEventTest::testNullMutex()
|
||||
{
|
||||
Poco::BasicEvent<int, NullMutex> ev;
|
||||
int tmp = 0;
|
||||
|
||||
|
||||
assertTrue (_count == 0);
|
||||
|
||||
ev += delegate(this, &BasicEventTest::onSimple);
|
||||
@@ -191,7 +193,7 @@ void BasicEventTest::testDuplicateUnregister()
|
||||
{
|
||||
// duplicate unregister shouldn't give an error,
|
||||
int tmp = 0;
|
||||
|
||||
|
||||
assertTrue (_count == 0);
|
||||
|
||||
Simple -= delegate(this, &BasicEventTest::onSimple); // should work
|
||||
@@ -211,10 +213,11 @@ void BasicEventTest::testDuplicateUnregister()
|
||||
assertTrue (_count == 1);
|
||||
}
|
||||
|
||||
|
||||
void BasicEventTest::testDisabling()
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
|
||||
assertTrue (_count == 0);
|
||||
|
||||
Simple += delegate(this, &BasicEventTest::onSimple);
|
||||
@@ -233,10 +236,11 @@ void BasicEventTest::testDisabling()
|
||||
assertTrue (_count == 1);
|
||||
}
|
||||
|
||||
|
||||
void BasicEventTest::testExpire()
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
|
||||
assertTrue (_count == 0);
|
||||
|
||||
Simple += delegate(this, &BasicEventTest::onSimple, 500);
|
||||
@@ -257,10 +261,11 @@ void BasicEventTest::testExpire()
|
||||
assertTrue (_count == 4);
|
||||
}
|
||||
|
||||
|
||||
void BasicEventTest::testExpireReRegister()
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
|
||||
assertTrue (_count == 0);
|
||||
|
||||
Simple += delegate(this, &BasicEventTest::onSimple, 500);
|
||||
@@ -279,6 +284,7 @@ void BasicEventTest::testExpireReRegister()
|
||||
assertTrue (_count == 3);
|
||||
}
|
||||
|
||||
|
||||
void BasicEventTest::testReturnParams()
|
||||
{
|
||||
DummyDelegate o1;
|
||||
@@ -289,6 +295,7 @@ void BasicEventTest::testReturnParams()
|
||||
assertTrue (tmp == 1);
|
||||
}
|
||||
|
||||
|
||||
void BasicEventTest::testOverwriteDelegate()
|
||||
{
|
||||
DummyDelegate o1;
|
||||
@@ -300,32 +307,34 @@ void BasicEventTest::testOverwriteDelegate()
|
||||
assertTrue (tmp == 2);
|
||||
}
|
||||
|
||||
|
||||
void BasicEventTest::testAsyncNotify()
|
||||
{
|
||||
Poco::BasicEvent<int>* pSimple= new Poco::BasicEvent<int>();
|
||||
(*pSimple) += delegate(this, &BasicEventTest::onAsync);
|
||||
Poco::BasicEvent<int> simple;
|
||||
simple += delegate(this, &BasicEventTest::onAsync);
|
||||
assertTrue (_count == 0);
|
||||
int tmp = 0;
|
||||
Poco::ActiveResult<int>retArg = pSimple->notifyAsync(this, tmp);
|
||||
delete pSimple; // must work even when the event got deleted!
|
||||
pSimple = NULL;
|
||||
Poco::ActiveResult<int>retArg = simple.notifyAsync(this, tmp);
|
||||
assertTrue (_count == 0);
|
||||
retArg.wait();
|
||||
assertTrue (retArg.data() == tmp);
|
||||
assertTrue (_count == LARGEINC);
|
||||
}
|
||||
|
||||
|
||||
void BasicEventTest::onStaticVoid(const void* pSender)
|
||||
{
|
||||
BasicEventTest* p = const_cast<BasicEventTest*>(reinterpret_cast<const BasicEventTest*>(pSender));
|
||||
p->_count++;
|
||||
}
|
||||
|
||||
|
||||
void BasicEventTest::onVoid(const void* pSender)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
|
||||
void BasicEventTest::onSimpleNoSender(int& i)
|
||||
{
|
||||
_count++;
|
||||
@@ -362,47 +371,55 @@ void BasicEventTest::onSimpleOther(const void* pSender, int& i)
|
||||
_count+=100;
|
||||
}
|
||||
|
||||
|
||||
void BasicEventTest::onConstSimple(const void* pSender, const int& i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
|
||||
void BasicEventTest::onComplex(const void* pSender, Poco::EventArgs* & i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
|
||||
void BasicEventTest::onComplex2(const void* pSender, Poco::EventArgs & i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
|
||||
void BasicEventTest::onConstComplex(const void* pSender, const Poco::EventArgs*& i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
|
||||
void BasicEventTest::onConst2Complex(const void* pSender, const Poco::EventArgs * const & i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
|
||||
void BasicEventTest::onAsync(const void* pSender, int& i)
|
||||
{
|
||||
Poco::Thread::sleep(700);
|
||||
_count += LARGEINC ;
|
||||
}
|
||||
|
||||
|
||||
int BasicEventTest::getCount() const
|
||||
{
|
||||
return _count;
|
||||
}
|
||||
|
||||
|
||||
void BasicEventTest::setUp()
|
||||
{
|
||||
_count = 0;
|
||||
// must clear events, otherwise repeating test executions will fail
|
||||
// because tests are only created once, only setup is called before
|
||||
// because tests are only created once, only setup is called before
|
||||
// each test run
|
||||
Void.clear();
|
||||
Simple.clear();
|
||||
|
@@ -56,7 +56,7 @@ namespace
|
||||
_counter(counter)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void run()
|
||||
{
|
||||
for (int i = 0; i < 100000; ++i)
|
||||
@@ -67,7 +67,7 @@ namespace
|
||||
--_counter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
AtomicCounter& _counter;
|
||||
};
|
||||
@@ -93,7 +93,7 @@ int Parent::i = 0;
|
||||
|
||||
struct Medium : public Parent
|
||||
{
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ void CoreTest::testFixedLength()
|
||||
assertTrue (sizeof(Poco::UInt64) == 8);
|
||||
#endif
|
||||
assertTrue (sizeof(Poco::IntPtr) == sizeof(void*));
|
||||
assertTrue (sizeof(Poco::UIntPtr) == sizeof(void*));
|
||||
assertTrue (sizeof(Poco::UIntPtr) == sizeof(void*));
|
||||
}
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ void CoreTest::testBugcheck()
|
||||
#if ENABLE_BUGCHECK_TEST
|
||||
try
|
||||
{
|
||||
Bugcheck::assertion("test", __FILE__, __LINE__);
|
||||
Bugcheck::assertion("test", __FILE__, __LINE__);
|
||||
failmsg("must throw exception");
|
||||
}
|
||||
catch (Exception&)
|
||||
@@ -160,7 +160,7 @@ void CoreTest::testBugcheck()
|
||||
|
||||
try
|
||||
{
|
||||
Bugcheck::nullPointer("test", __FILE__, __LINE__);
|
||||
Bugcheck::nullPointer("test", __FILE__, __LINE__);
|
||||
failmsg("must throw exception");
|
||||
}
|
||||
catch (Exception&)
|
||||
@@ -169,7 +169,7 @@ void CoreTest::testBugcheck()
|
||||
|
||||
try
|
||||
{
|
||||
Bugcheck::bugcheck("test", __FILE__, __LINE__);
|
||||
Bugcheck::bugcheck("test", __FILE__, __LINE__);
|
||||
failmsg("must throw exception");
|
||||
}
|
||||
catch (Exception&)
|
||||
@@ -181,7 +181,7 @@ void CoreTest::testBugcheck()
|
||||
|
||||
void CoreTest::testEnvironment()
|
||||
{
|
||||
#if !defined(_WIN32_WCE)
|
||||
#if !defined(_WIN32_WCE)
|
||||
Environment::set("FOO", "BAR");
|
||||
assertTrue (Environment::has("FOO"));
|
||||
assertTrue (Environment::get("FOO") == "BAR");
|
||||
@@ -194,7 +194,7 @@ void CoreTest::testEnvironment()
|
||||
catch (Exception&)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
std::cout << "OS Name: " << Environment::osName() << std::endl;
|
||||
std::cout << "OS Display Name: " << Environment::osDisplayName() << std::endl;
|
||||
std::cout << "OS Version: " << Environment::osVersion() << std::endl;
|
||||
@@ -321,7 +321,7 @@ void CoreTest::testFIFOBufferEOFAndError()
|
||||
typedef FIFOBuffer::Type T;
|
||||
|
||||
FIFOBuffer f(20, true);
|
||||
|
||||
|
||||
assertTrue (f.isEmpty());
|
||||
assertTrue (!f.isFull());
|
||||
|
||||
@@ -384,7 +384,7 @@ void CoreTest::testFIFOBufferEOFAndError()
|
||||
assertTrue (5 == f.used());
|
||||
f.setError();
|
||||
assertTrue (0 == f.write(b));
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
f.copy(b.begin(), 5);
|
||||
@@ -398,7 +398,7 @@ void CoreTest::testFIFOBufferEOFAndError()
|
||||
fail ("must throw InvalidAccessException");
|
||||
}
|
||||
catch (InvalidAccessException&) { }
|
||||
|
||||
|
||||
assertTrue (1 == _notToWritable);
|
||||
assertTrue (2 == _writableToNot);
|
||||
assertTrue (2 == _notToReadable);
|
||||
@@ -427,7 +427,7 @@ void CoreTest::testFIFOBufferChar()
|
||||
typedef FIFOBuffer::Type T;
|
||||
|
||||
FIFOBuffer f(20, true);
|
||||
|
||||
|
||||
assertTrue (f.isEmpty());
|
||||
assertTrue (!f.isFull());
|
||||
|
||||
@@ -743,7 +743,7 @@ void CoreTest::testFIFOBufferChar()
|
||||
assertTrue (10 == f.size());
|
||||
assertTrue (10 == f.used());
|
||||
assertTrue (0 == f.available());
|
||||
|
||||
|
||||
assertTrue (f[0] == '2');
|
||||
assertTrue (f[1] == '3');
|
||||
assertTrue (f[2] == '4');
|
||||
@@ -906,41 +906,41 @@ void CoreTest::testFIFOBufferInt()
|
||||
void CoreTest::testAtomicCounter()
|
||||
{
|
||||
AtomicCounter ac;
|
||||
|
||||
|
||||
assertTrue (ac.value() == 0);
|
||||
assertTrue (ac++ == 0);
|
||||
assertTrue (ac-- == 1);
|
||||
assertTrue (++ac == 1);
|
||||
assertTrue (--ac == 0);
|
||||
|
||||
|
||||
ac = 2;
|
||||
assertTrue (ac.value() == 2);
|
||||
|
||||
|
||||
ac = 0;
|
||||
assertTrue (ac.value() == 0);
|
||||
|
||||
|
||||
AtomicCounter ac2(2);
|
||||
assertTrue (ac2.value() == 2);
|
||||
|
||||
|
||||
ACTRunnable act(ac);
|
||||
Thread t1;
|
||||
Thread t2;
|
||||
Thread t3;
|
||||
Thread t4;
|
||||
Thread t5;
|
||||
|
||||
|
||||
t1.start(act);
|
||||
t2.start(act);
|
||||
t3.start(act);
|
||||
t4.start(act);
|
||||
t5.start(act);
|
||||
|
||||
|
||||
t1.join();
|
||||
t2.join();
|
||||
t3.join();
|
||||
t4.join();
|
||||
t5.join();
|
||||
|
||||
|
||||
assertTrue (ac.value() == 0);
|
||||
}
|
||||
|
||||
@@ -977,14 +977,14 @@ void CoreTest::testNullable()
|
||||
|
||||
Nullable<int> n1;
|
||||
assertTrue (n1.isNull());
|
||||
|
||||
|
||||
assertTrue (n1.value(42) == 42);
|
||||
assertTrue (n1.isNull());
|
||||
assertTrue (!(0 == n1));
|
||||
assertTrue (0 != n1);
|
||||
assertTrue (!(n1 == 0));
|
||||
assertTrue (n1 != 0);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
int POCO_UNUSED tmp = n1.value();
|
||||
@@ -993,25 +993,25 @@ void CoreTest::testNullable()
|
||||
catch (Poco::NullValueException&)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
n1 = 1;
|
||||
assertTrue (!n1.isNull());
|
||||
assertTrue (n1.value() == 1);
|
||||
|
||||
|
||||
Nullable<int> n2(42);
|
||||
assertTrue (!n2.isNull());
|
||||
assertTrue (n2.value() == 42);
|
||||
assertTrue (n2.value(99) == 42);
|
||||
|
||||
|
||||
assertTrue (!(0 == n2));
|
||||
assertTrue (0 != n2);
|
||||
assertTrue (!(n2 == 0));
|
||||
assertTrue (n2 != 0);
|
||||
|
||||
|
||||
n1 = n2;
|
||||
assertTrue (!n1.isNull());
|
||||
assertTrue (n1.value() == 42);
|
||||
|
||||
|
||||
std::ostringstream str;
|
||||
str << n1;
|
||||
assertTrue (str.str() == "42");
|
||||
@@ -1034,7 +1034,7 @@ void CoreTest::testNullable()
|
||||
assertTrue (n2 != n1);
|
||||
assertTrue (n1 > n2);
|
||||
|
||||
NullType nd;
|
||||
NullType nd{};
|
||||
assertTrue (n1 != nd);
|
||||
assertTrue (nd != n1);
|
||||
n1.clear();
|
||||
@@ -1049,7 +1049,7 @@ void CoreTest::testAscii()
|
||||
assertTrue (!Ascii::isAscii(-1));
|
||||
assertTrue (!Ascii::isAscii(128));
|
||||
assertTrue (!Ascii::isAscii(222));
|
||||
|
||||
|
||||
assertTrue (Ascii::isSpace(' '));
|
||||
assertTrue (Ascii::isSpace('\t'));
|
||||
assertTrue (Ascii::isSpace('\r'));
|
||||
@@ -1057,7 +1057,7 @@ void CoreTest::testAscii()
|
||||
assertTrue (!Ascii::isSpace('A'));
|
||||
assertTrue (!Ascii::isSpace(-1));
|
||||
assertTrue (!Ascii::isSpace(222));
|
||||
|
||||
|
||||
assertTrue (Ascii::isDigit('0'));
|
||||
assertTrue (Ascii::isDigit('1'));
|
||||
assertTrue (Ascii::isDigit('2'));
|
||||
@@ -1069,7 +1069,7 @@ void CoreTest::testAscii()
|
||||
assertTrue (Ascii::isDigit('8'));
|
||||
assertTrue (Ascii::isDigit('9'));
|
||||
assertTrue (!Ascii::isDigit('a'));
|
||||
|
||||
|
||||
assertTrue (Ascii::isHexDigit('0'));
|
||||
assertTrue (Ascii::isHexDigit('1'));
|
||||
assertTrue (Ascii::isHexDigit('2'));
|
||||
@@ -1097,21 +1097,21 @@ void CoreTest::testAscii()
|
||||
assertTrue (Ascii::isPunct('.'));
|
||||
assertTrue (Ascii::isPunct(','));
|
||||
assertTrue (!Ascii::isPunct('A'));
|
||||
|
||||
|
||||
assertTrue (Ascii::isAlpha('a'));
|
||||
assertTrue (Ascii::isAlpha('Z'));
|
||||
assertTrue (!Ascii::isAlpha('0'));
|
||||
|
||||
|
||||
assertTrue (Ascii::isLower('a'));
|
||||
assertTrue (!Ascii::isLower('A'));
|
||||
|
||||
|
||||
assertTrue (Ascii::isUpper('A'));
|
||||
assertTrue (!Ascii::isUpper('a'));
|
||||
|
||||
|
||||
assertTrue (Ascii::toLower('A') == 'a');
|
||||
assertTrue (Ascii::toLower('z') == 'z');
|
||||
assertTrue (Ascii::toLower('0') == '0');
|
||||
|
||||
|
||||
assertTrue (Ascii::toUpper('a') == 'A');
|
||||
assertTrue (Ascii::toUpper('0') == '0');
|
||||
assertTrue (Ascii::toUpper('Z') == 'Z');
|
||||
|
@@ -8,6 +8,11 @@
|
||||
//
|
||||
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
|
||||
#include "DateTimeTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
|
@@ -33,6 +33,7 @@ FIFOEventTest::~FIFOEventTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void FIFOEventTest::testNoDelegate()
|
||||
{
|
||||
int tmp = 0;
|
||||
@@ -54,12 +55,12 @@ void FIFOEventTest::testNoDelegate()
|
||||
Simple -= delegate(this, &FIFOEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
assertTrue (_count == 0);
|
||||
|
||||
|
||||
ConstSimple += delegate(this, &FIFOEventTest::onConstSimple);
|
||||
ConstSimple -= delegate(this, &FIFOEventTest::onConstSimple);
|
||||
ConstSimple.notify(this, tmp);
|
||||
assertTrue (_count == 0);
|
||||
|
||||
|
||||
//Note: passing &args will not work due to &
|
||||
EventArgs* pArgs = &args;
|
||||
Complex += delegate(this, &FIFOEventTest::onComplex);
|
||||
@@ -84,6 +85,7 @@ void FIFOEventTest::testNoDelegate()
|
||||
assertTrue (_count == 0);
|
||||
}
|
||||
|
||||
|
||||
void FIFOEventTest::testSingleDelegate()
|
||||
{
|
||||
int tmp = 0;
|
||||
@@ -98,11 +100,11 @@ void FIFOEventTest::testSingleDelegate()
|
||||
Simple += delegate(this, &FIFOEventTest::onSimple);
|
||||
Simple.notify(this, tmp);
|
||||
assertTrue (_count == 2);
|
||||
|
||||
|
||||
ConstSimple += delegate(this, &FIFOEventTest::onConstSimple);
|
||||
ConstSimple.notify(this, tmp);
|
||||
assertTrue (_count == 3);
|
||||
|
||||
|
||||
EventArgs* pArgs = &args;
|
||||
Complex += delegate(this, &FIFOEventTest::onComplex);
|
||||
Complex.notify(this, pArgs);
|
||||
@@ -123,13 +125,13 @@ void FIFOEventTest::testSingleDelegate()
|
||||
// check if 2nd notify also works
|
||||
Const2Complex.notify(this, pArgs);
|
||||
assertTrue (_count == 8);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void FIFOEventTest::testDuplicateRegister()
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
|
||||
assertTrue (_count == 0);
|
||||
|
||||
Simple += delegate(this, &FIFOEventTest::onSimple);
|
||||
@@ -141,11 +143,12 @@ void FIFOEventTest::testDuplicateRegister()
|
||||
assertTrue (_count == 3);
|
||||
}
|
||||
|
||||
|
||||
void FIFOEventTest::testDuplicateUnregister()
|
||||
{
|
||||
// duplicate unregister shouldn't give an error,
|
||||
int tmp = 0;
|
||||
|
||||
|
||||
assertTrue (_count == 0);
|
||||
|
||||
Simple -= delegate(this, &FIFOEventTest::onSimple); // should work
|
||||
@@ -169,7 +172,7 @@ void FIFOEventTest::testDuplicateUnregister()
|
||||
void FIFOEventTest::testDisabling()
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
|
||||
assertTrue (_count == 0);
|
||||
|
||||
Simple += delegate(this, &FIFOEventTest::onSimple);
|
||||
@@ -188,6 +191,7 @@ void FIFOEventTest::testDisabling()
|
||||
assertTrue (_count == 1);
|
||||
}
|
||||
|
||||
|
||||
void FIFOEventTest::testFIFOOrder()
|
||||
{
|
||||
DummyDelegate o1;
|
||||
@@ -203,7 +207,7 @@ void FIFOEventTest::testFIFOOrder()
|
||||
|
||||
Simple -= delegate(&o1, &DummyDelegate::onSimple);
|
||||
Simple -= delegate(&o2, &DummyDelegate::onSimple2);
|
||||
|
||||
|
||||
// now try with the wrong order
|
||||
Simple += delegate(&o2, &DummyDelegate::onSimple2);
|
||||
Simple += delegate(&o1, &DummyDelegate::onSimple);
|
||||
@@ -219,6 +223,7 @@ void FIFOEventTest::testFIFOOrder()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FIFOEventTest::testFIFOOrderExpire()
|
||||
{
|
||||
// expire must not break order!
|
||||
@@ -238,7 +243,7 @@ void FIFOEventTest::testFIFOOrderExpire()
|
||||
Simple -= delegate(&o2, &DummyDelegate::onSimple2);
|
||||
Simple.notify(this, tmp);
|
||||
assertTrue (tmp == 2);
|
||||
|
||||
|
||||
// now start mixing of expire and non expire
|
||||
tmp = 0;
|
||||
Simple += delegate(&o1, &DummyDelegate::onSimple);
|
||||
@@ -255,7 +260,7 @@ void FIFOEventTest::testFIFOOrderExpire()
|
||||
// now try with the wrong order
|
||||
Simple += delegate(&o2, &DummyDelegate::onSimple2, 5000);
|
||||
Simple += delegate(&o1, &DummyDelegate::onSimple);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
tmp = 0;
|
||||
@@ -264,15 +269,14 @@ void FIFOEventTest::testFIFOOrderExpire()
|
||||
}
|
||||
catch (Poco::InvalidArgumentException&)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void FIFOEventTest::testExpire()
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
|
||||
assertTrue (_count == 0);
|
||||
|
||||
Simple += delegate(this, &FIFOEventTest::onSimple, 500);
|
||||
@@ -287,7 +291,7 @@ void FIFOEventTest::testExpire()
|
||||
void FIFOEventTest::testExpireReRegister()
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
|
||||
assertTrue (_count == 0);
|
||||
|
||||
Simple += delegate(this, &FIFOEventTest::onSimple, 500);
|
||||
@@ -317,6 +321,7 @@ void FIFOEventTest::testReturnParams()
|
||||
assertTrue (tmp == 1);
|
||||
}
|
||||
|
||||
|
||||
void FIFOEventTest::testOverwriteDelegate()
|
||||
{
|
||||
DummyDelegate o1;
|
||||
@@ -328,77 +333,87 @@ void FIFOEventTest::testOverwriteDelegate()
|
||||
assertTrue (tmp == 2);
|
||||
}
|
||||
|
||||
|
||||
void FIFOEventTest::testAsyncNotify()
|
||||
{
|
||||
Poco::FIFOEvent<int >* pSimple= new Poco::FIFOEvent<int>();
|
||||
(*pSimple) += delegate(this, &FIFOEventTest::onAsync);
|
||||
Poco::FIFOEvent<int> simple;
|
||||
simple += delegate(this, &FIFOEventTest::onAsync);
|
||||
assertTrue (_count == 0);
|
||||
int tmp = 0;
|
||||
Poco::ActiveResult<int>retArg = pSimple->notifyAsync(this, tmp);
|
||||
delete pSimple; // must work even when the event got deleted!
|
||||
pSimple = NULL;
|
||||
Poco::ActiveResult<int>retArg = simple.notifyAsync(this, tmp);
|
||||
assertTrue (_count == 0);
|
||||
retArg.wait();
|
||||
assertTrue (retArg.data() == tmp);
|
||||
assertTrue (_count == LARGEINC);
|
||||
}
|
||||
|
||||
|
||||
void FIFOEventTest::onVoid(const void* pSender)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
|
||||
void FIFOEventTest::onSimple(const void* pSender, int& i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
|
||||
void FIFOEventTest::onSimpleOther(const void* pSender, int& i)
|
||||
{
|
||||
_count+=100;
|
||||
}
|
||||
|
||||
|
||||
void FIFOEventTest::onConstSimple(const void* pSender, const int& i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
|
||||
void FIFOEventTest::onComplex(const void* pSender, Poco::EventArgs* & i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
|
||||
void FIFOEventTest::onComplex2(const void* pSender, Poco::EventArgs & i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
|
||||
void FIFOEventTest::onConstComplex(const void* pSender, const Poco::EventArgs*& i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
|
||||
void FIFOEventTest::onConst2Complex(const void* pSender, const Poco::EventArgs * const & i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
|
||||
void FIFOEventTest::onAsync(const void* pSender, int& i)
|
||||
{
|
||||
Poco::Thread::sleep(700);
|
||||
_count += LARGEINC ;
|
||||
}
|
||||
|
||||
|
||||
int FIFOEventTest::getCount() const
|
||||
{
|
||||
return _count;
|
||||
}
|
||||
|
||||
|
||||
void FIFOEventTest::setUp()
|
||||
{
|
||||
_count = 0;
|
||||
// must clear events, otherwise repeating test executions will fail
|
||||
// because tests are only created once, only setup is called before
|
||||
// because tests are only created once, only setup is called before
|
||||
// each test run
|
||||
Void.clear();
|
||||
Simple.clear();
|
||||
|
@@ -526,7 +526,7 @@ void FileChannelTest::testWrongPurgeOption()
|
||||
{
|
||||
pChannel->setProperty(FileChannel::PROP_PURGEAGE, "peace");
|
||||
fail("must fail");
|
||||
} catch (InvalidArgumentException)
|
||||
} catch (InvalidArgumentException&)
|
||||
{
|
||||
assertTrue (pChannel->getProperty(FileChannel::PROP_PURGEAGE) == "5 seconds");
|
||||
}
|
||||
@@ -535,7 +535,7 @@ void FileChannelTest::testWrongPurgeOption()
|
||||
{
|
||||
pChannel->setProperty(FileChannel::PROP_PURGECOUNT, "peace");
|
||||
fail("must fail");
|
||||
} catch (InvalidArgumentException)
|
||||
} catch (InvalidArgumentException&)
|
||||
{
|
||||
assertTrue (pChannel->getProperty(FileChannel::PROP_PURGEAGE) == "5 seconds");
|
||||
}
|
||||
|
@@ -221,6 +221,29 @@ void LRUCacheTest::testUpdate()
|
||||
}
|
||||
|
||||
|
||||
void LRUCacheTest::testForEach()
|
||||
{
|
||||
LRUCache<int, int> aCache(3);
|
||||
|
||||
std::map<int, int> values;
|
||||
aCache.add(1, 100);
|
||||
aCache.add(2, 200);
|
||||
aCache.add(3, 300);
|
||||
|
||||
aCache.forEach(
|
||||
[&values](int key, int value)
|
||||
{
|
||||
values[key] = value;
|
||||
}
|
||||
);
|
||||
|
||||
assertEquals (values.size(), 3);
|
||||
assertEquals (values[1], 100);
|
||||
assertEquals (values[2], 200);
|
||||
assertEquals (values[3], 300);
|
||||
}
|
||||
|
||||
|
||||
void LRUCacheTest::onUpdate(const void* pSender, const Poco::KeyValueArgs<int, int>& args)
|
||||
{
|
||||
++updateCnt;
|
||||
@@ -260,6 +283,7 @@ CppUnit::Test* LRUCacheTest::suite()
|
||||
CppUnit_addTest(pSuite, LRUCacheTest, testCacheSizeN);
|
||||
CppUnit_addTest(pSuite, LRUCacheTest, testDuplicateAdd);
|
||||
CppUnit_addTest(pSuite, LRUCacheTest, testUpdate);
|
||||
CppUnit_addTest(pSuite, LRUCacheTest, testForEach);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@@ -31,6 +31,7 @@ public:
|
||||
void testCacheSizeN();
|
||||
void testDuplicateAdd();
|
||||
void testUpdate();
|
||||
void testForEach();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
@@ -8,6 +8,11 @@
|
||||
//
|
||||
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
|
||||
#include "LocalDateTimeTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
@@ -24,6 +29,7 @@
|
||||
#include "wce_time.h"
|
||||
#endif
|
||||
|
||||
|
||||
using Poco::LocalDateTime;
|
||||
using Poco::DateTime;
|
||||
using Poco::Timestamp;
|
||||
|
@@ -33,7 +33,7 @@ namespace
|
||||
public:
|
||||
void run()
|
||||
{
|
||||
|
||||
|
||||
testEvent.wait();
|
||||
_timestamp.update();
|
||||
}
|
||||
@@ -66,11 +66,11 @@ void NamedEventTest::testNamedEvent()
|
||||
thr1.start(te);
|
||||
Timestamp now;
|
||||
Thread::sleep(2000);
|
||||
try
|
||||
try
|
||||
{
|
||||
testEvent.set();
|
||||
}
|
||||
catch(Poco::NotImplementedException e)
|
||||
catch(Poco::NotImplementedException& e)
|
||||
{
|
||||
#if POCO_OS != POCO_OS_ANDROID
|
||||
throw e;
|
||||
@@ -84,11 +84,11 @@ void NamedEventTest::testNamedEvent()
|
||||
thr2.start(te);
|
||||
now.update();
|
||||
Thread::sleep(2000);
|
||||
try
|
||||
try
|
||||
{
|
||||
testEvent.set();
|
||||
}
|
||||
catch(Poco::NotImplementedException e)
|
||||
catch(Poco::NotImplementedException& e)
|
||||
{
|
||||
#if POCO_OS != POCO_OS_ANDROID
|
||||
throw e;
|
||||
|
@@ -33,7 +33,7 @@ namespace
|
||||
public:
|
||||
void run()
|
||||
{
|
||||
|
||||
|
||||
testMutex.lock();
|
||||
_timestamp.update();
|
||||
testMutex.unlock();
|
||||
@@ -54,7 +54,7 @@ namespace
|
||||
TestTryLock(): _locked(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void run()
|
||||
{
|
||||
if (testMutex.tryLock())
|
||||
@@ -87,7 +87,7 @@ NamedMutexTest::~NamedMutexTest()
|
||||
|
||||
void NamedMutexTest::testLock()
|
||||
{
|
||||
try
|
||||
try
|
||||
{
|
||||
testMutex.lock();
|
||||
Thread thr;
|
||||
@@ -99,7 +99,7 @@ void NamedMutexTest::testLock()
|
||||
thr.join();
|
||||
assertTrue (tl.timestamp() > now);
|
||||
}
|
||||
catch(Poco::NotImplementedException e)
|
||||
catch(Poco::NotImplementedException& e)
|
||||
{
|
||||
#if POCO_OS != POCO_OS_ANDROID
|
||||
throw e;
|
||||
@@ -117,7 +117,7 @@ void NamedMutexTest::testTryLock()
|
||||
#if POCO_OS != POCO_OS_ANDROID
|
||||
assertTrue (ttl1.locked());
|
||||
#endif
|
||||
try
|
||||
try
|
||||
{
|
||||
testMutex.lock();
|
||||
Thread thr2;
|
||||
@@ -127,7 +127,7 @@ void NamedMutexTest::testTryLock()
|
||||
testMutex.unlock();
|
||||
assertTrue (!ttl2.locked());
|
||||
}
|
||||
catch(Poco::NotImplementedException e)
|
||||
catch(Poco::NotImplementedException& e)
|
||||
{
|
||||
#if POCO_OS != POCO_OS_ANDROID
|
||||
throw e;
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/ObjectPool.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/Thread.h"
|
||||
|
||||
|
||||
using Poco::ObjectPool;
|
||||
@@ -30,18 +31,18 @@ ObjectPoolTest::~ObjectPoolTest()
|
||||
|
||||
void ObjectPoolTest::testObjectPool()
|
||||
{
|
||||
ObjectPool<std::string, Poco::SharedPtr<std::string> > pool(3, 4);
|
||||
|
||||
ObjectPool<std::string, Poco::SharedPtr<std::string>> pool(3, 4);
|
||||
|
||||
assertTrue (pool.capacity() == 3);
|
||||
assertTrue (pool.peakCapacity() == 4);
|
||||
assertTrue (pool.size() == 0);
|
||||
assertTrue (pool.available() == 4);
|
||||
|
||||
|
||||
Poco::SharedPtr<std::string> pStr1 = pool.borrowObject();
|
||||
pStr1->assign("first");
|
||||
assertTrue (pool.size() == 1);
|
||||
assertTrue (pool.available() == 3);
|
||||
|
||||
|
||||
Poco::SharedPtr<std::string> pStr2 = pool.borrowObject();
|
||||
pStr2->assign("second");
|
||||
assertTrue (pool.size() == 2);
|
||||
@@ -51,19 +52,19 @@ void ObjectPoolTest::testObjectPool()
|
||||
pStr3->assign("third");
|
||||
assertTrue (pool.size() == 3);
|
||||
assertTrue (pool.available() == 1);
|
||||
|
||||
|
||||
Poco::SharedPtr<std::string> pStr4 = pool.borrowObject();
|
||||
pStr4->assign("fourth");
|
||||
assertTrue (pool.size() == 4);
|
||||
assertTrue (pool.available() == 0);
|
||||
|
||||
|
||||
Poco::SharedPtr<std::string> pStr5 = pool.borrowObject();
|
||||
assertTrue (pStr5.isNull());
|
||||
|
||||
|
||||
pool.returnObject(pStr4);
|
||||
assertTrue (pool.size() == 4);
|
||||
assertTrue (pool.available() == 1);
|
||||
|
||||
|
||||
pool.returnObject(pStr3);
|
||||
assertTrue (pool.size() == 4);
|
||||
assertTrue (pool.available() == 2);
|
||||
@@ -75,10 +76,10 @@ void ObjectPoolTest::testObjectPool()
|
||||
pool.returnObject(pStr3);
|
||||
pool.returnObject(pStr2);
|
||||
pool.returnObject(pStr1);
|
||||
|
||||
|
||||
assertTrue (pool.size() == 3);
|
||||
assertTrue (pool.available() == 4);
|
||||
|
||||
|
||||
pStr1 = pool.borrowObject();
|
||||
assertTrue (*pStr1 == "second");
|
||||
assertTrue (pool.available() == 3);
|
||||
@@ -88,6 +89,27 @@ void ObjectPoolTest::testObjectPool()
|
||||
}
|
||||
|
||||
|
||||
void ObjectPoolTest::testObjectPoolWaitOnBorrowObject()
|
||||
{
|
||||
ObjectPool<std::string, Poco::SharedPtr<std::string>> pool(1, 1);
|
||||
|
||||
Poco::SharedPtr<std::string> objectToReturnDuringBorrow = pool.borrowObject();
|
||||
|
||||
Poco::Thread threadToReturnObject;
|
||||
threadToReturnObject.startFunc(
|
||||
[&pool, &objectToReturnDuringBorrow]()
|
||||
{
|
||||
pool.returnObject(objectToReturnDuringBorrow);
|
||||
}
|
||||
);
|
||||
|
||||
Poco::SharedPtr<std::string> object = pool.borrowObject(1000);
|
||||
|
||||
threadToReturnObject.join();
|
||||
assertFalse(object.isNull());
|
||||
}
|
||||
|
||||
|
||||
void ObjectPoolTest::setUp()
|
||||
{
|
||||
}
|
||||
@@ -103,6 +125,7 @@ CppUnit::Test* ObjectPoolTest::suite()
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ObjectPoolTest");
|
||||
|
||||
CppUnit_addTest(pSuite, ObjectPoolTest, testObjectPool);
|
||||
CppUnit_addTest(pSuite, ObjectPoolTest, testObjectPoolWaitOnBorrowObject);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@ public:
|
||||
~ObjectPoolTest();
|
||||
|
||||
void testObjectPool();
|
||||
void testObjectPoolWaitOnBorrowObject();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
@@ -907,7 +907,7 @@ void OrderedContainersTest::testHeterogeneousLookups()
|
||||
map.at(addr_unknown);
|
||||
fail("must throw");
|
||||
}
|
||||
catch (std::out_of_range) {}
|
||||
catch (std::out_of_range&) {}
|
||||
|
||||
assertTrue(map.find(addr1) != map.end());
|
||||
assertEquals(*map.find(addr1)->first, 1);
|
||||
|
@@ -30,9 +30,6 @@
|
||||
using Poco::Path;
|
||||
using Poco::PathSyntaxException;
|
||||
using Poco::Environment;
|
||||
using std::clog;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
|
||||
PathTest::PathTest(const std::string& name): CppUnit::TestCase(name)
|
||||
@@ -1239,7 +1236,6 @@ void PathTest::testParseVMS4()
|
||||
assertTrue (p[0] == "foo");
|
||||
assertTrue (!p.isDirectory());
|
||||
assertTrue (p.isFile());
|
||||
cout << "p.toString(Path::PATH_VMS)=" << p.toString(Path::PATH_VMS) << endl;
|
||||
assertTrue (p.toString(Path::PATH_VMS) == "[foo]bar.txt;5");
|
||||
assertTrue (p.version() == "5");
|
||||
|
||||
@@ -1301,7 +1297,6 @@ void PathTest::testParseGuess()
|
||||
assertTrue (p.getDevice() == "foo");
|
||||
assertTrue (!p.isDirectory());
|
||||
assertTrue (p.isFile());
|
||||
cout << "p.toString(Path::PATH_VMS)=" << p.toString(Path::PATH_VMS) << endl;
|
||||
assertTrue (p.toString(Path::PATH_VMS) == "foo:bar.txt;5");
|
||||
assertTrue (p.version() == "5");
|
||||
|
||||
|
@@ -42,6 +42,7 @@ void PatternFormatterTest::testPatternFormatter()
|
||||
msg.setThread("TestThread");
|
||||
msg.setPriority(Message::PRIO_ERROR);
|
||||
msg.setTime(DateTime(2005, 1, 1, 14, 30, 15, 500).timestamp());
|
||||
msg.setSourceFile(__FILE__);
|
||||
msg["testParam"] = "Test Parameter";
|
||||
|
||||
std::string result;
|
||||
@@ -91,6 +92,17 @@ void PatternFormatterTest::testPatternFormatter()
|
||||
fmt.setProperty("pattern", "start %v[8] end");
|
||||
fmt.format(msg, result);
|
||||
assertTrue (result == "start stSource end");
|
||||
|
||||
result.clear();
|
||||
fmt.setProperty("pattern", "%O");
|
||||
fmt.format(msg, result);
|
||||
assertTrue (result == "PatternFormatterTest.cpp");
|
||||
|
||||
result.clear();
|
||||
fmt.setProperty("priorityNames", "FATAL,CRITICAL,SPECIAL_ERROR_NAME,WARN,NOTICE,INFO,DEBUG,TRACE");
|
||||
fmt.setProperty("pattern", "%p");
|
||||
fmt.format(msg, result);
|
||||
assertTrue (result == "SPECIAL_ERROR_NAME");
|
||||
}
|
||||
|
||||
|
||||
|
@@ -33,6 +33,7 @@ PriorityEventTest::~PriorityEventTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void PriorityEventTest::testNoDelegate()
|
||||
{
|
||||
int tmp = 0;
|
||||
@@ -59,12 +60,12 @@ void PriorityEventTest::testNoDelegate()
|
||||
Simple -= priorityDelegate(this, &PriorityEventTest::onSimpleNoSender, 0);
|
||||
Simple.notify(this, tmp);
|
||||
assertTrue (_count == 0);
|
||||
|
||||
|
||||
ConstSimple += priorityDelegate(this, &PriorityEventTest::onConstSimple, 0);
|
||||
ConstSimple -= priorityDelegate(this, &PriorityEventTest::onConstSimple, 0);
|
||||
ConstSimple.notify(this, tmp);
|
||||
assertTrue (_count == 0);
|
||||
|
||||
|
||||
//Note: passing &args will not work due to &
|
||||
EventArgs* pArgs = &args;
|
||||
Complex += priorityDelegate(this, &PriorityEventTest::onComplex, 0);
|
||||
@@ -93,7 +94,7 @@ void PriorityEventTest::testNoDelegate()
|
||||
Simple += priorityDelegate(&PriorityEventTest::onStaticSimple, 1);
|
||||
Simple += priorityDelegate(&PriorityEventTest::onStaticSimple2, 2);
|
||||
Simple += priorityDelegate(&PriorityEventTest::onStaticSimple3, 3);
|
||||
|
||||
|
||||
Simple.notify(this, tmp);
|
||||
assertTrue (_count == 4);
|
||||
Simple -= priorityDelegate(PriorityEventTest::onStaticSimple, 0);
|
||||
@@ -108,6 +109,7 @@ void PriorityEventTest::testNoDelegate()
|
||||
Void -= priorityDelegate(PriorityEventTest::onStaticVoid, 0);
|
||||
}
|
||||
|
||||
|
||||
void PriorityEventTest::testSingleDelegate()
|
||||
{
|
||||
int tmp = 0;
|
||||
@@ -126,12 +128,12 @@ void PriorityEventTest::testSingleDelegate()
|
||||
Simple -= priorityDelegate(this, &PriorityEventTest::onSimple, 3);
|
||||
Simple.notify(this, tmp);
|
||||
assertTrue (_count == 2);
|
||||
|
||||
|
||||
ConstSimple += priorityDelegate(this, &PriorityEventTest::onConstSimple, 0);
|
||||
ConstSimple -= priorityDelegate(this, &PriorityEventTest::onConstSimple, 3);
|
||||
ConstSimple.notify(this, tmp);
|
||||
assertTrue (_count == 3);
|
||||
|
||||
|
||||
EventArgs* pArgs = &args;
|
||||
Complex += priorityDelegate(this, &PriorityEventTest::onComplex, 0);
|
||||
Complex -= priorityDelegate(this, &PriorityEventTest::onComplex, 3);
|
||||
@@ -156,13 +158,13 @@ void PriorityEventTest::testSingleDelegate()
|
||||
// check if 2nd notify also works
|
||||
Const2Complex.notify(this, pArgs);
|
||||
assertTrue (_count == 8);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void PriorityEventTest::testDuplicateRegister()
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
|
||||
assertTrue (_count == 0);
|
||||
|
||||
Simple += priorityDelegate(this, &PriorityEventTest::onSimple, 0);
|
||||
@@ -181,11 +183,12 @@ void PriorityEventTest::testDuplicateRegister()
|
||||
assertTrue (_count == 5 + LARGEINC);
|
||||
}
|
||||
|
||||
|
||||
void PriorityEventTest::testDuplicateUnregister()
|
||||
{
|
||||
// duplicate unregister shouldn't give an error,
|
||||
int tmp = 0;
|
||||
|
||||
|
||||
assertTrue (_count == 0);
|
||||
|
||||
Simple -= priorityDelegate(this, &PriorityEventTest::onSimple, 0); // should work
|
||||
@@ -209,7 +212,7 @@ void PriorityEventTest::testDuplicateUnregister()
|
||||
void PriorityEventTest::testDisabling()
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
|
||||
assertTrue (_count == 0);
|
||||
|
||||
Simple += priorityDelegate(this, &PriorityEventTest::onSimple, 0);
|
||||
@@ -228,6 +231,7 @@ void PriorityEventTest::testDisabling()
|
||||
assertTrue (_count == 1);
|
||||
}
|
||||
|
||||
|
||||
void PriorityEventTest::testPriorityOrder()
|
||||
{
|
||||
DummyDelegate o1;
|
||||
@@ -244,7 +248,7 @@ void PriorityEventTest::testPriorityOrder()
|
||||
|
||||
Simple -= PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0);
|
||||
Simple -= PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1);
|
||||
|
||||
|
||||
// now try with the wrong order
|
||||
Simple += PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 0);
|
||||
Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 1);
|
||||
@@ -263,6 +267,7 @@ void PriorityEventTest::testPriorityOrder()
|
||||
Simple -= PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 1);
|
||||
}
|
||||
|
||||
|
||||
void PriorityEventTest::testPriorityOrderExpire()
|
||||
{
|
||||
// expire must not break order!
|
||||
@@ -282,12 +287,12 @@ void PriorityEventTest::testPriorityOrderExpire()
|
||||
Simple -= priorityDelegate(&o2, &DummyDelegate::onSimple2, 1);
|
||||
Simple.notify(this, tmp);
|
||||
assertTrue (tmp == 2);
|
||||
|
||||
|
||||
// now start mixing of expire and non expire
|
||||
tmp = 0;
|
||||
Simple += priorityDelegate(&o2, &DummyDelegate::onSimple2, 1, 500000);
|
||||
Simple += priorityDelegate(&o1, &DummyDelegate::onSimple, 0);
|
||||
|
||||
|
||||
Simple.notify(this, tmp);
|
||||
assertTrue (tmp == 2);
|
||||
|
||||
@@ -313,13 +318,13 @@ void PriorityEventTest::testPriorityOrderExpire()
|
||||
|
||||
Simple -= priorityDelegate(&o2, &DummyDelegate::onSimple2, 0, 500000);
|
||||
Simple -= priorityDelegate(&o1, &DummyDelegate::onSimple, 1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void PriorityEventTest::testExpire()
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
|
||||
assertTrue (_count == 0);
|
||||
|
||||
Simple += priorityDelegate(this, &PriorityEventTest::onSimple, 1, 500);
|
||||
@@ -344,7 +349,7 @@ void PriorityEventTest::testExpire()
|
||||
void PriorityEventTest::testExpireReRegister()
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
|
||||
assertTrue (_count == 0);
|
||||
|
||||
Simple += priorityDelegate(this, &PriorityEventTest::onSimple, 1, 500);
|
||||
@@ -374,6 +379,7 @@ void PriorityEventTest::testReturnParams()
|
||||
assertTrue (tmp == 1);
|
||||
}
|
||||
|
||||
|
||||
void PriorityEventTest::testOverwriteDelegate()
|
||||
{
|
||||
DummyDelegate o1;
|
||||
@@ -385,32 +391,33 @@ void PriorityEventTest::testOverwriteDelegate()
|
||||
assertTrue (tmp == 2);
|
||||
}
|
||||
|
||||
|
||||
void PriorityEventTest::testAsyncNotify()
|
||||
{
|
||||
Poco::PriorityEvent<int >* pSimple= new Poco::PriorityEvent<int>();
|
||||
(*pSimple) += priorityDelegate(this, &PriorityEventTest::onAsync, 0);
|
||||
Poco::PriorityEvent<int> simple;
|
||||
simple += priorityDelegate(this, &PriorityEventTest::onAsync, 0);
|
||||
assertTrue (_count == 0);
|
||||
int tmp = 0;
|
||||
Poco::ActiveResult<int>retArg = pSimple->notifyAsync(this, tmp);
|
||||
delete pSimple; // must work even when the event got deleted!
|
||||
pSimple = NULL;
|
||||
Poco::ActiveResult<int>retArg = simple.notifyAsync(this, tmp);
|
||||
assertTrue (_count == 0);
|
||||
retArg.wait();
|
||||
assertTrue (retArg.data() == tmp);
|
||||
assertTrue (_count == LARGEINC);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void PriorityEventTest::onStaticVoid(const void* pSender)
|
||||
{
|
||||
PriorityEventTest* p = const_cast<PriorityEventTest*>(reinterpret_cast<const PriorityEventTest*>(pSender));
|
||||
p->_count++;
|
||||
}
|
||||
|
||||
|
||||
void PriorityEventTest::onVoid(const void* pSender){
|
||||
_count++;
|
||||
}
|
||||
|
||||
|
||||
void PriorityEventTest::onStaticSimple(const void* pSender, int& i)
|
||||
{
|
||||
PriorityEventTest* p = const_cast<PriorityEventTest*>(reinterpret_cast<const PriorityEventTest*>(pSender));
|
||||
@@ -441,52 +448,61 @@ void PriorityEventTest::onSimple(const void* pSender, int& i)
|
||||
_count++;
|
||||
}
|
||||
|
||||
|
||||
void PriorityEventTest::onSimpleOther(const void* pSender, int& i)
|
||||
{
|
||||
_count += LARGEINC ;
|
||||
}
|
||||
|
||||
|
||||
void PriorityEventTest::onConstSimple(const void* pSender, const int& i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
|
||||
void PriorityEventTest::onComplex(const void* pSender, Poco::EventArgs* & i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
|
||||
void PriorityEventTest::onComplex2(const void* pSender, Poco::EventArgs & i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
|
||||
void PriorityEventTest::onConstComplex(const void* pSender, const Poco::EventArgs*& i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
|
||||
void PriorityEventTest::onConst2Complex(const void* pSender, const Poco::EventArgs * const & i)
|
||||
{
|
||||
_count++;
|
||||
}
|
||||
|
||||
|
||||
void PriorityEventTest::onAsync(const void* pSender, int& i)
|
||||
{
|
||||
Poco::Thread::sleep(700);
|
||||
_count += LARGEINC ;
|
||||
}
|
||||
|
||||
|
||||
int PriorityEventTest::getCount() const
|
||||
{
|
||||
return _count;
|
||||
}
|
||||
|
||||
|
||||
void PriorityEventTest::setUp()
|
||||
{
|
||||
_count = 0;
|
||||
// must clear events, otherwise repeating test executions will fail
|
||||
// because tests are only created once, only setup is called before
|
||||
// because tests are only created once, only setup is called before
|
||||
// each test run
|
||||
Void.clear();
|
||||
Simple.clear();
|
||||
|
@@ -8,6 +8,11 @@
|
||||
//
|
||||
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
|
||||
#include "StringTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
@@ -89,8 +94,12 @@ void StringTest::testTrimLeft()
|
||||
std::string s = " abc ";
|
||||
assertTrue (trimLeft(s) == "abc ");
|
||||
{
|
||||
std::string s = " ab c ";
|
||||
assertTrue (trimLeft(s) == "ab c ");
|
||||
std::string s = " ab c ";
|
||||
assertTrue (trimLeft(s) == "ab c ");
|
||||
}
|
||||
{
|
||||
std::string s;
|
||||
assertTrue (trimLeft(s) == "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,6 +118,10 @@ void StringTest::testTrimLeftInPlace()
|
||||
std::string s = " ab c ";
|
||||
assertTrue (trimLeftInPlace(s) == "ab c ");
|
||||
}
|
||||
{
|
||||
std::string s;
|
||||
assertTrue (trimLeftInPlace(s) == "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -126,6 +139,10 @@ void StringTest::testTrimRight()
|
||||
std::string s = " ab c ";
|
||||
assertTrue (trimRight(s) == " ab c");
|
||||
}
|
||||
{
|
||||
std::string s;
|
||||
assertTrue (trimRight(s) == "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -143,6 +160,10 @@ void StringTest::testTrimRightInPlace()
|
||||
std::string s = " ab c ";
|
||||
assertTrue (trimRightInPlace(s) == " ab c");
|
||||
}
|
||||
{
|
||||
std::string s;
|
||||
assertTrue (trimRightInPlace(s) == "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -160,6 +181,10 @@ void StringTest::testTrim()
|
||||
std::string s = " ab c ";
|
||||
assertTrue (trim(s) == "ab c");
|
||||
}
|
||||
{
|
||||
std::string s;
|
||||
assertTrue (trim(s) == "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -177,6 +202,10 @@ void StringTest::testTrimInPlace()
|
||||
std::string s = " ab c ";
|
||||
assertTrue (trimInPlace(s) == "ab c");
|
||||
}
|
||||
{
|
||||
std::string s;
|
||||
assertTrue (trimInPlace(s) == "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -783,6 +812,7 @@ void StringTest::testNumericStringPadding()
|
||||
{
|
||||
std::string str;
|
||||
assertTrue (floatToStr(str, 0.999f, 2, 4) == "1.00");
|
||||
assertTrue (floatToStr(str, 0.999f, 2, 4, '.', ',') == "1,00");
|
||||
assertTrue (floatToStr(str, 0.945f, 2, 4) == "0.95");
|
||||
assertTrue (floatToStr(str, 0.944f, 2, 4) == "0.94");
|
||||
assertTrue (floatToStr(str, 12.45f, 2, 5) == "12.45");
|
||||
@@ -800,6 +830,7 @@ void StringTest::testNumericStringPadding()
|
||||
assertTrue (doubleToStr(str, 12.45, 2, 6) == " 12.45");
|
||||
assertTrue (doubleToStr(str, 12.455, 3, 7) == " 12.455");
|
||||
assertTrue (doubleToStr(str, 12.455, 2, 6) == " 12.46");
|
||||
assertTrue (doubleToStr(str, 12345.678, 3, 6, '.', ',') == "12.345,678");
|
||||
assertTrue (doubleToStr(str, 1.23556E-16, 2, 6) == "1.24e-16");
|
||||
}
|
||||
|
||||
@@ -1378,7 +1409,6 @@ void StringTest::testJSONString()
|
||||
{
|
||||
assertTrue (toJSON("\\", false) == "\\\\");
|
||||
assertTrue (toJSON("\"", false) == "\\\"");
|
||||
assertTrue (toJSON("/", false) == "\\/");
|
||||
assertTrue (toJSON("\a", false) == "\\u0007");
|
||||
assertTrue (toJSON("\b", false) == "\\b");
|
||||
assertTrue (toJSON("\f", false) == "\\f");
|
||||
@@ -1395,7 +1425,7 @@ void StringTest::testJSONString()
|
||||
std::string str = "\"foo\\\\\"";
|
||||
assertTrue (toJSON("foo\\") == str);
|
||||
|
||||
assertTrue (toJSON("bar/") == "\"bar\\/\"");
|
||||
assertTrue (toJSON("bar/") == "\"bar/\"");
|
||||
assertTrue (toJSON("baz") == "\"baz\"");
|
||||
assertTrue (toJSON("q\"uote\"d") == "\"q\\\"uote\\\"d\"");
|
||||
assertTrue (toJSON("bs\b") == "\"bs\\b\"");
|
||||
@@ -1412,7 +1442,7 @@ void StringTest::testJSONString()
|
||||
ostr.str("");
|
||||
|
||||
toJSON("foo\\", ostr);
|
||||
assertTrue (toJSON("bar/") == "\"bar\\/\"");
|
||||
assertTrue (toJSON("bar/") == "\"bar/\"");
|
||||
ostr.str("");
|
||||
toJSON("baz", ostr);
|
||||
assertTrue (ostr.str() == "\"baz\"");
|
||||
|
80
vendor/POCO/Foundation/testsuite/src/VarTest.cpp
vendored
80
vendor/POCO/Foundation/testsuite/src/VarTest.cpp
vendored
@@ -2438,14 +2438,14 @@ void VarTest::testDynamicPair()
|
||||
catch (InvalidAccessException&) { }
|
||||
|
||||
Var va(aPair);
|
||||
assertTrue ("{ \"0\" : null }" == va.convert<std::string>());
|
||||
assertTrue ("{ \"0\": null }" == va.convert<std::string>());
|
||||
assertTrue (aPair.toString() == va.convert<std::string>());
|
||||
|
||||
aPair = Pair<int>(4, "123");
|
||||
assertTrue ("123" == aPair.second());
|
||||
|
||||
va = aPair;
|
||||
assertTrue ("{ \"4\" : \"123\" }" == va.convert<std::string>());
|
||||
assertTrue ("{ \"4\": \"123\" }" == va.convert<std::string>());
|
||||
assertTrue (aPair.toString() == va.convert<std::string>());
|
||||
|
||||
int i = 1;
|
||||
@@ -2464,11 +2464,11 @@ void VarTest::testDynamicPair()
|
||||
assertTrue ("2" == pPair.second());
|
||||
|
||||
Var vp(pPair);
|
||||
assertTrue ("{ \"1\" : \"2\" }" == vp.convert<std::string>());
|
||||
assertTrue ("{ \"1\": \"2\" }" == vp.convert<std::string>());
|
||||
assertTrue (pPair.toString() == vp.convert<std::string>());
|
||||
|
||||
Var vs(sPair);
|
||||
assertTrue ("{ \"2\" : 1 }" == vs.convert<std::string>());
|
||||
assertTrue ("{ \"2\": 1 }" == vs.convert<std::string>());
|
||||
assertTrue (sPair.toString() == vs.convert<std::string>());
|
||||
}
|
||||
|
||||
@@ -2509,7 +2509,7 @@ void VarTest::testStructToString()
|
||||
aStruct["Age"] = 1;
|
||||
Var a1(aStruct);
|
||||
std::string res = a1.convert<std::string>();
|
||||
std::string expected = "{ \"Age\" : 1, \"First Name\" : \"Junior\", \"Last Name\" : \"POCO\" }";
|
||||
std::string expected = "{ \"Age\": 1, \"First Name\": \"Junior\", \"Last Name\": \"POCO\" }";
|
||||
assertTrue (res == expected);
|
||||
assertTrue (aStruct.toString() == res);
|
||||
}
|
||||
@@ -2523,7 +2523,7 @@ void VarTest::testOrderedStructToString()
|
||||
aStruct["Age"] = 1;
|
||||
Var a1(aStruct);
|
||||
std::string res = a1.convert<std::string>();
|
||||
std::string expected = "{ \"First Name\" : \"Junior\", \"Last Name\" : \"POCO\", \"Age\" : 1 }";
|
||||
std::string expected = "{ \"First Name\": \"Junior\", \"Last Name\": \"POCO\", \"Age\": 1 }";
|
||||
assertTrue(res == expected);
|
||||
assertTrue(aStruct.toString() == res);
|
||||
}
|
||||
@@ -2535,7 +2535,7 @@ void VarTest::testStructToStringEscape()
|
||||
aStruct["Value"] = "Value with \" and \n";
|
||||
Var a1(aStruct);
|
||||
std::string res = a1.convert<std::string>();
|
||||
std::string expected = "{ \"Value\" : \"Value with \\\" and \\n\" }";
|
||||
std::string expected = "{ \"Value\": \"Value with \\\" and \\n\" }";
|
||||
assertTrue (res == expected);
|
||||
assertTrue (aStruct.toString() == res);
|
||||
}
|
||||
@@ -2560,14 +2560,14 @@ void VarTest::testArrayOfStructsToString()
|
||||
Var a1(s16);
|
||||
std::string res = a1.convert<std::string>();
|
||||
std::string expected = "[ "
|
||||
"{ \"Age\" : 1, \"First Name\" : \"Junior\", \"Last Name\" : \"POCO\" }, "
|
||||
"{ \"Age\" : 100, \"First Name\" : \"Senior\", \"Last Name\" : \"POCO\" }, "
|
||||
"{ \"Age\": 1, \"First Name\": \"Junior\", \"Last Name\": \"POCO\" }, "
|
||||
"{ \"Age\": 100, \"First Name\": \"Senior\", \"Last Name\": \"POCO\" }, "
|
||||
"[ "
|
||||
"{ \"Age\" : 1, \"First Name\" : \"Junior\", \"Last Name\" : \"POCO\" }, "
|
||||
"{ \"Age\" : 100, \"First Name\" : \"Senior\", \"Last Name\" : \"POCO\" }, "
|
||||
"{ \"Age\": 1, \"First Name\": \"Junior\", \"Last Name\": \"POCO\" }, "
|
||||
"{ \"Age\": 100, \"First Name\": \"Senior\", \"Last Name\": \"POCO\" }, "
|
||||
"[ "
|
||||
"{ \"Age\" : 1, \"First Name\" : \"Junior\", \"Last Name\" : \"POCO\" }, "
|
||||
"{ \"Age\" : 100, \"First Name\" : \"Senior\", \"Last Name\" : \"POCO\" } "
|
||||
"{ \"Age\": 1, \"First Name\": \"Junior\", \"Last Name\": \"POCO\" }, "
|
||||
"{ \"Age\": 100, \"First Name\": \"Senior\", \"Last Name\": \"POCO\" } "
|
||||
"] ] ]";
|
||||
|
||||
assertTrue (res == expected);
|
||||
@@ -2594,8 +2594,8 @@ void VarTest::testStructWithArraysToString()
|
||||
aStruct["Address"] = addr;
|
||||
Var a2(aStruct);
|
||||
std::string res = a2.convert<std::string>();
|
||||
std::string expected = "{ \"Address\" : { \"Country\" : \"Carinthia\", \"Number\" : 4, \"Street\" : \"Unknown\" }, "
|
||||
"\"Age\" : 1, \"First Name\" : \"Junior\", \"Last Name\" : [ \"string\", 23 ] }";
|
||||
std::string expected = "{ \"Address\": { \"Country\": \"Carinthia\", \"Number\": 4, \"Street\": \"Unknown\" }, "
|
||||
"\"Age\": 1, \"First Name\": \"Junior\", \"Last Name\": [ \"string\", 23 ] }";
|
||||
|
||||
assertTrue (res == expected);
|
||||
assertTrue (aStruct.toString() == res);
|
||||
@@ -2615,17 +2615,17 @@ void VarTest::testJSONDeserializeString()
|
||||
char cc = b2.convert<char>();
|
||||
assertTrue (cc == 'c');
|
||||
|
||||
tst = "{ \"a\" : \"1\", \"b\" : \"2\" \n}";
|
||||
tst = "{ \"a\": \"1\", \"b\": \"2\" \n}";
|
||||
a = Var::parse(tst);
|
||||
assertTrue (a.toString() == "{ \"a\" : \"1\", \"b\" : \"2\" }");
|
||||
assertTrue (a.toString() == "{ \"a\": \"1\", \"b\": \"2\" }");
|
||||
|
||||
tst = "{ \"a\" : \"1\", \"b\" : \"2\"\n}";
|
||||
tst = "{ \"a\": \"1\", \"b\": \"2\"\n}";
|
||||
a = Var::parse(tst);
|
||||
assertTrue (a.toString() == "{ \"a\" : \"1\", \"b\" : \"2\" }");
|
||||
assertTrue (a.toString() == "{ \"a\": \"1\", \"b\": \"2\" }");
|
||||
|
||||
tst = "{ \"message\" : \"escape\\b\\f\\n\\r\\t\", \"path\" : \"\\/dev\\/null\" }";
|
||||
tst = "{ \"message\": \"escape\\b\\f\\n\\r\\t\", \"path\": \"\\/dev\\/null\", \"zero\": null }";
|
||||
a = Var::parse(tst);
|
||||
assertTrue(a.toString() == "{ \"message\" : \"escape\\b\\f\\n\\r\\t\", \"path\" : \"\\/dev\\/null\" }");
|
||||
assertTrue(a.toString() == "{ \"message\": \"escape\\b\\f\\n\\r\\t\", \"path\": \"/dev/null\", \"zero\": null }");
|
||||
}
|
||||
|
||||
|
||||
@@ -2859,6 +2859,32 @@ void VarTest::testDate()
|
||||
}
|
||||
|
||||
|
||||
void VarTest::testUUID()
|
||||
{
|
||||
Poco::UUID uuid("f1881be4-c3b7-4a47-9619-5169db5108a7");
|
||||
|
||||
Var vuuid(uuid);
|
||||
assertTrue (vuuid.isUUID());
|
||||
|
||||
assert (vuuid.convert<std::string>() == "f1881be4-c3b7-4a47-9619-5169db5108a7");
|
||||
|
||||
assert (vuuid.extract<Poco::UUID>() == uuid);
|
||||
|
||||
Var vstr(std::string("f1881be4-c3b7-4a47-9619-5169db5108a7"));
|
||||
assert (vstr.convert<Poco::UUID>() == uuid);
|
||||
|
||||
Var vstr2(std::string("notAnUUID"));
|
||||
try
|
||||
{
|
||||
Poco::UUID uuid2 = vstr2.convert<Poco::UUID>();
|
||||
fail("not a valid UUID, must fail");
|
||||
}
|
||||
catch (Poco::SyntaxException&)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void VarTest::testGetIdxNoThrow(Var& a1, std::vector<Var>::size_type n)
|
||||
{
|
||||
Var val1 = a1[n];
|
||||
@@ -2973,8 +2999,15 @@ void VarTest::testEmpty()
|
||||
void VarTest::testIterator()
|
||||
{
|
||||
Var da;
|
||||
assertTrue (da.isEmpty());
|
||||
assertTrue (da.begin() == da.end());
|
||||
try
|
||||
{
|
||||
auto it = da.begin();
|
||||
fail("calling begin() on empty Var must throw");
|
||||
}
|
||||
catch (const InvalidAccessException&) { }
|
||||
|
||||
da = Poco::Dynamic::Array();
|
||||
assertTrue(da.begin() == da.end());
|
||||
|
||||
da = 1;
|
||||
assertTrue (!da.isEmpty());
|
||||
@@ -3097,6 +3130,7 @@ CppUnit::Test* VarTest::suite()
|
||||
CppUnit_addTest(pSuite, VarTest, testJSONDeserializeComplex);
|
||||
CppUnit_addTest(pSuite, VarTest, testJSONRoundtripStruct);
|
||||
CppUnit_addTest(pSuite, VarTest, testDate);
|
||||
CppUnit_addTest(pSuite, VarTest, testUUID);
|
||||
CppUnit_addTest(pSuite, VarTest, testEmpty);
|
||||
CppUnit_addTest(pSuite, VarTest, testIterator);
|
||||
|
||||
|
27
vendor/POCO/Foundation/testsuite/src/VarTest.h
vendored
27
vendor/POCO/Foundation/testsuite/src/VarTest.h
vendored
@@ -71,13 +71,13 @@ public:
|
||||
void testJSONDeserializePrimitives();
|
||||
void testJSONDeserializeArray();
|
||||
void testJSONDeserializeStruct();
|
||||
void testJSONRoundtripStruct();
|
||||
void testJSONRoundtripStruct();
|
||||
void testJSONDeserializeComplex();
|
||||
void testDate();
|
||||
void testUUID();
|
||||
void testEmpty();
|
||||
void testIterator();
|
||||
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
static CppUnit::Test* suite();
|
||||
@@ -184,14 +184,29 @@ private:
|
||||
void testContainerIterator()
|
||||
{
|
||||
C cont;
|
||||
Poco::Dynamic::Var arr(cont);
|
||||
int counter = 0;
|
||||
|
||||
// test empty
|
||||
assertTrue (arr.size() == 0);
|
||||
Poco::Dynamic::Var::Iterator it = arr.begin();
|
||||
Poco::Dynamic::Var::Iterator end = arr.end();
|
||||
|
||||
for (; it != end; ++it)
|
||||
{
|
||||
*it = ++counter;
|
||||
}
|
||||
assertTrue(counter == 0);
|
||||
|
||||
// test non-empty
|
||||
cont.push_back(1);
|
||||
cont.push_back("2");
|
||||
cont.push_back(3.5);
|
||||
Poco::Dynamic::Var arr(cont);
|
||||
arr = cont;
|
||||
assertTrue (arr.size() == 3);
|
||||
Poco::Dynamic::Var::Iterator it = arr.begin();
|
||||
Poco::Dynamic::Var::Iterator end = arr.end();
|
||||
int counter = 0;
|
||||
it = arr.begin();
|
||||
end = arr.end();
|
||||
counter = 0;
|
||||
for (; it != end; ++it)
|
||||
{
|
||||
switch (++counter)
|
||||
|
Reference in New Issue
Block a user