trunk/branch integration: unit test integration

This commit is contained in:
Marian Krivos 2011-08-23 09:16:33 +00:00
parent fd733bcca4
commit 53eff41df8
48 changed files with 1939 additions and 697 deletions

View File

@ -1,7 +1,7 @@
//
// BinaryReaderWriterTest.cpp
//
// $Id: //poco/svn/Foundation/testsuite/src/BinaryReaderWriterTest.cpp#2 $
// $Id: //poco/1.4/Foundation/testsuite/src/BinaryReaderWriterTest.cpp#2 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -131,10 +131,16 @@ void BinaryReaderWriterTest::write(BinaryWriter& writer)
writer.write7BitEncoded((UInt64) 1000);
writer.write7BitEncoded((UInt64) 10000);
writer.write7BitEncoded((UInt64) 100000);
writer.write7BitEncoded((UInt64) 1000000);
writer.write7BitEncoded((UInt64) 1000000);
#endif
std::vector<int> vec;
vec.push_back(1);
vec.push_back(2);
vec.push_back(3);
writer << vec;
writer.writeRaw("RAW");
writer.writeRaw("RAW");
}
@ -224,11 +230,18 @@ void BinaryReaderWriterTest::read(BinaryReader& reader)
reader.read7BitEncoded(uint64v);
assert (uint64v == 100000);
reader.read7BitEncoded(uint64v);
assert (uint64v == 1000000);
assert (uint64v == 1000000);
#endif
reader.readRaw(3, str);
assert (str == "RAW");
std::vector<int> vec;
reader >> vec;
assert (vec.size() == 3);
assert (vec[0] == 1);
assert (vec[1] == 2);
assert (vec[2] == 3);
reader.readRaw(3, str);
assert (str == "RAW");
}

View File

@ -1,7 +1,7 @@
//
// CryptTestSuite.cpp
//
// $Id: //poco/svn/Foundation/testsuite/src/CryptTestSuite.cpp#2 $
// $Id: //poco/1.4/Foundation/testsuite/src/CryptTestSuite.cpp#2 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -31,7 +31,6 @@
#include "CryptTestSuite.h"
#include "MD2EngineTest.h"
#include "MD4EngineTest.h"
#include "MD5EngineTest.h"
#include "SHA1EngineTest.h"
@ -43,12 +42,11 @@
CppUnit::Test* CryptTestSuite::suite()
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("CryptTestTestSuite");
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("CryptTestSuite");
pSuite->addTest(MD2EngineTest::suite());
pSuite->addTest(MD4EngineTest::suite());
pSuite->addTest(MD5EngineTest::suite());
pSuite->addTest(SHA1EngineTest::suite());
pSuite->addTest(MD4EngineTest::suite());
pSuite->addTest(MD5EngineTest::suite());
pSuite->addTest(SHA1EngineTest::suite());
pSuite->addTest(HMACEngineTest::suite());
pSuite->addTest(DigestStreamTest::suite());
pSuite->addTest(RandomTest::suite());

View File

@ -47,10 +47,10 @@ using Poco::DateTimeFormatter;
DateTimeFormatterTest::DateTimeFormatterTest(const std::string& name): CppUnit::TestCase(name)
{
// Linker regresion SF #3288584
std::string message;
Poco::LocalDateTime now;
Poco::DateTimeFormatter::append(message,now,"%H:%M:%S.%i");
// Linker regresion SF #3288584
std::string message;
Poco::LocalDateTime now;
Poco::DateTimeFormatter::append(message,now,"%H:%M:%S.%i");
}
@ -74,9 +74,24 @@ void DateTimeFormatterTest::testISO8601()
}
void DateTimeFormatterTest::testISO8601Frac()
{
DateTime dt(2005, 1, 8, 12, 30, 00, 12, 34);
std::string str = DateTimeFormatter::format(dt, DateTimeFormat::ISO8601_FRAC_FORMAT);
assert (str == "2005-01-08T12:30:00.012034Z");
str = DateTimeFormatter::format(dt, DateTimeFormat::ISO8601_FRAC_FORMAT, 3600);
assert (str == "2005-01-08T12:30:00.012034+01:00");
str = DateTimeFormatter::format(dt, DateTimeFormat::ISO8601_FRAC_FORMAT, -3600);
assert (str == "2005-01-08T12:30:00.012034-01:00");
}
void DateTimeFormatterTest::testRFC822()
{
DateTime dt(2005, 1, 8, 12, 30, 00);
DateTime dt(2005, 1, 8, 12, 30, 00);
std::string str = DateTimeFormatter::format(dt, DateTimeFormat::RFC822_FORMAT);
assert (str == "Sat, 8 Jan 05 12:30:00 GMT");
@ -216,12 +231,13 @@ void DateTimeFormatterTest::tearDown()
CppUnit::Test* DateTimeFormatterTest::suite()
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("DateTimeFormatterTest");
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("DateTimeFormatterTest");
CppUnit_addTest(pSuite, DateTimeFormatterTest, testISO8601);
CppUnit_addTest(pSuite, DateTimeFormatterTest, testRFC822);
CppUnit_addTest(pSuite, DateTimeFormatterTest, testRFC1123);
CppUnit_addTest(pSuite, DateTimeFormatterTest, testHTTP);
CppUnit_addTest(pSuite, DateTimeFormatterTest, testISO8601);
CppUnit_addTest(pSuite, DateTimeFormatterTest, testISO8601Frac);
CppUnit_addTest(pSuite, DateTimeFormatterTest, testRFC822);
CppUnit_addTest(pSuite, DateTimeFormatterTest, testRFC1123);
CppUnit_addTest(pSuite, DateTimeFormatterTest, testHTTP);
CppUnit_addTest(pSuite, DateTimeFormatterTest, testRFC850);
CppUnit_addTest(pSuite, DateTimeFormatterTest, testRFC1036);
CppUnit_addTest(pSuite, DateTimeFormatterTest, testASCTIME);

View File

@ -44,12 +44,13 @@ class DateTimeFormatterTest: public CppUnit::TestCase
{
public:
DateTimeFormatterTest(const std::string& name);
~DateTimeFormatterTest();
~DateTimeFormatterTest();
void testISO8601();
void testRFC822();
void testRFC1123();
void testHTTP();
void testISO8601();
void testISO8601Frac();
void testRFC822();
void testRFC1123();
void testHTTP();
void testRFC850();
void testRFC1036();
void testASCTIME();

View File

@ -107,9 +107,135 @@ void DateTimeParserTest::testISO8601()
}
void DateTimeParserTest::testISO8601Frac()
{
int tzd;
DateTime dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00Z", tzd);
assert (dt.year() == 2005);
assert (dt.month() == 1);
assert (dt.day() == 8);
assert (dt.hour() == 12);
assert (dt.minute() == 30);
assert (dt.second() == 0);
assert (dt.millisecond() == 0);
assert (dt.microsecond() == 0);
assert (tzd == 0);
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00+01:00", tzd);
assert (dt.year() == 2005);
assert (dt.month() == 1);
assert (dt.day() == 8);
assert (dt.hour() == 12);
assert (dt.minute() == 30);
assert (dt.second() == 0);
assert (dt.millisecond() == 0);
assert (dt.microsecond() == 0);
assert (tzd == 3600);
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00-01:00", tzd);
assert (dt.year() == 2005);
assert (dt.month() == 1);
assert (dt.day() == 8);
assert (dt.hour() == 12);
assert (dt.minute() == 30);
assert (dt.second() == 0);
assert (dt.millisecond() == 0);
assert (dt.microsecond() == 0);
assert (tzd == -3600);
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00", tzd);
assert (dt.year() == 2005);
assert (dt.month() == 1);
assert (dt.day() == 8);
assert (dt.hour() == 12);
assert (dt.minute() == 30);
assert (dt.second() == 0);
assert (dt.millisecond() == 0);
assert (dt.microsecond() == 0);
assert (tzd == 0);
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08", tzd);
assert (dt.year() == 2005);
assert (dt.month() == 1);
assert (dt.day() == 8);
assert (dt.hour() == 0);
assert (dt.minute() == 0);
assert (dt.second() == 0);
assert (dt.millisecond() == 0);
assert (dt.microsecond() == 0);
assert (tzd == 0);
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00.1Z", tzd);
assert (dt.year() == 2005);
assert (dt.month() == 1);
assert (dt.day() == 8);
assert (dt.hour() == 12);
assert (dt.minute() == 30);
assert (dt.second() == 0);
assert (dt.millisecond() == 100);
assert (dt.microsecond() == 0);
assert (tzd == 0);
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00.123+01:00", tzd);
assert (dt.year() == 2005);
assert (dt.month() == 1);
assert (dt.day() == 8);
assert (dt.hour() == 12);
assert (dt.minute() == 30);
assert (dt.second() == 0);
assert (dt.millisecond() == 123);
assert (dt.microsecond() == 0);
assert (tzd == 3600);
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00.12345-01:00", tzd);
assert (dt.year() == 2005);
assert (dt.month() == 1);
assert (dt.day() == 8);
assert (dt.hour() == 12);
assert (dt.minute() == 30);
assert (dt.second() == 0);
assert (dt.millisecond() == 123);
assert (dt.microsecond() == 450);
assert (tzd == -3600);
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00", tzd);
assert (dt.year() == 2005);
assert (dt.month() == 1);
assert (dt.day() == 8);
assert (dt.hour() == 12);
assert (dt.minute() == 30);
assert (dt.second() == 0);
assert (dt.millisecond() == 0);
assert (dt.microsecond() == 0);
assert (tzd == 0);
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00.123456", tzd);
assert (dt.year() == 2005);
assert (dt.month() == 1);
assert (dt.day() == 8);
assert (dt.hour() == 12);
assert (dt.minute() == 30);
assert (dt.second() == 0);
assert (dt.millisecond() == 123);
assert (dt.microsecond() == 456);
assert (tzd == 0);
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08", tzd);
assert (dt.year() == 2005);
assert (dt.month() == 1);
assert (dt.day() == 8);
assert (dt.hour() == 0);
assert (dt.minute() == 0);
assert (dt.second() == 0);
assert (dt.millisecond() == 0);
assert (dt.microsecond() == 0);
assert (tzd == 0);
}
void DateTimeParserTest::testRFC822()
{
int tzd;
int tzd;
DateTime dt = DateTimeParser::parse(DateTimeFormat::RFC822_FORMAT, "Sat, 8 Jan 05 12:30:00 GMT", tzd);
assert (dt.year() == 2005);
assert (dt.month() == 1);
@ -541,12 +667,13 @@ void DateTimeParserTest::tearDown()
CppUnit::Test* DateTimeParserTest::suite()
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("DateTimeParserTest");
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("DateTimeParserTest");
CppUnit_addTest(pSuite, DateTimeParserTest, testISO8601);
CppUnit_addTest(pSuite, DateTimeParserTest, testRFC822);
CppUnit_addTest(pSuite, DateTimeParserTest, testRFC1123);
CppUnit_addTest(pSuite, DateTimeParserTest, testHTTP);
CppUnit_addTest(pSuite, DateTimeParserTest, testISO8601);
CppUnit_addTest(pSuite, DateTimeParserTest, testISO8601Frac);
CppUnit_addTest(pSuite, DateTimeParserTest, testRFC822);
CppUnit_addTest(pSuite, DateTimeParserTest, testRFC1123);
CppUnit_addTest(pSuite, DateTimeParserTest, testHTTP);
CppUnit_addTest(pSuite, DateTimeParserTest, testRFC850);
CppUnit_addTest(pSuite, DateTimeParserTest, testRFC1036);
CppUnit_addTest(pSuite, DateTimeParserTest, testASCTIME);

View File

@ -44,12 +44,13 @@ class DateTimeParserTest: public CppUnit::TestCase
{
public:
DateTimeParserTest(const std::string& name);
~DateTimeParserTest();
~DateTimeParserTest();
void testISO8601();
void testRFC822();
void testRFC1123();
void testHTTP();
void testISO8601();
void testISO8601Frac();
void testRFC822();
void testRFC1123();
void testHTTP();
void testRFC850();
void testRFC1036();
void testASCTIME();

View File

@ -394,10 +394,10 @@ void DateTimeTest::testRelational()
const DateTime& U = u;
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));
}
}
}

View File

@ -80,6 +80,8 @@ void FPETest::testClassify()
#pragma OPTIMIZE OFF
#elif defined(_MSC_VER)
#pragma optimize("", off)
#elif defined(__APPLE__)
#pragma GCC optimization_level 0
#endif
@ -129,6 +131,8 @@ void FPETest::testFlags()
#pragma OPTIMIZE ON
#elif defined(_MSC_VER)
#pragma optimize("", on)
#elif defined(__APPLE__)
#pragma GCC optimization_level reset
#endif

View File

@ -304,6 +304,27 @@ void FileStreamTest::testSeek()
}
void FileStreamTest::testMultiOpen()
{
Poco::FileStream str("test.txt", std::ios::trunc);
str << "0123456789\n";
str << "abcdefghij\n";
str << "klmnopqrst\n";
str.close();
std::string s;
str.open("test.txt", std::ios::in);
std::getline(str, s);
assert (s == "0123456789");
str.close();
str.open("test.txt", std::ios::in);
std::getline(str, s);
assert (s == "0123456789");
str.close();
}
void FileStreamTest::setUp()
{
}
@ -325,9 +346,10 @@ CppUnit::Test* FileStreamTest::suite()
CppUnit_addTest(pSuite, FileStreamTest, testOpenModeIn);
CppUnit_addTest(pSuite, FileStreamTest, testOpenModeOut);
CppUnit_addTest(pSuite, FileStreamTest, testOpenModeTrunc);
CppUnit_addTest(pSuite, FileStreamTest, testOpenModeAte);
CppUnit_addTest(pSuite, FileStreamTest, testOpenModeApp);
CppUnit_addTest(pSuite, FileStreamTest, testSeek);
CppUnit_addTest(pSuite, FileStreamTest, testOpenModeAte);
CppUnit_addTest(pSuite, FileStreamTest, testOpenModeApp);
CppUnit_addTest(pSuite, FileStreamTest, testSeek);
CppUnit_addTest(pSuite, FileStreamTest, testMultiOpen);
return pSuite;
return pSuite;
}

View File

@ -53,12 +53,13 @@ public:
void testOpenModeIn();
void testOpenModeOut();
void testOpenModeTrunc();
void testOpenModeAte();
void testOpenModeApp();
void testSeek();
void testOpenModeAte();
void testOpenModeApp();
void testSeek();
void testMultiOpen();
void setUp();
void tearDown();
void setUp();
void tearDown();
static CppUnit::Test* suite();

View File

@ -1,7 +1,7 @@
//
// FileTest.cpp
//
// $Id: //poco/Main/Foundation/testsuite/src/FileTest.cpp#16 $
// $Id: //poco/1.4/Foundation/testsuite/src/FileTest.cpp#1 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -60,20 +60,9 @@ FileTest::~FileTest()
}
void FileTest::testCreateFile()
{
File f("testfile.dat");
bool created = f.createFile();
assert (created);
assert (!f.isHidden());
created = f.createFile();
assert (!created);
}
void FileTest::testFileAttributes1()
{
File f("testfile.dat");
File f("testfile.dat");
assert (!f.exists());
try
@ -214,9 +203,20 @@ void FileTest::testFileAttributes1()
}
void FileTest::testCreateFile()
{
File f("testfile.dat");
bool created = f.createFile();
assert (created);
assert (!f.isHidden());
created = f.createFile();
assert (!created);
}
void FileTest::testFileAttributes2()
{
TemporaryFile f;
TemporaryFile f;
bool created = f.createFile();
Timestamp ts;
assert (created);
@ -248,14 +248,16 @@ void FileTest::testFileAttributes2()
void FileTest::testFileAttributes3()
{
#if defined(POCO_OS_FAMILY_UNIX)
File f("/dev/console");
#elif defined(POCO_OS_FAMILY_WINDOWS)
File f("CON");
File f("/dev/console");
#elif defined(POCO_OS_FAMILY_WINDOWS) && !defined(_WIN32_WCE)
File f("CON");
#endif
assert (f.isDevice());
assert (!f.isFile());
assert (!f.isDirectory());
#if !defined(_WIN32_WCE)
assert (f.isDevice());
assert (!f.isFile());
assert (!f.isDirectory());
#endif
}
@ -287,17 +289,24 @@ void FileTest::testCompare()
void FileTest::testRootDir()
{
#if defined(POCO_OS_FAMILY_WINDOWS)
File f1("/");
File f2("c:/");
File f3("c:\\");
#if defined(_WIN32_WCE)
File f1("\\");
File f2("/");
assert (f1.exists());
assert (f2.exists());
#else
File f1("/");
File f2("c:/");
File f3("c:\\");
File f4("\\");
assert (f1.exists());
assert (f2.exists());
assert (f3.exists());
assert (f4.exists());
assert (f2.exists());
assert (f3.exists());
assert (f4.exists());
#endif
#else
File f1("/");
assert (f1.exists());
File f1("/");
assert (f1.exists());
#endif
}

View File

@ -1,45 +1,32 @@
//
// FormatTest.cpp
//
// $Id: //poco/svn/Foundation/testsuite/src/FormatTest.cpp#2 $
// $Id: //poco/1.4/Foundation/testsuite/src/FormatTest.cpp#1 $
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Redistributions in any form must be accompanied by information on
// how to obtain complete source code for this software and any
// accompanying software that uses this software. The source code
// must either be included in the distribution or be available for no
// more than the cost of distribution plus a nominal fee, and must be
// freely redistributable under reasonable conditions. For an
// executable file, complete source code means the source code for all
// modules it contains. It does not include source code for modules or
// files that typically accompany the major components of the operating
// system on which the executable file runs.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
@ -76,7 +63,7 @@ void FormatTest::testChar()
assert (s == " a");
s = format("%-2c", c);
assert (s == "a ");
try
{
s = format("%c", std::string("foo"));
@ -113,7 +100,7 @@ void FormatTest::testInt()
assert (s == " 42");
s = format("%04hu", hu);
assert (s == "0042");
unsigned x = 0x42;
s = format("%x", x);
assert (s == "42");
@ -137,7 +124,7 @@ void FormatTest::testInt()
assert (s == " 42");
s = format("%04u", u);
assert (s == "0042");
long l = 42;
s = format("%ld", l);
assert (s == "42");
@ -153,7 +140,7 @@ void FormatTest::testInt()
assert (s == " 42");
s = format("%04lu", ul);
assert (s == "0042");
unsigned long xl = 0x42;
s = format("%lx", xl);
assert (s == "42");
@ -161,7 +148,7 @@ void FormatTest::testInt()
assert (s == " 42");
s = format("%04lx", xl);
assert (s == "0042");
Int64 i64 = 42;
s = format("%Ld", i64);
assert (s == "42");
@ -169,7 +156,7 @@ void FormatTest::testInt()
assert (s == " 42");
s = format("%04Ld", i64);
assert (s == "0042");
UInt64 ui64 = 42;
s = format("%Lu", ui64);
assert (s == "42");
@ -177,13 +164,13 @@ void FormatTest::testInt()
assert (s == " 42");
s = format("%04Lu", ui64);
assert (s == "0042");
x = 0xaa;
s = format("%x", x);
assert (s == "aa");
s = format("%X", x);
assert (s == "AA");
i = 42;
s = format("%+d", i);
assert (s == "+42");
@ -196,11 +183,11 @@ void FormatTest::testInt()
s = format("%d", i);
assert (s == "-42");
x = 0x42;
s = format("%#x", x);
assert (s == "0x42");
try
{
s = format("%d", l);
@ -245,7 +232,7 @@ void FormatTest::testAnyInt()
char c = 42;
std::string s(format("%?i", c));
assert (s == "42");
bool b = true;
s = format("%?i", b);
assert (s == "1");
@ -253,35 +240,35 @@ void FormatTest::testAnyInt()
signed char sc = -42;
s = format("%?i", sc);
assert (s == "-42");
unsigned char uc = 65;
s = format("%?i", uc);
assert (s == "65");
short ss = -134;
s = format("%?i", ss);
assert (s == "-134");
unsigned short us = 200;
s = format("%?i", us);
assert (s == "200");
int i = -12345;
s = format("%?i", i);
assert (s == "-12345");
unsigned ui = 12345;
s = format("%?i", ui);
assert (s == "12345");
long l = -54321;
s = format("%?i", l);
assert (s == "-54321");
unsigned long ul = 54321;
s = format("%?i", ul);
assert (s == "54321");
Int64 i64 = -12345678;
s = format("%?i", i64);
assert (s == "-12345678");
@ -289,7 +276,7 @@ void FormatTest::testAnyInt()
UInt64 ui64 = 12345678;
s = format("%?i", ui64);
assert (s == "12345678");
ss = 0x42;
s = format("%?x", ss);
assert (s == "42");
@ -299,6 +286,7 @@ void FormatTest::testAnyInt()
assert (s == "42");
}
void FormatTest::testFloatFix()
{
double d = 1.5;
@ -312,10 +300,10 @@ void FormatTest::testFloatFix()
assert (s == " 1.50");
s = format("%-6.2f", d);
assert (s == "1.50 ");
float f = 1.5;
s = format("%hf", f);
assert (s.find("1.50") == 0);
float f = 1.5;
s = format("%hf", f);
assert (s.find("1.50") == 0);
s = format("%.0f", 1.0);
assert (s == "1");
@ -347,7 +335,7 @@ void FormatTest::testString()
std::string foo("foo");
std::string s(format("%s", foo));
assert (s == "foo");
s = format("%5s", foo);
assert (s == " foo");
@ -369,7 +357,7 @@ void FormatTest::testMultiple()
s = format("%%%d%%%d%%%d", 1, 2, 3);
assert (s == "%1%2%3");
s = format("%d%d%d%d", 1, 2, 3, 4);
assert (s == "1234");
@ -381,6 +369,19 @@ void FormatTest::testMultiple()
}
void FormatTest::testIndex()
{
std::string s(format("%[1]d%[0]d", 1, 2));
assert (s == "21");
s = format("%[5]d%[4]d%[3]d%[2]d%[1]d%[0]d", 1, 2, 3, 4, 5, 6);
assert (s == "654321");
s = format("%%%[1]d%%%[2]d%%%d", 1, 2, 3);
assert (s == "%2%3%1");
}
void FormatTest::setUp()
{
}
@ -400,9 +401,10 @@ CppUnit::Test* FormatTest::suite()
CppUnit_addTest(pSuite, FormatTest, testInt);
CppUnit_addTest(pSuite, FormatTest, testAnyInt);
CppUnit_addTest(pSuite, FormatTest, testFloatFix);
CppUnit_addTest(pSuite, FormatTest, testFloatSci);
CppUnit_addTest(pSuite, FormatTest, testString);
CppUnit_addTest(pSuite, FormatTest, testMultiple);
CppUnit_addTest(pSuite, FormatTest, testFloatSci);
CppUnit_addTest(pSuite, FormatTest, testString);
CppUnit_addTest(pSuite, FormatTest, testMultiple);
CppUnit_addTest(pSuite, FormatTest, testIndex);
return pSuite;
return pSuite;
}

View File

@ -64,12 +64,13 @@ public:
void testBool();
void testAnyInt();
void testFloatFix();
void testFloatSci();
void testString();
void testMultiple();
void testFloatSci();
void testString();
void testMultiple();
void testIndex();
void setUp();
void tearDown();
void setUp();
void tearDown();
static CppUnit::Test* suite();

View File

@ -32,7 +32,6 @@
#include "FoundationTestSuite.h"
#include "CoreTestSuite.h"
#include "DynamicTestSuite.h"
#include "DateTimeTestSuite.h"
#include "StreamsTestSuite.h"
#include "CryptTestSuite.h"
@ -44,7 +43,9 @@
#include "UUIDTestSuite.h"
#include "TextTestSuite.h"
#include "URITestSuite.h"
#if !defined(POCO_VXWORKS)
#include "ProcessesTestSuite.h"
#endif
#include "TaskTestSuite.h"
#include "EventTestSuite.h"
#include "CacheTestSuite.h"
@ -53,25 +54,26 @@
CppUnit::Test* FoundationTestSuite::suite()
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("FoundationTestSuite");
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("FoundationTestSuite");
pSuite->addTest(CoreTestSuite::suite());
pSuite->addTest(DynamicTestSuite::suite());
pSuite->addTest(DateTimeTestSuite::suite());
pSuite->addTest(StreamsTestSuite::suite());
pSuite->addTest(CryptTestSuite::suite());
pSuite->addTest(CoreTestSuite::suite());
pSuite->addTest(DateTimeTestSuite::suite());
pSuite->addTest(StreamsTestSuite::suite());
pSuite->addTest(CryptTestSuite::suite());
pSuite->addTest(NotificationsTestSuite::suite());
pSuite->addTest(ThreadingTestSuite::suite());
pSuite->addTest(SharedLibraryTestSuite::suite());
pSuite->addTest(LoggingTestSuite::suite());
pSuite->addTest(FilesystemTestSuite::suite());
pSuite->addTest(UUIDTestSuite::suite());
pSuite->addTest(TextTestSuite::suite());
pSuite->addTest(URITestSuite::suite());
pSuite->addTest(ProcessesTestSuite::suite());
pSuite->addTest(TaskTestSuite::suite());
pSuite->addTest(EventTestSuite::suite());
pSuite->addTest(CacheTestSuite::suite());
pSuite->addTest(UUIDTestSuite::suite());
pSuite->addTest(TextTestSuite::suite());
pSuite->addTest(URITestSuite::suite());
#if !defined(POCO_VXWORKS)
pSuite->addTest(ProcessesTestSuite::suite());
#endif
pSuite->addTest(TaskTestSuite::suite());
pSuite->addTest(EventTestSuite::suite());
pSuite->addTest(CacheTestSuite::suite());
pSuite->addTest(HashingTestSuite::suite());
return pSuite;

View File

@ -1,7 +1,7 @@
//
// GlobTest.cpp
//
// $Id: //poco/1.3/Foundation/testsuite/src/GlobTest.cpp#2 $
// $Id: //poco/1.4/Foundation/testsuite/src/GlobTest.cpp#1 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -467,22 +467,41 @@ void GlobTest::testGlob()
translatePaths(files);
assert (files.size() == 3);
assert (files.find("globtest/include/") != files.end());
assert (files.find("globtest/src/") != files.end());
assert (files.find("globtest/testsuite/") != files.end());
assert (files.find("globtest/src/") != files.end());
assert (files.find("globtest/testsuite/") != files.end());
files.clear();
Glob::glob("../*/globtest/*/", files);
translatePaths(files);
assert (files.size() == 3);
File dir("globtest");
dir.remove(true);
#if !defined(_WIN32_WCE)
// won't work if current directory is root dir
files.clear();
Glob::glob("../*/globtest/*/", files);
translatePaths(files);
assert (files.size() == 3);
#endif
File dir("globtest");
dir.remove(true);
}
void GlobTest::testMatchEmptyPattern()
{
// Run the empty pattern against a number of subjects with all different match options
const std::string empty;
assert (!Glob(empty, Glob::GLOB_DEFAULT).match("subject"));
assert (Glob(empty, Glob::GLOB_DEFAULT).match(empty));
assert (!Glob(empty, Glob::GLOB_DOT_SPECIAL).match("subject"));
assert (Glob(empty, Glob::GLOB_DOT_SPECIAL).match(empty));
assert (!Glob(empty, Glob::GLOB_CASELESS).match("subject"));
assert (Glob(empty, Glob::GLOB_CASELESS).match(empty));
}
void GlobTest::createFile(const std::string& path)
{
Path p(path, Path::PATH_UNIX);
Path p(path, Path::PATH_UNIX);
File dir(p.parent());
dir.createDirectories();
std::ofstream ostr(path.c_str());
@ -521,9 +540,10 @@ CppUnit::Test* GlobTest::suite()
CppUnit_addTest(pSuite, GlobTest, testMatchQM);
CppUnit_addTest(pSuite, GlobTest, testMatchAsterisk);
CppUnit_addTest(pSuite, GlobTest, testMatchRange);
CppUnit_addTest(pSuite, GlobTest, testMisc);
CppUnit_addTest(pSuite, GlobTest, testCaseless);
CppUnit_addTest(pSuite, GlobTest, testGlob);
CppUnit_addTest(pSuite, GlobTest, testMisc);
CppUnit_addTest(pSuite, GlobTest, testCaseless);
CppUnit_addTest(pSuite, GlobTest, testGlob);
CppUnit_addTest(pSuite, GlobTest, testMatchEmptyPattern);
return pSuite;
return pSuite;
}

View File

@ -51,12 +51,13 @@ public:
void testMatchQM();
void testMatchAsterisk();
void testMatchRange();
void testMisc();
void testGlob();
void testCaseless();
void testMisc();
void testGlob();
void testCaseless();
void testMatchEmptyPattern();
void setUp();
void tearDown();
void setUp();
void tearDown();
static CppUnit::Test* suite();

View File

@ -1,7 +1,7 @@
//
// HashSetTest.cpp
//
// $Id: //poco/svn/Foundation/testsuite/src/HashSetTest.cpp#2 $
// $Id: //poco/1.4/Foundation/testsuite/src/HashSetTest.cpp#1 $
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -37,6 +37,7 @@
#include <set>
using Poco::Hash;
using Poco::HashSet;
@ -52,128 +53,128 @@ HashSetTest::~HashSetTest()
void HashSetTest::testInsert()
{
const int N = 1000;
const int N = 1000;
HashSet<int> hs;
assert (hs.empty());
for (int i = 0; i < N; ++i)
{
std::pair<HashSet<int>::Iterator, bool> res = hs.insert(i);
assert (*res.first == i);
assert (res.second);
HashSet<int>::Iterator it = hs.find(i);
assert (it != hs.end());
assert (*it == i);
assert (hs.size() == i + 1);
HashSet<int, Hash<int> > hs;
assert (hs.empty());
for (int i = 0; i < N; ++i)
{
std::pair<HashSet<int, Hash<int> >::Iterator, bool> res = hs.insert(i);
assert (*res.first == i);
assert (res.second);
HashSet<int, Hash<int> >::Iterator it = hs.find(i);
assert (it != hs.end());
assert (*it == i);
assert (hs.size() == i + 1);
}
assert (!hs.empty());
for (int i = 0; i < N; ++i)
{
HashSet<int>::Iterator it = hs.find(i);
assert (it != hs.end());
assert (*it == i);
}
for (int i = 0; i < N; ++i)
{
std::pair<HashSet<int>::Iterator, bool> res = hs.insert(i);
assert (*res.first == i);
assert (!res.second);
}
for (int i = 0; i < N; ++i)
{
HashSet<int, Hash<int> >::Iterator it = hs.find(i);
assert (it != hs.end());
assert (*it == i);
}
for (int i = 0; i < N; ++i)
{
std::pair<HashSet<int, Hash<int> >::Iterator, bool> res = hs.insert(i);
assert (*res.first == i);
assert (!res.second);
}
}
void HashSetTest::testErase()
{
const int N = 1000;
const int N = 1000;
HashSet<int> hs;
HashSet<int, Hash<int> > hs;
for (int i = 0; i < N; ++i)
{
for (int i = 0; i < N; ++i)
{
hs.insert(i);
}
assert (hs.size() == N);
for (int i = 0; i < N; i += 2)
{
hs.erase(i);
HashSet<int>::Iterator it = hs.find(i);
assert (it == hs.end());
}
assert (hs.size() == N/2);
for (int i = 0; i < N; i += 2)
{
HashSet<int>::Iterator it = hs.find(i);
assert (it == hs.end());
}
for (int i = 1; i < N; i += 2)
{
HashSet<int>::Iterator it = hs.find(i);
assert (it != hs.end());
assert (*it == i);
}
for (int i = 0; i < N; i += 2)
{
hs.erase(i);
HashSet<int, Hash<int> >::Iterator it = hs.find(i);
assert (it == hs.end());
}
assert (hs.size() == N/2);
for (int i = 0; i < N; i += 2)
{
HashSet<int, Hash<int> >::Iterator it = hs.find(i);
assert (it == hs.end());
}
for (int i = 1; i < N; i += 2)
{
HashSet<int, Hash<int> >::Iterator it = hs.find(i);
assert (it != hs.end());
assert (*it == i);
}
for (int i = 0; i < N; i += 2)
{
hs.insert(i);
}
for (int i = 0; i < N; ++i)
{
HashSet<int>::Iterator it = hs.find(i);
assert (it != hs.end());
assert (*it == i);
}
for (int i = 0; i < N; ++i)
{
HashSet<int, Hash<int> >::Iterator it = hs.find(i);
assert (it != hs.end());
assert (*it == i);
}
}
void HashSetTest::testIterator()
{
const int N = 1000;
const int N = 1000;
HashSet<int> hs;
HashSet<int, Hash<int> > hs;
for (int i = 0; i < N; ++i)
{
for (int i = 0; i < N; ++i)
{
hs.insert(i);
}
std::set<int> values;
HashSet<int>::Iterator it = hs.begin();
while (it != hs.end())
{
assert (values.find(*it) == values.end());
}
std::set<int> values;
HashSet<int, Hash<int> >::Iterator it = hs.begin();
while (it != hs.end())
{
assert (values.find(*it) == values.end());
values.insert(*it);
++it;
}
assert (values.size() == N);
}
void HashSetTest::testConstIterator()
{
const int N = 1000;
const int N = 1000;
HashSet<int> hs;
HashSet<int, Hash<int> > hs;
for (int i = 0; i < N; ++i)
{
for (int i = 0; i < N; ++i)
{
hs.insert(i);
}
std::set<int> values;
HashSet<int>::ConstIterator it = hs.begin();
while (it != hs.end())
{
assert (values.find(*it) == values.end());
}
std::set<int> values;
HashSet<int, Hash<int> >::ConstIterator it = hs.begin();
while (it != hs.end())
{
assert (values.find(*it) == values.end());
values.insert(*it);
++it;
}

View File

@ -1,7 +1,7 @@
//
// LinearHashTableTest.cpp
//
// $Id: //poco/svn/Foundation/testsuite/src/LinearHashTableTest.cpp#2 $
// $Id: //poco/1.4/Foundation/testsuite/src/LinearHashTableTest.cpp#1 $
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -42,6 +42,7 @@
using Poco::LinearHashTable;
using Poco::Hash;
using Poco::HashTable;
using Poco::Stopwatch;
using Poco::NumberFormatter;
@ -59,104 +60,107 @@ LinearHashTableTest::~LinearHashTableTest()
void LinearHashTableTest::testInsert()
{
const int N = 1000;
const int N = 1000;
LinearHashTable<int> ht;
assert (ht.empty());
for (int i = 0; i < N; ++i)
{
std::pair<LinearHashTable<int>::Iterator, bool> res = ht.insert(i);
assert (*res.first == i);
assert (res.second);
LinearHashTable<int>::Iterator it = ht.find(i);
assert (it != ht.end());
assert (*it == i);
assert (ht.size() == i + 1);
}
assert (!ht.empty());
for (int i = 0; i < N; ++i)
{
LinearHashTable<int>::Iterator it = ht.find(i);
assert (it != ht.end());
assert (*it == i);
}
for (int i = 0; i < N; ++i)
{
std::pair<LinearHashTable<int>::Iterator, bool> res = ht.insert(i);
assert (*res.first == i);
assert (!res.second);
}
LinearHashTable<int, Hash<int> > ht;
assert (ht.empty());
for (int i = 0; i < N; ++i)
{
std::pair<LinearHashTable<int, Hash<int> >::Iterator, bool> res = ht.insert(i);
assert (*res.first == i);
assert (res.second);
LinearHashTable<int, Hash<int> >::Iterator it = ht.find(i);
assert (it != ht.end());
assert (*it == i);
assert (ht.size() == i + 1);
}
assert (ht.buckets() == N + 1);
assert (!ht.empty());
for (int i = 0; i < N; ++i)
{
LinearHashTable<int, Hash<int> >::Iterator it = ht.find(i);
assert (it != ht.end());
assert (*it == i);
}
for (int i = 0; i < N; ++i)
{
std::pair<LinearHashTable<int, Hash<int> >::Iterator, bool> res = ht.insert(i);
assert (*res.first == i);
assert (!res.second);
assert (ht.size() == N);
assert (ht.buckets() == N + 1);
}
}
void LinearHashTableTest::testErase()
{
const int N = 1000;
const int N = 1000;
LinearHashTable<int> ht;
LinearHashTable<int, Hash<int> > ht;
for (int i = 0; i < N; ++i)
{
for (int i = 0; i < N; ++i)
{
ht.insert(i);
}
assert (ht.size() == N);
for (int i = 0; i < N; i += 2)
{
ht.erase(i);
LinearHashTable<int>::Iterator it = ht.find(i);
assert (it == ht.end());
}
assert (ht.size() == N/2);
for (int i = 0; i < N; i += 2)
{
LinearHashTable<int>::Iterator it = ht.find(i);
assert (it == ht.end());
}
for (int i = 1; i < N; i += 2)
{
LinearHashTable<int>::Iterator it = ht.find(i);
assert (it != ht.end());
assert (*it == i);
}
for (int i = 0; i < N; i += 2)
{
ht.erase(i);
LinearHashTable<int, Hash<int> >::Iterator it = ht.find(i);
assert (it == ht.end());
}
assert (ht.size() == N/2);
for (int i = 0; i < N; i += 2)
{
LinearHashTable<int, Hash<int> >::Iterator it = ht.find(i);
assert (it == ht.end());
}
for (int i = 1; i < N; i += 2)
{
LinearHashTable<int, Hash<int> >::Iterator it = ht.find(i);
assert (it != ht.end());
assert (*it == i);
}
for (int i = 0; i < N; i += 2)
{
ht.insert(i);
}
for (int i = 0; i < N; ++i)
{
LinearHashTable<int>::Iterator it = ht.find(i);
assert (it != ht.end());
assert (*it == i);
}
for (int i = 0; i < N; ++i)
{
LinearHashTable<int, Hash<int> >::Iterator it = ht.find(i);
assert (it != ht.end());
assert (*it == i);
}
}
void LinearHashTableTest::testIterator()
{
const int N = 1000;
const int N = 1000;
LinearHashTable<int> ht;
LinearHashTable<int, Hash<int> > ht;
for (int i = 0; i < N; ++i)
{
for (int i = 0; i < N; ++i)
{
ht.insert(i);
}
std::set<int> values;
LinearHashTable<int>::Iterator it = ht.begin();
while (it != ht.end())
{
assert (values.find(*it) == values.end());
}
std::set<int> values;
LinearHashTable<int, Hash<int> >::Iterator it = ht.begin();
while (it != ht.end())
{
assert (values.find(*it) == values.end());
values.insert(*it);
++it;
}
@ -167,33 +171,33 @@ void LinearHashTableTest::testIterator()
void LinearHashTableTest::testConstIterator()
{
const int N = 1000;
const int N = 1000;
LinearHashTable<int> ht;
LinearHashTable<int, Hash<int> > ht;
for (int i = 0; i < N; ++i)
{
for (int i = 0; i < N; ++i)
{
ht.insert(i);
}
std::set<int> values;
LinearHashTable<int>::ConstIterator it = ht.begin();
while (it != ht.end())
{
assert (values.find(*it) == values.end());
}
std::set<int> values;
LinearHashTable<int, Hash<int> >::ConstIterator it = ht.begin();
while (it != ht.end())
{
assert (values.find(*it) == values.end());
values.insert(*it);
++it;
}
assert (values.size() == N);
values.clear();
const LinearHashTable<int> cht(ht);
assert (values.size() == N);
values.clear();
const LinearHashTable<int, Hash<int> > cht(ht);
LinearHashTable<int>::ConstIterator cit = cht.begin();
while (cit != cht.end())
{
assert (values.find(*cit) == values.end());
LinearHashTable<int, Hash<int> >::ConstIterator cit = cht.begin();
while (cit != cht.end())
{
assert (values.find(*cit) == values.end());
values.insert(*cit);
++cit;
}
@ -205,13 +209,13 @@ void LinearHashTableTest::testConstIterator()
void LinearHashTableTest::testPerformanceInt()
{
const int N = 5000000;
Stopwatch sw;
Stopwatch sw;
{
LinearHashTable<int> lht(N);
sw.start();
for (int i = 0; i < N; ++i)
{
{
LinearHashTable<int, Hash<int> > lht(N);
sw.start();
for (int i = 0; i < N; ++i)
{
lht.insert(i);
}
sw.stop();
@ -282,13 +286,13 @@ void LinearHashTableTest::testPerformanceStr()
for (int i = 0; i < N; ++i)
{
values.push_back(NumberFormatter::format0(i, 8));
}
}
{
LinearHashTable<std::string> lht(N);
sw.start();
for (int i = 0; i < N; ++i)
{
{
LinearHashTable<std::string, Hash<std::string> > lht(N);
sw.start();
for (int i = 0; i < N; ++i)
{
lht.insert(values[i]);
}
sw.stop();

View File

@ -1,7 +1,7 @@
//
// LocalDateTimeTest.cpp
//
// $Id: //poco/svn/Foundation/testsuite/src/LocalDateTimeTest.cpp#3 $
// $Id: //poco/1.4/Foundation/testsuite/src/LocalDateTimeTest.cpp#1 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -42,13 +42,18 @@
#include "Poco/DateTimeFormatter.h"
#include <ctime>
#include <iostream>
#if defined(_WIN32_WCE)
#include "wce_time.h"
#endif
using Poco::LocalDateTime;
using Poco::DateTime;
using Poco::Timestamp;
using Poco::Timespan;
using Poco::Timezone;
#ifndef _WIN32_WCE
using std::strftime;
#endif
LocalDateTimeTest::LocalDateTimeTest(const std::string& name): CppUnit::TestCase(name)
@ -379,9 +384,10 @@ void LocalDateTimeTest::testSwap()
void LocalDateTimeTest::testTimezone()
{
std::time_t tINCREMENT = (30 * 24 * 60 * 60); // 30 days
Timespan tsINCREMENT(30*Timespan::DAYS);
LocalDateTime now;
#if !defined(_WIN32_WCE)
std::time_t tINCREMENT = (30 * 24 * 60 * 60); // 30 days
Timespan tsINCREMENT(30*Timespan::DAYS);
LocalDateTime now;
std::time_t t = std::time(NULL);
std::tm then;
bool foundDST = false;
@ -458,9 +464,10 @@ void LocalDateTimeTest::testTimezone()
{
std::cerr
<< __FILE__ << ":" << __LINE__
<< " - failed to locate DST boundary, timezone test skipped."
<< std::endl;
}
<< " - failed to locate DST boundary, timezone test skipped."
<< std::endl;
}
#endif
}

View File

@ -93,13 +93,13 @@ LoggingFactoryTest::~LoggingFactoryTest()
void LoggingFactoryTest::testBuiltins()
{
LoggingFactory& fact = LoggingFactory::defaultFactory();
AutoPtr<Channel> pConsoleChannel = fact.createChannel("ConsoleChannel");
#if defined(_WIN32)
assert (dynamic_cast<Poco::WindowsConsoleChannel*>(pConsoleChannel.get()) != 0);
LoggingFactory& fact = LoggingFactory::defaultFactory();
AutoPtr<Channel> pConsoleChannel = fact.createChannel("ConsoleChannel");
#if defined(_WIN32) && !defined(_WIN32_WCE)
assert (dynamic_cast<Poco::WindowsConsoleChannel*>(pConsoleChannel.get()) != 0);
#else
assert (dynamic_cast<ConsoleChannel*>(pConsoleChannel.get()) != 0);
assert (dynamic_cast<ConsoleChannel*>(pConsoleChannel.get()) != 0);
#endif
AutoPtr<Channel> pFileChannel = fact.createChannel("FileChannel");

View File

@ -0,0 +1,128 @@
//
// MemoryStreamTest.cpp
//
// $Id: //poco/1.4/Foundation/testsuite/src/MemoryStreamTest.cpp#2 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "MemoryStreamTest.h"
#include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h"
#include "Poco/MemoryStream.h"
using Poco::MemoryInputStream;
using Poco::MemoryOutputStream;
MemoryStreamTest::MemoryStreamTest(const std::string& name): CppUnit::TestCase(name)
{
}
MemoryStreamTest::~MemoryStreamTest()
{
}
void MemoryStreamTest::testInput()
{
const char* data = "This is a test";
MemoryInputStream istr1(data, 14);
int c = istr1.get();
assert (c == 'T');
c = istr1.get();
assert (c == 'h');
std::string str;
istr1 >> str;
assert (str == "is");
char buffer[32];
istr1.read(buffer, sizeof(buffer));
assert (istr1.gcount() == 10);
buffer[istr1.gcount()] = 0;
assert (std::string(" is a test") == buffer);
const char* data2 = "123";
MemoryInputStream istr2(data2, 3);
c = istr2.get();
assert (c == '1');
assert (istr2.good());
c = istr2.get();
assert (c == '2');
istr2.unget();
c = istr2.get();
assert (c == '2');
assert (istr2.good());
c = istr2.get();
assert (c == '3');
assert (istr2.good());
c = istr2.get();
assert (c == -1);
assert (istr2.eof());
}
void MemoryStreamTest::testOutput()
{
char output[64];
MemoryOutputStream ostr1(output, 64);
ostr1 << "This is a test " << 42 << std::ends;
assert (ostr1.charsWritten() == 18);
assert (std::string("This is a test 42") == output);
char output2[4];
MemoryOutputStream ostr2(output2, 4);
ostr2 << "test";
assert (ostr2.good());
ostr2 << 'x';
assert (ostr2.fail());
}
void MemoryStreamTest::setUp()
{
}
void MemoryStreamTest::tearDown()
{
}
CppUnit::Test* MemoryStreamTest::suite()
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("MemoryStreamTest");
CppUnit_addTest(pSuite, MemoryStreamTest, testInput);
CppUnit_addTest(pSuite, MemoryStreamTest, testOutput);
return pSuite;
}

View File

@ -0,0 +1,61 @@
//
// MemoryStreamTest.h
//
// $Id: //poco/1.4/Foundation/testsuite/src/MemoryStreamTest.h#1 $
//
// Definition of the MemoryStreamTest class.
//
// Copyright (c) 2009, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef MemoryStreamTest_INCLUDED
#define MemoryStreamTest_INCLUDED
#include "Poco/Foundation.h"
#include "CppUnit/TestCase.h"
class MemoryStreamTest: public CppUnit::TestCase
{
public:
MemoryStreamTest(const std::string& name);
~MemoryStreamTest();
void testInput();
void testOutput();
void setUp();
void tearDown();
static CppUnit::Test* suite();
private:
};
#endif // MemoryStreamTest_INCLUDED

View File

@ -1,7 +1,7 @@
//
// NotificationCenterTest.cpp
//
// $Id: //poco/svn/Foundation/testsuite/src/NotificationCenterTest.cpp#2 $
// $Id: //poco/1.4/Foundation/testsuite/src/NotificationCenterTest.cpp#1 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -70,26 +70,34 @@ void NotificationCenterTest::test1()
void NotificationCenterTest::test2()
{
NotificationCenter nc;
nc.addObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
nc.postNotification(new Notification);
assert (_set.size() == 1);
assert (_set.find("handle1") != _set.end());
nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
NotificationCenter nc;
nc.addObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
assert (nc.hasObservers());
assert (nc.countObservers() == 1);
nc.postNotification(new Notification);
assert (_set.size() == 1);
assert (_set.find("handle1") != _set.end());
nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
assert (!nc.hasObservers());
assert (nc.countObservers() == 0);
}
void NotificationCenterTest::test3()
{
NotificationCenter nc;
nc.addObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
nc.addObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle2));
nc.postNotification(new Notification);
assert (_set.size() == 2);
assert (_set.find("handle1") != _set.end());
assert (_set.find("handle2") != _set.end());
nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle2));
NotificationCenter nc;
nc.addObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
nc.addObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle2));
assert (nc.hasObservers());
assert (nc.countObservers() == 2);
nc.postNotification(new Notification);
assert (_set.size() == 2);
assert (_set.find("handle1") != _set.end());
assert (_set.find("handle2") != _set.end());
nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle2));
assert (!nc.hasObservers());
assert (nc.countObservers() == 0);
}

View File

@ -12,14 +12,14 @@
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
@ -60,13 +60,13 @@ void NumberFormatterTest::testFormat()
assert (NumberFormatter::format((unsigned) 123) == "123");
assert (NumberFormatter::format((unsigned) 123, 5) == " 123");
assert (NumberFormatter::format0((unsigned) 123, 5) == "00123");
assert (NumberFormatter::format((long) 123) == "123");
assert (NumberFormatter::format((long) -123) == "-123");
assert (NumberFormatter::format((long) -123, 5) == " -123");
assert (NumberFormatter::format((unsigned long) 123) == "123");
assert (NumberFormatter::format((unsigned long) 123, 5) == " 123");
assert (NumberFormatter::format((unsigned long) 123, 5) == " 123");
#if defined(POCO_HAVE_INT64)
assert (NumberFormatter::format((Int64) 123) == "123");
@ -74,7 +74,7 @@ void NumberFormatterTest::testFormat()
assert (NumberFormatter::format((Int64) -123, 5) == " -123");
assert (NumberFormatter::format((UInt64) 123) == "123");
assert (NumberFormatter::format((UInt64) 123, 5) == " 123");
assert (NumberFormatter::format((UInt64) 123, 5) == " 123");
#endif
if (sizeof(void*) == 4)
@ -85,17 +85,17 @@ void NumberFormatterTest::testFormat()
{
assert (NumberFormatter::format((void*) 0x12345678) == "0000000012345678");
}
assert (NumberFormatter::format(12.25) == "12.25");
assert (NumberFormatter::format(12.25, 4) == "12.2500");
assert (NumberFormatter::format(12.25, 8, 4) == " 12.2500");
assert (NumberFormatter::format(12.25) == "12.25");
assert (NumberFormatter::format(12.25, 4) == "12.2500");
assert (NumberFormatter::format(12.25, 8, 4) == " 12.2500");
assert (NumberFormatter::format(true, NumberFormatter::FMT_TRUE_FALSE) == "true");
assert (NumberFormatter::format(false, NumberFormatter::FMT_TRUE_FALSE) == "false");
assert (NumberFormatter::format(true, NumberFormatter::FMT_YES_NO) == "yes");
assert (NumberFormatter::format(false, NumberFormatter::FMT_YES_NO) == "no");
assert (NumberFormatter::format(true, NumberFormatter::FMT_ON_OFF) == "on");
assert (NumberFormatter::format(false, NumberFormatter::FMT_ON_OFF) == "off");
assert (NumberFormatter::format(true, NumberFormatter::FMT_TRUE_FALSE) == "true");
assert (NumberFormatter::format(false, NumberFormatter::FMT_TRUE_FALSE) == "false");
assert (NumberFormatter::format(true, NumberFormatter::FMT_YES_NO) == "yes");
assert (NumberFormatter::format(false, NumberFormatter::FMT_YES_NO) == "no");
assert (NumberFormatter::format(true, NumberFormatter::FMT_ON_OFF) == "on");
assert (NumberFormatter::format(false, NumberFormatter::FMT_ON_OFF) == "off");
}
@ -151,6 +151,20 @@ void NumberFormatterTest::testFormatHex()
}
void NumberFormatterTest::testFormatFloat()
{
std::string s(NumberFormatter::format(1.0f));
assert (s == "1");
s = NumberFormatter::format(0.1f);
assert (s == "0.1");
s = NumberFormatter::format(1.0);
assert (s == "1");
s = NumberFormatter::format(0.1);
assert (s == "0.1");
}
void NumberFormatterTest::setUp()
{
}
@ -165,9 +179,10 @@ CppUnit::Test* NumberFormatterTest::suite()
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("NumberFormatterTest");
CppUnit_addTest(pSuite, NumberFormatterTest, testFormat);
CppUnit_addTest(pSuite, NumberFormatterTest, testFormat0);
CppUnit_addTest(pSuite, NumberFormatterTest, testFormatHex);
CppUnit_addTest(pSuite, NumberFormatterTest, testFormat);
CppUnit_addTest(pSuite, NumberFormatterTest, testFormat0);
CppUnit_addTest(pSuite, NumberFormatterTest, testFormatHex);
CppUnit_addTest(pSuite, NumberFormatterTest, testFormatFloat);
return pSuite;
return pSuite;
}

View File

@ -46,12 +46,13 @@ public:
NumberFormatterTest(const std::string& name);
~NumberFormatterTest();
void testFormat();
void testFormat0();
void testFormatHex();
void setUp();
void tearDown();
void testFormat();
void testFormat0();
void testFormatHex();
void testFormatFloat();
void setUp();
void tearDown();
static CppUnit::Test* suite();

View File

@ -1560,11 +1560,14 @@ void PathTest::testFind()
{
Path p;
#if defined(POCO_OS_FAMILY_UNIX)
bool found = Path::find(Environment::get("PATH"), "ls", p);
bool notfound = Path::find(Environment::get("PATH"), "xxxyyy123", p);
bool found = Path::find(Environment::get("PATH"), "ls", p);
bool notfound = Path::find(Environment::get("PATH"), "xxxyyy123", p);
#elif defined(POCO_OS_FAMILY_WINDOWS)
bool found = Path::find(Environment::get("PATH"), "cmd.exe", p);
bool notfound = Path::find(Environment::get("PATH"), "xxxyyy123.zzz", p);
#if defined(_WIN32_WCE)
return;
#endif
bool found = Path::find(Environment::get("PATH"), "cmd.exe", p);
bool notfound = Path::find(Environment::get("PATH"), "xxxyyy123.zzz", p);
#else
bool found = true;
bool notfound = false;
@ -1607,6 +1610,22 @@ void PathTest::testResolve()
}
void PathTest::testPushPop()
{
Path p;
p.pushDirectory("a");
p.pushDirectory("b");
p.pushDirectory("c");
assert (p.toString(Path::PATH_UNIX) == "a/b/c/");
p.popDirectory();
assert (p.toString(Path::PATH_UNIX) == "a/b/");
p.popFrontDirectory();
assert (p.toString(Path::PATH_UNIX) == "b/");
}
void PathTest::setUp()
{
}
@ -1644,9 +1663,10 @@ CppUnit::Test* PathTest::suite()
CppUnit_addTest(pSuite, PathTest, testForDirectory);
CppUnit_addTest(pSuite, PathTest, testExpand);
CppUnit_addTest(pSuite, PathTest, testListRoots);
CppUnit_addTest(pSuite, PathTest, testFind);
CppUnit_addTest(pSuite, PathTest, testSwap);
CppUnit_addTest(pSuite, PathTest, testResolve);
CppUnit_addTest(pSuite, PathTest, testFind);
CppUnit_addTest(pSuite, PathTest, testSwap);
CppUnit_addTest(pSuite, PathTest, testResolve);
CppUnit_addTest(pSuite, PathTest, testPushPop);
return pSuite;
return pSuite;
}

View File

@ -1,7 +1,7 @@
//
// ProcessTest.cpp
//
// $Id: //poco/svn/Foundation/testsuite/src/ProcessTest.cpp#2 $
// $Id: //poco/1.4/Foundation/testsuite/src/ProcessTest.cpp#1 $
//
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -64,10 +64,14 @@ void ProcessTest::testLaunch()
#endif
#if defined(POCO_OS_FAMILY_UNIX)
cmd = "./";
cmd += name;
cmd = "./";
cmd += name;
#elif defined(_WIN32_WCE)
cmd = "\\";
cmd += name;
cmd += ".EXE";
#else
cmd = name;
cmd = name;
#endif
std::vector<std::string> args;
@ -82,8 +86,9 @@ void ProcessTest::testLaunch()
void ProcessTest::testLaunchRedirectIn()
{
std::string name("TestApp");
std::string cmd;
#if !defined(_WIN32_WCE)
std::string name("TestApp");
std::string cmd;
#if defined(_DEBUG)
name += "d";
#endif
@ -101,16 +106,18 @@ void ProcessTest::testLaunchRedirectIn()
ProcessHandle ph = Process::launch(cmd, args, &inPipe, 0, 0);
PipeOutputStream ostr(inPipe);
ostr << std::string(100, 'x');
ostr.close();
int rc = ph.wait();
assert (rc == 100);
ostr.close();
int rc = ph.wait();
assert (rc == 100);
#endif // !defined(_WIN32_WCE)
}
void ProcessTest::testLaunchRedirectOut()
{
std::string name("TestApp");
std::string cmd;
#if !defined(_WIN32_WCE)
std::string name("TestApp");
std::string cmd;
#if defined(_DEBUG)
name += "d";
#endif
@ -130,9 +137,10 @@ void ProcessTest::testLaunchRedirectOut()
std::string s;
int c = istr.get();
while (c != -1) { s += (char) c; c = istr.get(); }
assert (s == "Hello, world!");
int rc = ph.wait();
assert (rc == 1);
assert (s == "Hello, world!");
int rc = ph.wait();
assert (rc == 1);
#endif // !defined(_WIN32_WCE)
}

View File

@ -38,11 +38,14 @@
CppUnit::Test* SharedLibraryTestSuite::suite()
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("SharedLibraryTestSuite");
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("SharedLibraryTestSuite");
pSuite->addTest(SharedLibraryTest::suite());
pSuite->addTest(ManifestTest::suite());
pSuite->addTest(ClassLoaderTest::suite());
pSuite->addTest(ManifestTest::suite());
return pSuite;
#if !defined(_WIN32) || defined(_DLL)
pSuite->addTest(SharedLibraryTest::suite());
pSuite->addTest(ClassLoaderTest::suite());
#endif
return pSuite;
}

View File

@ -141,9 +141,21 @@ void StreamConverterTest::testIdentityUTF8In()
std::istringstream istr4(text);
std::ostringstream ostr4;
InputStreamConverter converter4(istr4, encoding, encoding);
StreamCopier::copyStream(converter4, ostr4);
assert (ostr4.str() == text);
assert (converter4.errors() == 0);
StreamCopier::copyStream(converter4, ostr4);
assert (ostr4.str() == text);
assert (converter4.errors() == 0);
const unsigned char supp[] = {0x41, 0x42, 0xf0, 0x90, 0x82, 0xa4, 0xf0, 0xaf, 0xa6, 0xa0, 0xf0, 0xaf, 0xa8, 0x9d, 0x00};
std::string text2((const char*) supp);
std::istringstream istr5(text2);
std::ostringstream ostr5;
InputStreamConverter converter5(istr5, encoding, encoding);
StreamCopier::copyStream(converter5, ostr5);
assert (ostr5.str() == text2);
assert (converter5.errors() == 0);
}

View File

@ -1,7 +1,7 @@
//
// StreamTokenizerTest.cpp
//
// $Id: //poco/svn/Foundation/testsuite/src/StreamTokenizerTest.cpp#2 $
// $Id: //poco/1.4/Foundation/testsuite/src/StreamTokenizerTest.cpp#1 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -35,7 +35,7 @@
#include "CppUnit/TestSuite.h"
#include "Poco/StreamTokenizer.h"
#include "Poco/Token.h"
#include <cctype>
#include "Poco/Ascii.h"
#include <sstream>
@ -44,6 +44,7 @@ using Poco::Token;
using Poco::InvalidToken;
using Poco::EOFToken;
using Poco::WhitespaceToken;
using Poco::Ascii;
class IdentifierToken: public Token
@ -61,24 +62,24 @@ public:
{
return Token::IDENTIFIER_TOKEN;
}
bool start(char c, std::istream& istr)
{
if (std::isalpha(c))
{
_value = c;
return true;
bool start(char c, std::istream& istr)
{
if (c != -1 && Ascii::isAlpha(c))
{
_value = c;
return true;
}
else return false;
}
void finish(std::istream& istr)
{
int c = istr.peek();
while (std::isalnum(c))
{
istr.get();
_value += c;
void finish(std::istream& istr)
{
int c = istr.peek();
while (c != -1 && Ascii::isAlphaNumeric(c))
{
istr.get();
_value += c;
c = istr.peek();
}
}
@ -100,24 +101,24 @@ public:
{
return Token::INTEGER_LITERAL_TOKEN;
}
bool start(char c, std::istream& istr)
{
if (std::isdigit(c))
{
_value = c;
return true;
bool start(char c, std::istream& istr)
{
if (c != -1 && Ascii::isDigit(c))
{
_value = c;
return true;
}
else return false;
}
void finish(std::istream& istr)
{
int c = istr.peek();
while (std::isdigit(c))
{
istr.get();
_value += c;
void finish(std::istream& istr)
{
int c = istr.peek();
while (c != -1 && Ascii::isDigit(c))
{
istr.get();
_value += c;
c = istr.peek();
}
}

View File

@ -42,6 +42,7 @@
#include "LineEndingConverterTest.h"
#include "TeeStreamTest.h"
#include "FileStreamTest.h"
#include "MemoryStreamTest.h"
CppUnit::Test* StreamsTestSuite::suite()
@ -56,9 +57,10 @@ CppUnit::Test* StreamsTestSuite::suite()
pSuite->addTest(ZLibTest::suite());
pSuite->addTest(StreamTokenizerTest::suite());
pSuite->addTest(BinaryReaderWriterTest::suite());
pSuite->addTest(LineEndingConverterTest::suite());
pSuite->addTest(TeeStreamTest::suite());
pSuite->addTest(FileStreamTest::suite());
pSuite->addTest(LineEndingConverterTest::suite());
pSuite->addTest(TeeStreamTest::suite());
pSuite->addTest(FileStreamTest::suite());
pSuite->addTest(MemoryStreamTest::suite());
return pSuite;
return pSuite;
}

View File

@ -0,0 +1,55 @@
//
// TestApp_WINCE.cpp
//
// $Id: //poco/1.4/Foundation/testsuite/src/TestApp_WINCE.cpp#1 $
//
// Copyright (c) 2005-2010, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include <string>
#include <iostream>
int _tmain(int argc, wchar_t* argv[])
{
if (argc > 1)
{
std::wstring arg(argv[1]);
if (arg == L"-hello")
{
std::cout << "Hello, world!";
}
else if (arg == L"-count")
{
int n = 0;
int c = std::cin.get();
while (c != -1) { ++n; c = std::cin.get(); }
return n;
}
}
return argc - 1;
}

View File

@ -0,0 +1,286 @@
//
// TextBufferIteratorTest.cpp
//
// $Id: //poco/1.4/Foundation/testsuite/src/TextBufferIteratorTest.cpp#1 $
//
// Copyright (c) 2010, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "TextBufferIteratorTest.h"
#include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h"
#include "Poco/TextBufferIterator.h"
#include "Poco/Latin1Encoding.h"
#include "Poco/UTF8Encoding.h"
#include "Poco/UTF16Encoding.h"
using Poco::TextBufferIterator;
using Poco::Latin1Encoding;
using Poco::UTF8Encoding;
using Poco::UTF16Encoding;
TextBufferIteratorTest::TextBufferIteratorTest(const std::string& name): CppUnit::TestCase(name)
{
}
TextBufferIteratorTest::~TextBufferIteratorTest()
{
}
void TextBufferIteratorTest::testEmptyLatin1()
{
Latin1Encoding encoding;
const char* text = "";
TextBufferIterator it(text, encoding);
TextBufferIterator end(it.end());
assert (it == end);
}
void TextBufferIteratorTest::testOneLatin1()
{
Latin1Encoding encoding;
const char* text = "x";
TextBufferIterator it(text, encoding);
TextBufferIterator end(it.end());
assert (it != end);
assert (*it == 'x');
++it;
assert (it == end);
}
void TextBufferIteratorTest::testLatin1()
{
Latin1Encoding encoding;
const char* text = "Latin1";
TextBufferIterator it(text, encoding);
TextBufferIterator end(it.end());
assert (it != end);
assert (*it++ == 'L');
assert (it != end);
assert (*it++ == 'a');
assert (it != end);
assert (*it++ == 't');
assert (it != end);
assert (*it++ == 'i');
assert (it != end);
assert (*it++ == 'n');
assert (it != end);
assert (*it++ == '1');
assert (it == end);
const char* empty = "";
it = TextBufferIterator(empty, encoding);
end = it.end();
assert (it == end);
}
void TextBufferIteratorTest::testEmptyUTF8()
{
UTF8Encoding encoding;
const char* text = "";
TextBufferIterator it(text, encoding);
TextBufferIterator end(text);
assert (it == end);
}
void TextBufferIteratorTest::testOneUTF8()
{
UTF8Encoding encoding;
// 1 byte sequence
const char* text = "x";
TextBufferIterator it(text, encoding);
TextBufferIterator end(it.end());
assert (it != end);
assert (*it == 'x');
++it;
assert (it == end);
unsigned char data[Poco::TextEncoding::MAX_SEQUENCE_LENGTH];
// 2 byte sequence
int n = encoding.convert(0xab, data, sizeof(data));
assert (n == 2);
it = TextBufferIterator(reinterpret_cast<const char*>(data), n, encoding);
end = it.end();
assert (it != end);
assert (*it++ == 0xab);
assert (it == end);
// 3 byte sequence
n = encoding.convert(0xabcd, data, sizeof(data));
assert (n == 3);
it = TextBufferIterator(reinterpret_cast<const char*>(data), n, encoding);
end = it.end();
assert (it != end);
assert (*it++ == 0xabcd);
assert (it == end);
// 4 byte sequence
n = encoding.convert(0xabcde, data, sizeof(data));
assert (n == 4);
it = TextBufferIterator(reinterpret_cast<const char*>(data), n, encoding);
end = it.end();
assert (it != end);
assert (*it++ == 0xabcde);
assert (it == end);
// 5 byte sequence - not supported
n = encoding.convert(0xabcdef, data, sizeof(data));
assert (n == 0);
// 6 byte sequence - not supported
n = encoding.convert(0xfabcdef, data, sizeof(data));
assert (n == 0);
}
void TextBufferIteratorTest::testUTF8()
{
UTF8Encoding encoding;
const unsigned char text[] = {0x20, 0xce, 0xba, 0xe1, 0xbd, 0xb9, 0xcf, 0x83, 0xce, 0xbc, 0xce, 0xb5, 0x20, 0x00};
TextBufferIterator it(reinterpret_cast<const char*>(text), encoding);
TextBufferIterator end(it.end());
assert (it != end);
assert (*it++ == 0x0020);
assert (it != end);
assert (*it++ == 0x03ba);
assert (it != end);
assert (*it++ == 0x1f79);
assert (it != end);
assert (*it++ == 0x03c3);
assert (it != end);
assert (*it++ == 0x03bc);
assert (it != end);
assert (*it++ == 0x03b5);
assert (it != end);
assert (*it++ == 0x0020);
assert (it == end);
}
void TextBufferIteratorTest::testUTF8Supplementary()
{
UTF8Encoding encoding;
const unsigned char text[] = {0x41, 0x42, 0xf0, 0x90, 0x82, 0xa4, 0xf0, 0xaf, 0xa6, 0xa0, 0xf0, 0xaf, 0xa8, 0x9d, 0x00};
TextBufferIterator it(reinterpret_cast<const char*>(text), encoding);
TextBufferIterator end(it.end());
assert (it != end);
assert (*it++ == 0x0041);
assert (it != end);
assert (*it++ == 0x0042);
assert (it != end);
assert (*it++ == 0x100a4);
assert (it != end);
assert (*it++ == 0x2f9a0);
assert (it != end);
assert (*it++ == 0x2fa1d);
assert (it == end);
}
void TextBufferIteratorTest::testUTF16Supplementary()
{
UTF16Encoding encoding;
const Poco::UInt16 text[] = { 0x0041, 0x0042, 0xD800, 0xDCA4, 0xD87E, 0xDDA0, 0xD87E, 0xDE1D};
TextBufferIterator it(reinterpret_cast<const char*>(text), sizeof(text), encoding);
TextBufferIterator end(it.end());
assert (it != end);
assert (*it++ == 0x0041);
assert (it != end);
assert (*it++ == 0x0042);
assert (it != end);
assert (*it++ == 0x100a4);
assert (it != end);
assert (*it++ == 0x2f9a0);
assert (it != end);
assert (*it++ == 0x2fa1d);
assert (it == end);
}
void TextBufferIteratorTest::testSwap()
{
Latin1Encoding encoding;
const char* text = "x";
TextBufferIterator it1(text, encoding);
TextBufferIterator it2(text, encoding);
TextBufferIterator end(it1.end());
assert (it1 == it2);
it2.swap(end);
assert (it1 != it2);
it2.swap(end);
assert (it1 == it2);
}
void TextBufferIteratorTest::setUp()
{
}
void TextBufferIteratorTest::tearDown()
{
}
CppUnit::Test* TextBufferIteratorTest::suite()
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("TextBufferIteratorTest");
CppUnit_addTest(pSuite, TextBufferIteratorTest, testEmptyLatin1);
CppUnit_addTest(pSuite, TextBufferIteratorTest, testOneLatin1);
CppUnit_addTest(pSuite, TextBufferIteratorTest, testLatin1);
CppUnit_addTest(pSuite, TextBufferIteratorTest, testEmptyUTF8);
CppUnit_addTest(pSuite, TextBufferIteratorTest, testOneUTF8);
CppUnit_addTest(pSuite, TextBufferIteratorTest, testUTF8);
CppUnit_addTest(pSuite, TextBufferIteratorTest, testUTF8Supplementary);
CppUnit_addTest(pSuite, TextBufferIteratorTest, testUTF16Supplementary);
CppUnit_addTest(pSuite, TextBufferIteratorTest, testSwap);
return pSuite;
}

View File

@ -0,0 +1,68 @@
//
// TextBufferIteratorTest.h
//
// $Id: //poco/1.4/Foundation/testsuite/src/TextBufferIteratorTest.h#1 $
//
// Definition of the TextBufferIteratorTest class.
//
// Copyright (c) 2010, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef TextBufferIteratorTest_INCLUDED
#define TextBufferIteratorTest_INCLUDED
#include "Poco/Foundation.h"
#include "CppUnit/TestCase.h"
class TextBufferIteratorTest: public CppUnit::TestCase
{
public:
TextBufferIteratorTest(const std::string& name);
~TextBufferIteratorTest();
void testEmptyLatin1();
void testOneLatin1();
void testLatin1();
void testEmptyUTF8();
void testOneUTF8();
void testUTF8();
void testUTF8Supplementary();
void testUTF16Supplementary();
void testSwap();
void setUp();
void tearDown();
static CppUnit::Test* suite();
private:
};
#endif // TextBufferIteratorTest_INCLUDED

View File

@ -1,7 +1,7 @@
//
// TextIteratorTest.cpp
//
// $Id: //poco/svn/Foundation/testsuite/src/TextIteratorTest.cpp#2 $
// $Id: //poco/1.4/Foundation/testsuite/src/TextIteratorTest.cpp#1 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -36,11 +36,13 @@
#include "Poco/TextIterator.h"
#include "Poco/Latin1Encoding.h"
#include "Poco/UTF8Encoding.h"
#include "Poco/UTF16Encoding.h"
using Poco::TextIterator;
using Poco::Latin1Encoding;
using Poco::UTF8Encoding;
using Poco::UTF16Encoding;
TextIteratorTest::TextIteratorTest(const std::string& name): CppUnit::TestCase(name)
@ -202,9 +204,53 @@ void TextIteratorTest::testUTF8()
}
void TextIteratorTest::testUTF8Supplementary()
{
UTF8Encoding encoding;
const unsigned char supp[] = {0x41, 0x42, 0xf0, 0x90, 0x82, 0xa4, 0xf0, 0xaf, 0xa6, 0xa0, 0xf0, 0xaf, 0xa8, 0x9d, 0x00};
std::string text((const char*) supp);
TextIterator it(text, encoding);
TextIterator end(text);
assert (it != end);
assert (*it++ == 0x0041);
assert (it != end);
assert (*it++ == 0x0042);
assert (it != end);
assert (*it++ == 0x100a4);
assert (it != end);
assert (*it++ == 0x2f9a0);
assert (it != end);
assert (*it++ == 0x2fa1d);
assert (it == end);
}
void TextIteratorTest::testUTF16Supplementary()
{
UTF16Encoding encoding;
const Poco::UInt16 supp [] = { 0x0041, 0x0042, 0xD800, 0xDCA4, 0xD87E, 0xDDA0, 0xD87E, 0xDE1D, 0x00};
std::string text((const char*) supp, 16);
TextIterator it(text, encoding);
TextIterator end(text);
assert (it != end);
assert (*it++ == 0x0041);
assert (it != end);
assert (*it++ == 0x0042);
assert (it != end);
assert (*it++ == 0x100a4);
assert (it != end);
assert (*it++ == 0x2f9a0);
assert (it != end);
assert (*it++ == 0x2fa1d);
assert (it == end);
}
void TextIteratorTest::testSwap()
{
Latin1Encoding encoding;
Latin1Encoding encoding;
std::string text("x");
TextIterator it1(text, encoding);
TextIterator it2(text, encoding);
@ -235,10 +281,12 @@ CppUnit::Test* TextIteratorTest::suite()
CppUnit_addTest(pSuite, TextIteratorTest, testEmptyLatin1);
CppUnit_addTest(pSuite, TextIteratorTest, testOneLatin1);
CppUnit_addTest(pSuite, TextIteratorTest, testLatin1);
CppUnit_addTest(pSuite, TextIteratorTest, testEmptyUTF8);
CppUnit_addTest(pSuite, TextIteratorTest, testOneUTF8);
CppUnit_addTest(pSuite, TextIteratorTest, testUTF8);
CppUnit_addTest(pSuite, TextIteratorTest, testSwap);
CppUnit_addTest(pSuite, TextIteratorTest, testEmptyUTF8);
CppUnit_addTest(pSuite, TextIteratorTest, testOneUTF8);
CppUnit_addTest(pSuite, TextIteratorTest, testUTF8);
CppUnit_addTest(pSuite, TextIteratorTest, testUTF8Supplementary);
CppUnit_addTest(pSuite, TextIteratorTest, testUTF16Supplementary);
CppUnit_addTest(pSuite, TextIteratorTest, testSwap);
return pSuite;
return pSuite;
}

View File

@ -49,12 +49,14 @@ public:
void testEmptyLatin1();
void testOneLatin1();
void testLatin1();
void testEmptyUTF8();
void testOneUTF8();
void testUTF8();
void testSwap();
void testEmptyUTF8();
void testOneUTF8();
void testUTF8();
void testUTF8Supplementary();
void testUTF16Supplementary();
void testSwap();
void setUp();
void setUp();
void tearDown();
static CppUnit::Test* suite();

View File

@ -1,7 +1,7 @@
//
// TextTestSuite.cpp
//
// $Id: //poco/svn/Foundation/testsuite/src/TextTestSuite.cpp#2 $
// $Id: //poco/1.4/Foundation/testsuite/src/TextTestSuite.cpp#1 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -32,21 +32,29 @@
#include "TextTestSuite.h"
#include "TextIteratorTest.h"
#include "TextBufferIteratorTest.h"
#include "TextConverterTest.h"
#include "StreamConverterTest.h"
#include "TextEncodingTest.h"
#include "UTF8StringTest.h"
#ifdef _WINDOWS
#include "UnicodeConverterTest.h"
#endif
CppUnit::Test* TextTestSuite::suite()
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("TextTestSuite");
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("TextTestSuite");
pSuite->addTest(TextIteratorTest::suite());
pSuite->addTest(TextConverterTest::suite());
pSuite->addTest(StreamConverterTest::suite());
pSuite->addTest(TextEncodingTest::suite());
pSuite->addTest(UTF8StringTest::suite());
pSuite->addTest(TextIteratorTest::suite());
pSuite->addTest(TextBufferIteratorTest::suite());
pSuite->addTest(TextConverterTest::suite());
pSuite->addTest(StreamConverterTest::suite());
pSuite->addTest(TextEncodingTest::suite());
pSuite->addTest(UTF8StringTest::suite());
#ifdef _WINDOWS
pSuite->addTest(UnicodeConverterTest::suite());
#endif
return pSuite;
return pSuite;
}

View File

@ -38,13 +38,13 @@
#include "Poco/ThreadTarget.h"
#include "Poco/Event.h"
#if defined(__sun) && defined(__SVR4)
# if !defined(__EXTENSIONS__)
# define __EXTENSIONS__
# endif
// must be limits.h for PTHREAD_STACK_MIN on Solaris
# include <limits.h>
# if !defined(__EXTENSIONS__)
#define __EXTENSIONS__
#endif
// must be limits.h for PTHREAD_STACK_MIN on Solaris
# include <limits.h>
#else
# include <climits>
#include <climits>
#endif
@ -272,30 +272,30 @@ void ThreadTest::testThreadFunction()
void ThreadTest::testThreadStackSize()
{
// some platforms (e.g. Fedora Core9/g++ 4.3.0) ignore set stack size value
// so some asserts will fail here
// some platforms (e.g. Fedora Core9/g++ 4.3.0) ignore set stack size value
// so some asserts will fail here
int stackSize = 50000000;
Thread thread;
int stackSize = 50000000;
Thread thread;
assert (0 == thread.getStackSize());
thread.setStackSize(stackSize);
assert (stackSize == thread.getStackSize());
int tmp = MyRunnable::_staticVar;
thread.start(freeFunc, &tmp);
thread.join();
assert (0 == thread.getStackSize());
thread.setStackSize(stackSize);
assert (stackSize == thread.getStackSize());
int tmp = MyRunnable::_staticVar;
thread.start(freeFunc, &tmp);
thread.join();
assert (tmp * 2 == MyRunnable::_staticVar);
stackSize = 1;
thread.setStackSize(stackSize);
#ifdef PTHREAD_STACK_MIN
assert (PTHREAD_STACK_MIN == thread.getStackSize());
assert (PTHREAD_STACK_MIN == thread.getStackSize());
#else
assert (stackSize == thread.getStackSize());
assert (stackSize == thread.getStackSize());
#endif // PTHREAD_STACK_MIN
tmp = MyRunnable::_staticVar;
thread.start(freeFunc, &tmp);
thread.join();
tmp = MyRunnable::_staticVar;
thread.start(freeFunc, &tmp);
thread.join();
assert (tmp * 2 == MyRunnable::_staticVar);
thread.setStackSize(0);
@ -307,6 +307,15 @@ void ThreadTest::testThreadStackSize()
}
void ThreadTest::testSleep()
{
Poco::Timestamp start;
Thread::sleep(200);
Poco::Timespan elapsed = start.elapsed();
assert (elapsed.totalMilliseconds() >= 190 && elapsed.totalMilliseconds() < 250);
}
void ThreadTest::setUp()
{
}
@ -326,9 +335,10 @@ CppUnit::Test* ThreadTest::suite()
CppUnit_addTest(pSuite, ThreadTest, testCurrent);
CppUnit_addTest(pSuite, ThreadTest, testThreads);
CppUnit_addTest(pSuite, ThreadTest, testJoin);
CppUnit_addTest(pSuite, ThreadTest, testThreadTarget);
CppUnit_addTest(pSuite, ThreadTest, testThreadFunction);
CppUnit_addTest(pSuite, ThreadTest, testThreadStackSize);
CppUnit_addTest(pSuite, ThreadTest, testThreadTarget);
CppUnit_addTest(pSuite, ThreadTest, testThreadFunction);
CppUnit_addTest(pSuite, ThreadTest, testThreadStackSize);
CppUnit_addTest(pSuite, ThreadTest, testSleep);
return pSuite;
return pSuite;
}

View File

@ -51,12 +51,13 @@ public:
void testCurrent();
void testThreads();
void testJoin();
void testThreadTarget();
void testThreadFunction();
void testThreadStackSize();
void testThreadTarget();
void testThreadFunction();
void testThreadStackSize();
void testSleep();
void setUp();
void tearDown();
void setUp();
void tearDown();
static CppUnit::Test* suite();

View File

@ -62,19 +62,19 @@ void TimerTest::testTimer()
Stopwatch sw;
TimerCallback<TimerTest> tc(*this, &TimerTest::onTimer);
sw.start();
t.start(tc);
_event.wait();
sw.stop();
assert (sw.elapsed() >= 90000 && sw.elapsed() < 150000);
sw.restart();
_event.wait();
sw.stop();
assert (sw.elapsed() >= 190000 && sw.elapsed() < 250000);
sw.restart();
_event.wait();
sw.stop();
assert (sw.elapsed() >= 190000 && sw.elapsed() < 250000);
t.stop();
t.start(tc);
_event.wait();
sw.stop();
assert (sw.elapsed() >= 80000 && sw.elapsed() < 250000);
sw.restart();
_event.wait();
sw.stop();
assert (sw.elapsed() >= 180000 && sw.elapsed() < 250000);
sw.restart();
_event.wait();
sw.stop();
assert (sw.elapsed() >= 180000 && sw.elapsed() < 250000);
t.stop();
}

View File

@ -12,14 +12,14 @@
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
@ -60,58 +60,58 @@ void URITest::testConstruction()
assert (uri.getPath().empty());
assert (uri.getQuery().empty());
assert (uri.getFragment().empty());
uri.setScheme("ftp");
assert (uri.getScheme() == "ftp");
assert (uri.getPort() == 21);
uri.setScheme("HTTP");
assert (uri.getScheme() == "http");
uri.setAuthority("www.appinf.com");
assert (uri.getAuthority() == "www.appinf.com");
assert (uri.getPort() == 80);
uri.setAuthority("user@services.appinf.com:8000");
assert (uri.getUserInfo() == "user");
assert (uri.getHost() == "services.appinf.com");
assert (uri.getPort() == 8000);
uri.setPath("/index.html");
assert (uri.getPath() == "/index.html");
uri.setPath("/file%20with%20spaces.html");
assert (uri.getPath() == "/file with spaces.html");
uri.setPathEtc("/query.cgi?query=foo");
assert (uri.getPath() == "/query.cgi");
assert (uri.getQuery() == "query=foo");
assert (uri.getFragment().empty());
assert (uri.getPathEtc() == "/query.cgi?query=foo");
assert (uri.getPathAndQuery() == "/query.cgi?query=foo");
uri.setPathEtc("/query.cgi?query=bar#frag");
assert (uri.getPath() == "/query.cgi");
assert (uri.getQuery() == "query=bar");
assert (uri.getFragment() == "frag");
assert (uri.getPathEtc() == "/query.cgi?query=bar#frag");
assert (uri.getPathAndQuery() == "/query.cgi?query=bar");
uri.setQuery("query=test");
assert (uri.getQuery() == "query=test");
uri.setFragment("result");
assert (uri.getFragment() == "result");
URI uri2("file", "/home/guenter/foo.bar");
assert (uri2.getScheme() == "file");
assert (uri2.getPath() == "/home/guenter/foo.bar");
URI uri3("http", "www.appinf.com", "/index.html");
assert (uri3.getScheme() == "http");
assert (uri3.getAuthority() == "www.appinf.com");
assert (uri3.getPath() == "/index.html");
URI uri4("http", "www.appinf.com:8000", "/index.html");
assert (uri4.getScheme() == "http");
assert (uri4.getAuthority() == "www.appinf.com:8000");
@ -140,7 +140,7 @@ void URITest::testConstruction()
assert (uri7.getPort() == 80);
assert (uri7.getAuthority() == "user@www.appinf.com");
assert (uri7.getPath() == "/index.html");
URI uri8("http", "www.appinf.com", "/index.html", "query=test");
assert (uri8.getScheme() == "http");
assert (uri8.getAuthority() == "www.appinf.com");
@ -165,14 +165,14 @@ void URITest::testConstruction()
assert (uri9.getQuery().empty());
assert (uri9.getFragment().empty());
URI uri10("ldap", "[2001:db8::7]", "/c=GB?objectClass?one");
assert (uri10.getScheme() == "ldap");
assert (uri10.getUserInfo().empty());
assert (uri10.getHost() == "[2001:db8::7]");
assert (uri10.getPort() == 389);
assert (uri10.getAuthority() == "[2001:db8::7]");
assert (uri10.getPathEtc() == "/c=GB?objectClass?one");
URI uri10("ldap", "[2001:db8::7]", "/c=GB?objectClass?one");
assert (uri10.getScheme() == "ldap");
assert (uri10.getUserInfo().empty());
assert (uri10.getHost() == "2001:db8::7");
assert (uri10.getPort() == 389);
assert (uri10.getAuthority() == "[2001:db8::7]");
assert (uri10.getPathEtc() == "/c=GB?objectClass?one");
URI uri11("http", "www.appinf.com", "/index.html?query=test#fragment");
assert (uri11.getScheme() == "http");
assert (uri11.getAuthority() == "www.appinf.com");
@ -180,7 +180,6 @@ void URITest::testConstruction()
assert (uri11.getPathEtc() == "/index.html?query=test#fragment");
assert (uri11.getQuery() == "query=test");
assert (uri11.getFragment() == "fragment");
}
@ -201,7 +200,7 @@ void URITest::testParse()
assert (uri.getQuery().empty());
assert (uri.getFragment().empty());
assert (!uri.isRelative());
uri = "ftp://anonymous@ftp.appinf.com/pub/";
assert (uri.getScheme() == "ftp");
assert (uri.getUserInfo() == "anonymous");
@ -222,7 +221,7 @@ void URITest::testParse()
assert (uri.getQuery().empty());
assert (uri.getFragment() == "top");
assert (!uri.isRelative());
uri = "http://www.appinf.com/search.cgi?keyword=test&scope=all";
assert (uri.getScheme() == "http");
assert (uri.getHost() == "www.appinf.com");
@ -240,7 +239,7 @@ void URITest::testParse()
assert (uri.getQuery() == "keyword=test&scope=all");
assert (uri.getFragment() == "result");
assert (!uri.isRelative());
uri = "http://www.appinf.com/search.cgi?keyword=test%20encoded&scope=all#result";
assert (uri.getScheme() == "http");
assert (uri.getHost() == "www.appinf.com");
@ -249,17 +248,17 @@ void URITest::testParse()
assert (uri.getQuery() == "keyword=test encoded&scope=all");
assert (uri.getFragment() == "result");
assert (!uri.isRelative());
uri = "ldap://[2001:db8::7]/c=GB?objectClass?one";
assert (uri.getScheme() == "ldap");
assert (uri.getUserInfo().empty());
assert (uri.getHost() == "[2001:db8::7]");
assert (uri.getPort() == 389);
assert (uri.getAuthority() == "[2001:db8::7]");
assert (uri.getPath() == "/c=GB");
uri = "ldap://[2001:db8::7]/c=GB?objectClass?one";
assert (uri.getScheme() == "ldap");
assert (uri.getUserInfo().empty());
assert (uri.getHost() == "2001:db8::7");
assert (uri.getPort() == 389);
assert (uri.getAuthority() == "[2001:db8::7]");
assert (uri.getPath() == "/c=GB");
assert (uri.getQuery() == "objectClass?one");
assert (uri.getFragment().empty());
uri = "mailto:John.Doe@example.com";
assert (uri.getScheme() == "mailto");
assert (uri.getUserInfo().empty());
@ -269,7 +268,7 @@ void URITest::testParse()
assert (uri.getPath() == "John.Doe@example.com");
assert (uri.getQuery().empty());
assert (uri.getFragment().empty());
uri = "tel:+1-816-555-1212";
assert (uri.getScheme() == "tel");
assert (uri.getUserInfo().empty());
@ -279,7 +278,7 @@ void URITest::testParse()
assert (uri.getPath() == "+1-816-555-1212");
assert (uri.getQuery().empty());
assert (uri.getFragment().empty());
uri = "telnet://192.0.2.16:80";
assert (uri.getScheme() == "telnet");
assert (uri.getUserInfo().empty());
@ -289,7 +288,7 @@ void URITest::testParse()
assert (uri.getPath().empty());
assert (uri.getQuery().empty());
assert (uri.getFragment().empty());
uri = "urn:oasis:names:specification:docbook:dtd:xml:4.1.2";
assert (uri.getScheme() == "urn");
assert (uri.getUserInfo().empty());
@ -299,7 +298,7 @@ void URITest::testParse()
assert (uri.getPath() == "oasis:names:specification:docbook:dtd:xml:4.1.2");
assert (uri.getQuery().empty());
assert (uri.getFragment().empty());
uri = "";
assert (uri.getScheme().empty());
assert (uri.getAuthority().empty());
@ -310,9 +309,9 @@ void URITest::testParse()
assert (uri.getQuery().empty());
assert (uri.getFragment().empty());
assert (uri.empty());
// relative references
uri = "/foo/bar";
assert (uri.getScheme().empty());
assert (uri.getAuthority().empty());
@ -367,8 +366,8 @@ void URITest::testParse()
assert (uri.getQuery().empty());
assert (uri.getFragment() == "frag");
assert (uri.isRelative());
uri = "?query=test";
uri = "?query=test";
assert (uri.getScheme().empty());
assert (uri.getAuthority().empty());
assert (uri.getUserInfo().empty());
@ -379,7 +378,7 @@ void URITest::testParse()
assert (uri.getFragment().empty());
assert (uri.isRelative());
uri = "?query=test#frag";
uri = "?query=test#frag";
assert (uri.getScheme().empty());
assert (uri.getAuthority().empty());
assert (uri.getUserInfo().empty());
@ -389,8 +388,8 @@ void URITest::testParse()
assert (uri.getQuery() == "query=test");
assert (uri.getFragment() == "frag");
assert (uri.isRelative());
uri = "#frag";
uri = "#frag";
assert (uri.getScheme().empty());
assert (uri.getAuthority().empty());
assert (uri.getUserInfo().empty());
@ -401,7 +400,7 @@ void URITest::testParse()
assert (uri.getFragment() == "frag");
assert (uri.isRelative());
uri = "#";
uri = "#";
assert (uri.getScheme().empty());
assert (uri.getAuthority().empty());
assert (uri.getUserInfo().empty());
@ -411,7 +410,7 @@ void URITest::testParse()
assert (uri.getQuery().empty());
assert (uri.getFragment().empty());
assert (uri.isRelative());
uri = "file:///a/b/c";
assert (uri.getScheme() == "file");
assert (uri.getAuthority().empty());
@ -433,7 +432,7 @@ void URITest::testParse()
assert (uri.getQuery().empty());
assert (uri.getFragment().empty());
assert (!uri.isRelative());
uri = "file:///c:/Windows/system32/";
assert (uri.getScheme() == "file");
assert (uri.getAuthority().empty());
@ -455,7 +454,7 @@ void URITest::testParse()
assert (uri.getQuery().empty());
assert (uri.getFragment().empty());
assert (uri.isRelative());
}
@ -466,42 +465,42 @@ void URITest::testToString()
uri = "http://www.appinf.com/";
assert (uri.toString() == "http://www.appinf.com/");
uri = "ftp://anonymous@ftp.appinf.com/pub/";
assert (uri.toString() == "ftp://anonymous@ftp.appinf.com/pub/");
uri = "https://www.appinf.com/index.html#top";
assert (uri.toString() == "https://www.appinf.com/index.html#top");
uri = "http://www.appinf.com/search.cgi?keyword=test&scope=all";
assert (uri.toString() == "http://www.appinf.com/search.cgi?keyword=test&scope=all");
uri = "http://www.appinf.com/search.cgi?keyword=test&scope=all#result";
assert (uri.toString() == "http://www.appinf.com/search.cgi?keyword=test&scope=all#result");
uri = "http://www.appinf.com/search.cgi?keyword=test%20encoded&scope=all#result";
assert (uri.toString() == "http://www.appinf.com/search.cgi?keyword=test%20encoded&scope=all#result");
uri = "ldap://[2001:db8::7]/c=GB?objectClass?one";
assert (uri.toString() == "ldap://[2001:db8::7]/c=GB?objectClass?one");
uri = "mailto:John.Doe@example.com";
assert (uri.toString() == "mailto:John.Doe@example.com");
uri = "tel:+1-816-555-1212";
assert (uri.toString() == "tel:+1-816-555-1212");
uri = "telnet://192.0.2.16:80";
assert (uri.toString() == "telnet://192.0.2.16:80");
uri = "urn:oasis:names:specification:docbook:dtd:xml:4.1.2";
assert (uri.toString() == "urn:oasis:names:specification:docbook:dtd:xml:4.1.2");
uri = "";
assert (uri.toString() == "");
// relative references
uri = "/foo/bar";
assert (uri.toString() == "/foo/bar");
@ -519,30 +518,34 @@ void URITest::testToString()
uri = "index.html#frag";
assert (uri.toString() == "index.html#frag");
uri = "?query=test";
uri = "?query=test";
assert (uri.toString() == "?query=test");
uri = "?query=test#frag";
uri = "?query=test#frag";
assert (uri.toString() == "?query=test#frag");
uri = "#frag";
uri = "#frag";
assert (uri.toString() == "#frag");
uri = "#";
uri = "#";
assert (uri.toString() == "");
uri = "file:///a/b/c";
assert (uri.toString() == "file:///a/b/c");
uri = "file://localhost/a/b/c";
assert (uri.toString() == "file://localhost/a/b/c");
uri = "file:///c:/Windows/system32/";
assert (uri.toString() == "file:///c:/Windows/system32/");
uri = "./c:/Windows/system32/";
assert (uri.toString() == "./c:/Windows/system32/");
uri = "./c:/Windows/system32/";
assert (uri.toString() == "./c:/Windows/system32/");
uri = "http://www.appinf.com";
uri.setRawQuery("query=test");
assert (uri.toString() == "http://www.appinf.com/?query=test");
}
@ -553,19 +556,19 @@ void URITest::testCompare()
assert (uri1 == uri2);
assert (uri1 == "http://www.appinf.com:");
assert (uri1 != "http://www.google.com");
uri1 = "/foo/bar";
assert (uri1 == "/foo/bar");
assert (uri1 != "/foo/baz");
uri1 = "?query";
assert (uri1 == "?query");
assert (uri1 != "?query2");
uri1 = "#frag";
assert (uri1 == "#frag");
assert (uri1 != "#frag2");
uri1 = "/index.html#frag";
assert (uri1 == "/index.html#frag");
assert (uri1 != "/index.html");
@ -577,15 +580,15 @@ void URITest::testNormalize()
URI uri("http://www.appinf.com");
uri.normalize();
assert (uri.toString() == "http://www.appinf.com");
uri = "http://www.appinf.com/";
uri.normalize();
assert (uri.toString() == "http://www.appinf.com/");
uri = "http://www.appinf.com/foo/bar/./index.html";
uri.normalize();
assert (uri.toString() == "http://www.appinf.com/foo/bar/index.html");
uri = "http://www.appinf.com/foo/bar/../index.html";
uri.normalize();
assert (uri.toString() == "http://www.appinf.com/foo/index.html");
@ -625,7 +628,7 @@ void URITest::testNormalize()
uri = "http://www.appinf.com/../foo/../";
uri.normalize();
assert (uri.toString() == "http://www.appinf.com/");
uri = "file:///c:/Windows/system32/";
uri.normalize();
assert (uri.toString() == "file:///c:/Windows/system32/");
@ -640,13 +643,13 @@ void URITest::testNormalize()
void URITest::testResolve()
{
URI uri("http://www.appinf.com");
uri.resolve("/index.html");
assert (uri.toString() == "http://www.appinf.com/index.html");
uri.resolve("#frag");
assert (uri.toString() == "http://www.appinf.com/index.html#frag");
uri = "http://www.appinf.com/html";
uri.resolve("../images/foo.gif");
assert (uri.toString() == "http://www.appinf.com/images/foo.gif");
@ -674,7 +677,7 @@ void URITest::testResolve()
uri = "/a/b/c/d/e";
uri.resolve("./../../f/./g");
assert (uri.toString() == "/a/b/f/g");
uri = "/a/b/../c/";
uri.resolve("../d");
assert (uri.toString() == "/a/d");
@ -714,7 +717,7 @@ void URITest::testResolve()
uri = "http://www.appinf.com/html/";
uri.resolve("http://www.google.com/");
assert (uri.toString() == "http://www.google.com/");
uri = "http://www.appinf.com/";
URI uri2(uri, "index.html");
assert (uri2.toString() == "http://www.appinf.com/index.html");
@ -729,13 +732,12 @@ void URITest::testSwap()
{
URI uri1("http://www.appinf.com/search.cgi?keyword=test%20encoded&scope=all#result");
URI uri2("mailto:John.Doe@example.com");
uri1.swap(uri2);
assert (uri1.toString() == "mailto:John.Doe@example.com");
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 '%'
@ -764,6 +766,7 @@ void URITest::testOther()
assert(uri.getPathEtc() == "/search?q=pony%7eride#frag%20ment");
}
void URITest::setUp()
{
}

View File

@ -1,7 +1,7 @@
//
// UUIDTest.cpp
//
// $Id: //poco/svn/Foundation/testsuite/src/UUIDTest.cpp#2 $
// $Id: //poco/1.4/Foundation/testsuite/src/UUIDTest.cpp#1 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -72,40 +72,40 @@ void UUIDTest::testBuffer()
void UUIDTest::testCompare()
{
UUID nil;
assert (nil.isNil());
assert (UUID::nil().isNil());
UUID uuid1 = nil;
UUID uuid2;
assert (uuid1.isNil());
assert (uuid1 == nil);
assert (!(uuid1 != nil));
assert (uuid1 >= nil);
assert (uuid1 <= nil);
assert (!(uuid1 > nil));
assert (!(uuid1 < nil));
assert (uuid1.toString() == "00000000-0000-0000-0000-000000000000");
uuid1 = UUID::dns();
assert (!uuid1.isNil());
assert (uuid1 != nil);
assert (!(uuid1 == nil));
assert (uuid1 >= nil);
assert (!(uuid1 <= nil));
assert (uuid1 > nil);
assert (!(uuid1 < nil));
assert (uuid1.toString() == "6ba7b810-9dad-11d1-80b4-00c04fd430c8");
UUID null;
assert (null.isNull());
assert (UUID::null().isNull());
UUID uuid1 = null;
UUID uuid2;
assert (uuid1.isNull());
assert (uuid1 == null);
assert (!(uuid1 != null));
assert (uuid1 >= null);
assert (uuid1 <= null);
assert (!(uuid1 > null));
assert (!(uuid1 < null));
assert (uuid1.toString() == "00000000-0000-0000-0000-000000000000");
uuid1 = UUID::dns();
assert (!uuid1.isNull());
assert (uuid1 != null);
assert (!(uuid1 == null));
assert (uuid1 >= null);
assert (!(uuid1 <= null));
assert (uuid1 > null);
assert (!(uuid1 < null));
assert (uuid1.toString() == "6ba7b810-9dad-11d1-80b4-00c04fd430c8");
assert (nil != uuid1);
assert (!(nil == uuid1));
assert (!(nil >= uuid1));
assert (nil <= uuid1);
assert (!(nil > uuid1));
assert (nil < uuid1);
uuid2 = uuid1;
assert (uuid2 == uuid1);
assert (null != uuid1);
assert (!(null == uuid1));
assert (!(null >= uuid1));
assert (null <= uuid1);
assert (!(null > uuid1));
assert (null < uuid1);
uuid2 = uuid1;
assert (uuid2 == uuid1);
assert (!(uuid2 != uuid1));
assert (uuid2 >= uuid1);
assert (uuid2 <= uuid1);
@ -160,9 +160,19 @@ void UUIDTest::testSwap()
UUID uuid2("d2ee4220-3625-11d9-9669-0800200c9a66");
uuid1.swap(uuid2);
assert (uuid1.toString() == "d2ee4220-3625-11d9-9669-0800200c9a66");
assert (uuid2.toString() == "db4fa7e9-9e62-4597-99e0-b1ec0b59800e");
assert (uuid2.toString() == "db4fa7e9-9e62-4597-99e0-b1ec0b59800e");
}
void UUIDTest::testTryParse()
{
UUID uuid;
assert (uuid.tryParse("6BA7B810-9DAD-11D1-80B4-00C04FD430C8"));
assert (uuid.toString() == "6ba7b810-9dad-11d1-80b4-00c04fd430c8");
UUID notUuid;
assert (!notUuid.tryParse("not a uuid"));
assert (notUuid.isNull());
}
void UUIDTest::setUp()
{
@ -181,9 +191,10 @@ CppUnit::Test* UUIDTest::suite()
CppUnit_addTest(pSuite, UUIDTest, testParse);
CppUnit_addTest(pSuite, UUIDTest, testBuffer);
CppUnit_addTest(pSuite, UUIDTest, testCompare);
CppUnit_addTest(pSuite, UUIDTest, testVersion);
CppUnit_addTest(pSuite, UUIDTest, testVariant);
CppUnit_addTest(pSuite, UUIDTest, testSwap);
CppUnit_addTest(pSuite, UUIDTest, testVersion);
CppUnit_addTest(pSuite, UUIDTest, testVariant);
CppUnit_addTest(pSuite, UUIDTest, testSwap);
CppUnit_addTest(pSuite, UUIDTest, testTryParse);
return pSuite;
return pSuite;
}

View File

@ -49,12 +49,13 @@ public:
void testParse();
void testBuffer();
void testCompare();
void testVersion();
void testVariant();
void testSwap();
void setUp();
void tearDown();
void testVersion();
void testVariant();
void testSwap();
void testTryParse();
void setUp();
void tearDown();
static CppUnit::Test* suite();

View File

@ -0,0 +1,115 @@
//
// UnicodeConverterTest.cpp
//
// $Id: //poco/1.4/Foundation/testsuite/src/UnicodeConverterTest.cpp#1 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "UnicodeConverterTest.h"
#include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h"
#include "Poco/UnicodeConverter.h"
using Poco::UnicodeConverter;
UnicodeConverterTest::UnicodeConverterTest(const std::string& name): CppUnit::TestCase(name)
{
}
UnicodeConverterTest::~UnicodeConverterTest()
{
}
void UnicodeConverterTest::testString()
{
const unsigned char supp[] = {0x41, 0x42, 0xf0, 0x90, 0x82, 0xa4, 0xf0, 0xaf, 0xa6, 0xa0, 0xf0, 0xaf, 0xa8, 0x9d, 0x00};
std::string text((const char*) supp);
std::wstring wtext;
UnicodeConverter::toUTF16 (text, wtext);
std::string text2;
UnicodeConverter::toUTF8 (wtext, text2);
assert (text == text2);
}
void UnicodeConverterTest::testCharPtrLength()
{
const unsigned char supp[] = {0x41, 0x42, 0xf0, 0x90, 0x82, 0xa4, 0xf0, 0xaf, 0xa6, 0xa0, 0xf0, 0xaf, 0xa8, 0x9d, 0x00};
std::string text((const char*) supp);
std::wstring wtext;
std::string text2;
UnicodeConverter::toUTF16 ((const char*)supp, 14, wtext);
UnicodeConverter::toUTF8 (wtext.c_str (), (int) wtext.size (), text2);
assert (text == text2);
}
void UnicodeConverterTest::testCharPtr()
{
const unsigned char supp[] = {0x41, 0x42, 0xf0, 0x90, 0x82, 0xa4, 0xf0, 0xaf, 0xa6, 0xa0, 0xf0, 0xaf, 0xa8, 0x9d, 0x00};
std::string text((const char*) supp);
std::wstring wtext;
std::string text2;
UnicodeConverter::toUTF16 ((const char*)supp, wtext);
UnicodeConverter::toUTF8 (wtext.c_str (), text2);
assert (text == text2);
}
void UnicodeConverterTest::setUp()
{
}
void UnicodeConverterTest::tearDown()
{
}
CppUnit::Test* UnicodeConverterTest::suite()
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("UnicodeConverterTest");
CppUnit_addTest(pSuite, UnicodeConverterTest, testString);
CppUnit_addTest(pSuite, UnicodeConverterTest, testCharPtrLength);
CppUnit_addTest(pSuite, UnicodeConverterTest, testCharPtr);
return pSuite;
}

View File

@ -0,0 +1,62 @@
//
// UnicodeConverterTest.h
//
// $Id: //poco/1.4/Foundation/testsuite/src/UnicodeConverterTest.h#1 $
//
// Definition of the UnicodeConverterTest class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef UnicodeConverterTest_INCLUDED
#define UnicodeConverterTest_INCLUDED
#include "Poco/Foundation.h"
#include "CppUnit/TestCase.h"
class UnicodeConverterTest: public CppUnit::TestCase
{
public:
UnicodeConverterTest(const std::string& name);
~UnicodeConverterTest();
void testString();
void testCharPtrLength();
void testCharPtr();
void setUp();
void tearDown();
static CppUnit::Test* suite();
private:
};
#endif // UnicodeConverterTest_INCLUDED

View File

@ -0,0 +1,52 @@
//
// WinCEDriver.cpp
//
// $Id: //poco/1.4/Foundation/testsuite/src/WinCEDriver.cpp#1 $
//
// Console-based test driver for Windows CE.
//
// Copyright (c) 2004-2010, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "CppUnit/TestRunner.h"
#include "FoundationTestSuite.h"
#include <cstdlib>
int _tmain(int argc, wchar_t* argv[])
{
std::vector<std::string> args;
for (int i = 0; i < argc; ++i)
{
char buffer[1024];
std::wcstombs(buffer, argv[i], sizeof(buffer));
args.push_back(std::string(buffer));
}
CppUnit::TestRunner runner;
runner.addTest("FoundationTestSuite", FoundationTestSuite::suite());
return runner.run(args) ? 0 : 1;
}

View File

@ -1,7 +1,7 @@
//
// ZLibTest.cpp
//
// $Id: //poco/svn/Foundation/testsuite/src/ZLibTest.cpp#2 $
// $Id: //poco/1.4/Foundation/testsuite/src/ZLibTest.cpp#1 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -150,6 +150,35 @@ void ZLibTest::testGzip2()
}
void ZLibTest::testGzip3()
{
std::stringstream buffer;
DeflatingOutputStream deflater1(buffer, DeflatingStreamBuf::STREAM_GZIP);
deflater1 << "abcdefabcdefabcdefabcdefabcdefabcdef" << std::endl;
deflater1 << "abcdefabcdefabcdefabcdefabcdefabcdef" << std::endl;
deflater1.close();
DeflatingOutputStream deflater2(buffer, DeflatingStreamBuf::STREAM_GZIP);
deflater2 << "bcdefabcdefabcdefabcdefabcdefabcdefa" << std::endl;
deflater2 << "bcdefabcdefabcdefabcdefabcdefabcdefa" << std::endl;
deflater2.close();
InflatingInputStream inflater(buffer, InflatingStreamBuf::STREAM_GZIP);
std::string data;
inflater >> data;
assert (data == "abcdefabcdefabcdefabcdefabcdefabcdef");
inflater >> data;
assert (data == "abcdefabcdefabcdefabcdefabcdefabcdef");
data.clear();
inflater >> data;
assert (data.empty());
assert (inflater.eof());
inflater.reset();
inflater >> data;
assert (data == "bcdefabcdefabcdefabcdefabcdefabcdefa");
inflater >> data;
assert (data == "bcdefabcdefabcdefabcdefabcdefabcdefa");
}
void ZLibTest::setUp()
{
}
@ -166,9 +195,10 @@ CppUnit::Test* ZLibTest::suite()
CppUnit_addTest(pSuite, ZLibTest, testDeflate1);
CppUnit_addTest(pSuite, ZLibTest, testDeflate2);
CppUnit_addTest(pSuite, ZLibTest, testDeflate3);
CppUnit_addTest(pSuite, ZLibTest, testGzip1);
CppUnit_addTest(pSuite, ZLibTest, testGzip2);
CppUnit_addTest(pSuite, ZLibTest, testDeflate3);
CppUnit_addTest(pSuite, ZLibTest, testGzip1);
CppUnit_addTest(pSuite, ZLibTest, testGzip2);
CppUnit_addTest(pSuite, ZLibTest, testGzip3);
return pSuite;
return pSuite;
}

View File

@ -48,12 +48,13 @@ public:
void testDeflate1();
void testDeflate2();
void testDeflate3();
void testGzip1();
void testGzip2();
void testDeflate3();
void testGzip1();
void testGzip2();
void testGzip3();
void setUp();
void tearDown();
void setUp();
void tearDown();
static CppUnit::Test* suite();