Merge branch 'develop' into issue_532-3

This commit is contained in:
martin-osborne
2015-01-11 11:12:43 +00:00
2485 changed files with 23564 additions and 128705 deletions

View File

@@ -18,8 +18,10 @@
#include "Poco/Timespan.h"
#include "Poco/Exception.h"
GCC_DIAG_OFF(unused-variable)
using Poco::Timestamp;
using Poco::DateTime;
using Poco::Timespan;
@@ -443,6 +445,28 @@ void DateTimeTest::testArithmetics()
loop_1_assert(line, data[di].month2 == X.month());
loop_1_assert(line, data[di].day2 == X.day());
}
DateTime edgeTime(2014, 9, 16, 0, 0, 0, 0, 10);
edgeTime -= Poco::Timespan(11);
assert (edgeTime.year() == 2014);
assert (edgeTime.month() == 9);
assert (edgeTime.day() == 15);
assert (edgeTime.hour() == 23);
assert (edgeTime.minute() == 59);
assert (edgeTime.second() == 59);
assert (edgeTime.millisecond() == 999);
assert (edgeTime.microsecond() == 999);
edgeTime.assign(2014, 9, 15, 23, 59, 59, 999, 968);
edgeTime += Poco::Timespan(11);
assert (edgeTime.year() == 2014);
assert (edgeTime.month() == 9);
assert (edgeTime.day() == 15);
assert (edgeTime.hour() == 23);
assert (edgeTime.minute() == 59);
assert (edgeTime.second() == 59);
assert (edgeTime.millisecond() == 999);
assert (edgeTime.microsecond() == 979);
}
void DateTimeTest::testIncrementDecrement()

View File

@@ -142,6 +142,28 @@ void LoggerTest::testLogger()
pChannel->list().clear();
root.fatal("fatal");
assert (pChannel->list().begin()->getPriority() == Message::PRIO_FATAL);
root.setLevel("1");
assert (root.getLevel() == Message::PRIO_FATAL);
root.setLevel("8");
assert (root.getLevel() == Message::PRIO_TRACE);
try
{
root.setLevel("0");
assert(0);
}
catch(Poco::InvalidArgumentException&)
{
}
try
{
root.setLevel("9");
assert(0);
}
catch(Poco::InvalidArgumentException&)
{
}
}
@@ -199,6 +221,18 @@ void LoggerTest::testFormatAny()
root.error("%d%d%d%d%d%d", 1, 2, 3, 4, 5, 6);
assert (pChannel->getLastMessage().getText() == "123456");
root.error("%d%d%d%d%d%d%d", 1, 2, 3, 4, 5, 6, 7);
assert(pChannel->getLastMessage().getText() == "1234567");
root.error("%d%d%d%d%d%d%d%d", 1, 2, 3, 4, 5, 6, 7, 8);
assert(pChannel->getLastMessage().getText() == "12345678");
root.error("%d%d%d%d%d%d%d%d%d", 1, 2, 3, 4, 5, 6, 7, 8, 9);
assert(pChannel->getLastMessage().getText() == "123456789");
root.error("%d%d%d%d%d%d%d%d%d%d", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
assert(pChannel->getLastMessage().getText() == "12345678910");
}

View File

@@ -363,6 +363,45 @@ void ThreadTest::testThreadFunction()
}
struct Functor
{
void operator () ()
{
++MyRunnable::_staticVar;
}
};
void ThreadTest::testThreadFunctor()
{
Thread thread;
assert (!thread.isRunning());
MyRunnable::_staticVar = 0;
thread.startFunc(Functor());
thread.join();
assert (1 == MyRunnable::_staticVar);
assert (!thread.isRunning());
#if __cplusplus >= 201103L
Thread thread2;
assert (!thread2.isRunning());
MyRunnable::_staticVar = 0;
thread.startFunc([] () {MyRunnable::_staticVar++;});
thread.join();
assert (1 == MyRunnable::_staticVar);
assert (!thread2.isRunning());
#endif
}
void ThreadTest::testThreadStackSize()
{
int stackSize = 50000000;
@@ -436,6 +475,7 @@ CppUnit::Test* ThreadTest::suite()
CppUnit_addTest(pSuite, ThreadTest, testTrySleep);
CppUnit_addTest(pSuite, ThreadTest, testThreadTarget);
CppUnit_addTest(pSuite, ThreadTest, testThreadFunction);
CppUnit_addTest(pSuite, ThreadTest, testThreadFunctor);
CppUnit_addTest(pSuite, ThreadTest, testThreadStackSize);
CppUnit_addTest(pSuite, ThreadTest, testSleep);

View File

@@ -37,6 +37,7 @@ public:
void testTrySleep();
void testThreadTarget();
void testThreadFunction();
void testThreadFunctor();
void testThreadStackSize();
void testSleep();

View File

@@ -720,6 +720,7 @@ void URITest::testSwap()
assert (uri2.toString() == "http://www.appinf.com/search.cgi?keyword=test%20encoded&scope=all#result");
}
void URITest::testOther()
{
// The search string is "hello%world"; google happens to ignore the '%'
@@ -735,6 +736,18 @@ void URITest::testOther()
assert(uri.toString() == "http://google.com/search?q=hello%25world#frag%20ment");
assert(uri.getPathEtc() == "/search?q=hello%25world#frag%20ment");
uri.setQuery("q=foo&bar");
assert(uri.getQuery() == "q=foo&bar");
assert(uri.getRawQuery() == "q=foo&bar");
assert(uri.toString() == "http://google.com/search?q=foo&bar#frag%20ment");
assert(uri.getPathEtc() == "/search?q=foo&bar#frag%20ment");
uri.setQuery("q=foo/bar");
assert(uri.getQuery() == "q=foo/bar");
assert(uri.getRawQuery() == "q=foo%2Fbar");
assert(uri.toString() == "http://google.com/search?q=foo%2Fbar#frag%20ment");
assert(uri.getPathEtc() == "/search?q=foo%2Fbar#frag%20ment");
uri.setQuery("q=goodbye cruel world");
assert(uri.getQuery() == "q=goodbye cruel world");
assert(uri.getRawQuery() == "q=goodbye%20cruel%20world");
@@ -753,6 +766,15 @@ void URITest::testOther()
uri.addQueryParameter("pa=ra&m2", "val&ue");
assert(uri.getRawQuery() == "q=pony%7eride&pa%3Dra%26m1=&pa%3Dra%26m2=val%26ue");
assert(uri.getQuery() == "q=pony~ride&pa=ra&m1=&pa=ra&m2=val&ue");
uri = "http://google.com/search?q=hello+world#frag%20ment";
assert(uri.getHost() == "google.com");
assert(uri.getPath() == "/search");
assert(uri.getQuery() == "q=hello+world");
assert(uri.getRawQuery() == "q=hello+world");
assert(uri.getFragment() == "frag ment");
assert(uri.toString() == "http://google.com/search?q=hello+world#frag%20ment");
assert(uri.getPathEtc() == "/search?q=hello+world#frag%20ment");
}
@@ -792,6 +814,40 @@ void URITest::testFromPath()
}
void URITest::testQueryParameters()
{
Poco::URI uri("http://google.com/search?q=hello+world&client=safari");
URI::QueryParameters params = uri.getQueryParameters();
assert (params.size() == 2);
assert (params[0].first == "q");
assert (params[0].second == "hello world");
assert (params[1].first == "client");
assert (params[1].second == "safari");
uri.setQueryParameters(params);
assert (uri.toString() == "http://google.com/search?q=hello%20world&client=safari");
uri = "http://google.com/search?q=&client&";
params = uri.getQueryParameters();
assert (params.size() == 2);
assert (params[0].first == "q");
assert (params[0].second == "");
assert (params[1].first == "client");
assert (params[1].second == "");
uri.setQueryParameters(params);
assert (uri.toString() == "http://google.com/search?q=&client=");
params[0].second = "foo/bar?";
uri.setQueryParameters(params);
assert (uri.toString() == "http://google.com/search?q=foo%2Fbar%3F&client=");
params[0].second = "foo&bar";
uri.setQueryParameters(params);
assert (uri.toString() == "http://google.com/search?q=foo%26bar&client=");
}
void URITest::setUp()
{
}
@@ -816,6 +872,7 @@ CppUnit::Test* URITest::suite()
CppUnit_addTest(pSuite, URITest, testEncodeDecode);
CppUnit_addTest(pSuite, URITest, testOther);
CppUnit_addTest(pSuite, URITest, testFromPath);
CppUnit_addTest(pSuite, URITest, testQueryParameters);
return pSuite;
}

View File

@@ -36,6 +36,7 @@ public:
void testEncodeDecode();
void testOther();
void testFromPath();
void testQueryParameters();
void setUp();
void tearDown();

View File

@@ -2089,6 +2089,20 @@ void VarTest::testArrayToString()
}
void VarTest::testArrayToStringEscape()
{
std::string s1("\"quoted string\"");
Poco::Int8 s2(23);
std::vector<Var> s16;
s16.push_back(s1);
s16.push_back(s2);
Var a1(s16);
std::string res = a1.convert<std::string>();
std::string expected("[ \"\\\"quoted string\\\"\", 23 ]");
assert (res == expected);
}
void VarTest::testStructToString()
{
DynamicStruct aStruct;
@@ -2103,6 +2117,18 @@ void VarTest::testStructToString()
}
void VarTest::testStructToStringEscape()
{
DynamicStruct aStruct;
aStruct["Value"] = "Value with \" and \n";
Var a1(aStruct);
std::string res = a1.convert<std::string>();
std::string expected = "{ \"Value\" : \"Value with \\\" and \\n\" }";
assert (res == expected);
assert (aStruct.toString() == res);
}
void VarTest::testArrayOfStructsToString()
{
std::vector<Var> s16;
@@ -2592,7 +2618,9 @@ CppUnit::Test* VarTest::suite()
CppUnit_addTest(pSuite, VarTest, testDynamicStructString);
CppUnit_addTest(pSuite, VarTest, testDynamicStructInt);
CppUnit_addTest(pSuite, VarTest, testArrayToString);
CppUnit_addTest(pSuite, VarTest, testArrayToStringEscape);
CppUnit_addTest(pSuite, VarTest, testStructToString);
CppUnit_addTest(pSuite, VarTest, testStructToStringEscape);
CppUnit_addTest(pSuite, VarTest, testArrayOfStructsToString);
CppUnit_addTest(pSuite, VarTest, testStructWithArraysToString);
CppUnit_addTest(pSuite, VarTest, testJSONDeserializeString);

View File

@@ -59,7 +59,9 @@ public:
void testDynamicStructString();
void testDynamicStructInt();
void testArrayToString();
void testArrayToStringEscape();
void testStructToString();
void testStructToStringEscape();
void testArrayOfStructsToString();
void testStructWithArraysToString();
void testJSONDeserializeString();