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 // 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. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
@@ -134,6 +134,12 @@ void BinaryReaderWriterTest::write(BinaryWriter& writer)
writer.write7BitEncoded((UInt64) 1000000); writer.write7BitEncoded((UInt64) 1000000);
#endif #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");
} }
@@ -227,6 +233,13 @@ void BinaryReaderWriterTest::read(BinaryReader& reader)
assert (uint64v == 1000000); assert (uint64v == 1000000);
#endif #endif
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); reader.readRaw(3, str);
assert (str == "RAW"); assert (str == "RAW");
} }

View File

@@ -1,7 +1,7 @@
// //
// CryptTestSuite.cpp // 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. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
@@ -31,7 +31,6 @@
#include "CryptTestSuite.h" #include "CryptTestSuite.h"
#include "MD2EngineTest.h"
#include "MD4EngineTest.h" #include "MD4EngineTest.h"
#include "MD5EngineTest.h" #include "MD5EngineTest.h"
#include "SHA1EngineTest.h" #include "SHA1EngineTest.h"
@@ -43,9 +42,8 @@
CppUnit::Test* CryptTestSuite::suite() 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(MD4EngineTest::suite());
pSuite->addTest(MD5EngineTest::suite()); pSuite->addTest(MD5EngineTest::suite());
pSuite->addTest(SHA1EngineTest::suite()); pSuite->addTest(SHA1EngineTest::suite());

View File

@@ -74,6 +74,21 @@ 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() void DateTimeFormatterTest::testRFC822()
{ {
DateTime dt(2005, 1, 8, 12, 30, 00); DateTime dt(2005, 1, 8, 12, 30, 00);
@@ -219,6 +234,7 @@ 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, testISO8601);
CppUnit_addTest(pSuite, DateTimeFormatterTest, testISO8601Frac);
CppUnit_addTest(pSuite, DateTimeFormatterTest, testRFC822); CppUnit_addTest(pSuite, DateTimeFormatterTest, testRFC822);
CppUnit_addTest(pSuite, DateTimeFormatterTest, testRFC1123); CppUnit_addTest(pSuite, DateTimeFormatterTest, testRFC1123);
CppUnit_addTest(pSuite, DateTimeFormatterTest, testHTTP); CppUnit_addTest(pSuite, DateTimeFormatterTest, testHTTP);

View File

@@ -47,6 +47,7 @@ public:
~DateTimeFormatterTest(); ~DateTimeFormatterTest();
void testISO8601(); void testISO8601();
void testISO8601Frac();
void testRFC822(); void testRFC822();
void testRFC1123(); void testRFC1123();
void testHTTP(); void testHTTP();

View File

@@ -107,6 +107,132 @@ 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() void DateTimeParserTest::testRFC822()
{ {
int tzd; int tzd;
@@ -544,6 +670,7 @@ 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, testISO8601);
CppUnit_addTest(pSuite, DateTimeParserTest, testISO8601Frac);
CppUnit_addTest(pSuite, DateTimeParserTest, testRFC822); CppUnit_addTest(pSuite, DateTimeParserTest, testRFC822);
CppUnit_addTest(pSuite, DateTimeParserTest, testRFC1123); CppUnit_addTest(pSuite, DateTimeParserTest, testRFC1123);
CppUnit_addTest(pSuite, DateTimeParserTest, testHTTP); CppUnit_addTest(pSuite, DateTimeParserTest, testHTTP);

View File

@@ -47,6 +47,7 @@ public:
~DateTimeParserTest(); ~DateTimeParserTest();
void testISO8601(); void testISO8601();
void testISO8601Frac();
void testRFC822(); void testRFC822();
void testRFC1123(); void testRFC1123();
void testHTTP(); void testHTTP();

View File

@@ -394,10 +394,10 @@ void DateTimeTest::testRelational()
const DateTime& U = u; const DateTime& U = u;
u.assign(values[j].year, values[j].month, values[j].day); u.assign(values[j].year, values[j].month, values[j].day);
loop_2_assert(i, j, j < i == U < V); loop_2_assert(i, j, (j < i) == (U < V));
loop_2_assert(i, j, j <= i == U <= V); loop_2_assert(i, j, (j <= i) == (U <= V));
loop_2_assert(i, j, j >= i == U >= V); loop_2_assert(i, j, (j >= i) == (U >= V));
loop_2_assert(i, j, j > i == U > V); loop_2_assert(i, j, (j > i) == (U > V));
} }
} }
} }

View File

@@ -80,6 +80,8 @@ void FPETest::testClassify()
#pragma OPTIMIZE OFF #pragma OPTIMIZE OFF
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
#pragma optimize("", off) #pragma optimize("", off)
#elif defined(__APPLE__)
#pragma GCC optimization_level 0
#endif #endif
@@ -129,6 +131,8 @@ void FPETest::testFlags()
#pragma OPTIMIZE ON #pragma OPTIMIZE ON
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
#pragma optimize("", on) #pragma optimize("", on)
#elif defined(__APPLE__)
#pragma GCC optimization_level reset
#endif #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() void FileStreamTest::setUp()
{ {
} }
@@ -328,6 +349,7 @@ CppUnit::Test* FileStreamTest::suite()
CppUnit_addTest(pSuite, FileStreamTest, testOpenModeAte); CppUnit_addTest(pSuite, FileStreamTest, testOpenModeAte);
CppUnit_addTest(pSuite, FileStreamTest, testOpenModeApp); CppUnit_addTest(pSuite, FileStreamTest, testOpenModeApp);
CppUnit_addTest(pSuite, FileStreamTest, testSeek); CppUnit_addTest(pSuite, FileStreamTest, testSeek);
CppUnit_addTest(pSuite, FileStreamTest, testMultiOpen);
return pSuite; return pSuite;
} }

View File

@@ -56,6 +56,7 @@ public:
void testOpenModeAte(); void testOpenModeAte();
void testOpenModeApp(); void testOpenModeApp();
void testSeek(); void testSeek();
void testMultiOpen();
void setUp(); void setUp();
void tearDown(); void tearDown();

View File

@@ -1,7 +1,7 @@
// //
// FileTest.cpp // 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. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
@@ -60,17 +60,6 @@ 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() void FileTest::testFileAttributes1()
{ {
File f("testfile.dat"); File f("testfile.dat");
@@ -214,6 +203,17 @@ 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() void FileTest::testFileAttributes2()
{ {
TemporaryFile f; TemporaryFile f;
@@ -249,13 +249,15 @@ void FileTest::testFileAttributes3()
{ {
#if defined(POCO_OS_FAMILY_UNIX) #if defined(POCO_OS_FAMILY_UNIX)
File f("/dev/console"); File f("/dev/console");
#elif defined(POCO_OS_FAMILY_WINDOWS) #elif defined(POCO_OS_FAMILY_WINDOWS) && !defined(_WIN32_WCE)
File f("CON"); File f("CON");
#endif #endif
#if !defined(_WIN32_WCE)
assert (f.isDevice()); assert (f.isDevice());
assert (!f.isFile()); assert (!f.isFile());
assert (!f.isDirectory()); assert (!f.isDirectory());
#endif
} }
@@ -287,6 +289,12 @@ void FileTest::testCompare()
void FileTest::testRootDir() void FileTest::testRootDir()
{ {
#if defined(POCO_OS_FAMILY_WINDOWS) #if defined(POCO_OS_FAMILY_WINDOWS)
#if defined(_WIN32_WCE)
File f1("\\");
File f2("/");
assert (f1.exists());
assert (f2.exists());
#else
File f1("/"); File f1("/");
File f2("c:/"); File f2("c:/");
File f3("c:\\"); File f3("c:\\");
@@ -295,6 +303,7 @@ void FileTest::testRootDir()
assert (f2.exists()); assert (f2.exists());
assert (f3.exists()); assert (f3.exists());
assert (f4.exists()); assert (f4.exists());
#endif
#else #else
File f1("/"); File f1("/");
assert (f1.exists()); assert (f1.exists());

View File

@@ -1,45 +1,32 @@
// //
// FormatTest.cpp // 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. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// All rights reserved. // All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Permission is hereby granted, free of charge, to any person or organization
// modification, are permitted provided that the following conditions // obtaining a copy of the software and accompanying documentation covered by
// are met: // 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:
// //
// 1. Redistributions of source code must retain the above copyright // The copyright notices in the Software and this entire statement, including
// notice, this list of conditions and the following disclaimer. // 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.
// //
// 2. Redistributions in binary form must reproduce the above copyright // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// notice, this list of conditions and the following disclaimer in the // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// documentation and/or other materials provided with the distribution. // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// 3. Redistributions in any form must be accompanied by information on // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// how to obtain complete source code for this software and any // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// accompanying software that uses this software. The source code // DEALINGS IN THE SOFTWARE.
// 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.
// //
@@ -299,6 +286,7 @@ void FormatTest::testAnyInt()
assert (s == "42"); assert (s == "42");
} }
void FormatTest::testFloatFix() void FormatTest::testFloatFix()
{ {
double d = 1.5; double d = 1.5;
@@ -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() void FormatTest::setUp()
{ {
} }
@@ -403,6 +404,7 @@ CppUnit::Test* FormatTest::suite()
CppUnit_addTest(pSuite, FormatTest, testFloatSci); CppUnit_addTest(pSuite, FormatTest, testFloatSci);
CppUnit_addTest(pSuite, FormatTest, testString); CppUnit_addTest(pSuite, FormatTest, testString);
CppUnit_addTest(pSuite, FormatTest, testMultiple); CppUnit_addTest(pSuite, FormatTest, testMultiple);
CppUnit_addTest(pSuite, FormatTest, testIndex);
return pSuite; return pSuite;
} }

View File

@@ -67,6 +67,7 @@ public:
void testFloatSci(); void testFloatSci();
void testString(); void testString();
void testMultiple(); void testMultiple();
void testIndex();
void setUp(); void setUp();
void tearDown(); void tearDown();

View File

@@ -32,7 +32,6 @@
#include "FoundationTestSuite.h" #include "FoundationTestSuite.h"
#include "CoreTestSuite.h" #include "CoreTestSuite.h"
#include "DynamicTestSuite.h"
#include "DateTimeTestSuite.h" #include "DateTimeTestSuite.h"
#include "StreamsTestSuite.h" #include "StreamsTestSuite.h"
#include "CryptTestSuite.h" #include "CryptTestSuite.h"
@@ -44,7 +43,9 @@
#include "UUIDTestSuite.h" #include "UUIDTestSuite.h"
#include "TextTestSuite.h" #include "TextTestSuite.h"
#include "URITestSuite.h" #include "URITestSuite.h"
#if !defined(POCO_VXWORKS)
#include "ProcessesTestSuite.h" #include "ProcessesTestSuite.h"
#endif
#include "TaskTestSuite.h" #include "TaskTestSuite.h"
#include "EventTestSuite.h" #include "EventTestSuite.h"
#include "CacheTestSuite.h" #include "CacheTestSuite.h"
@@ -56,7 +57,6 @@ CppUnit::Test* FoundationTestSuite::suite()
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("FoundationTestSuite"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("FoundationTestSuite");
pSuite->addTest(CoreTestSuite::suite()); pSuite->addTest(CoreTestSuite::suite());
pSuite->addTest(DynamicTestSuite::suite());
pSuite->addTest(DateTimeTestSuite::suite()); pSuite->addTest(DateTimeTestSuite::suite());
pSuite->addTest(StreamsTestSuite::suite()); pSuite->addTest(StreamsTestSuite::suite());
pSuite->addTest(CryptTestSuite::suite()); pSuite->addTest(CryptTestSuite::suite());
@@ -68,7 +68,9 @@ CppUnit::Test* FoundationTestSuite::suite()
pSuite->addTest(UUIDTestSuite::suite()); pSuite->addTest(UUIDTestSuite::suite());
pSuite->addTest(TextTestSuite::suite()); pSuite->addTest(TextTestSuite::suite());
pSuite->addTest(URITestSuite::suite()); pSuite->addTest(URITestSuite::suite());
#if !defined(POCO_VXWORKS)
pSuite->addTest(ProcessesTestSuite::suite()); pSuite->addTest(ProcessesTestSuite::suite());
#endif
pSuite->addTest(TaskTestSuite::suite()); pSuite->addTest(TaskTestSuite::suite());
pSuite->addTest(EventTestSuite::suite()); pSuite->addTest(EventTestSuite::suite());
pSuite->addTest(CacheTestSuite::suite()); pSuite->addTest(CacheTestSuite::suite());

View File

@@ -1,7 +1,7 @@
// //
// GlobTest.cpp // 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. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
@@ -470,16 +470,35 @@ void GlobTest::testGlob()
assert (files.find("globtest/src/") != files.end()); assert (files.find("globtest/src/") != files.end());
assert (files.find("globtest/testsuite/") != files.end()); assert (files.find("globtest/testsuite/") != files.end());
#if !defined(_WIN32_WCE)
// won't work if current directory is root dir
files.clear(); files.clear();
Glob::glob("../*/globtest/*/", files); Glob::glob("../*/globtest/*/", files);
translatePaths(files); translatePaths(files);
assert (files.size() == 3); assert (files.size() == 3);
#endif
File dir("globtest"); File dir("globtest");
dir.remove(true); 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) void GlobTest::createFile(const std::string& path)
{ {
Path p(path, Path::PATH_UNIX); Path p(path, Path::PATH_UNIX);
@@ -524,6 +543,7 @@ CppUnit::Test* GlobTest::suite()
CppUnit_addTest(pSuite, GlobTest, testMisc); CppUnit_addTest(pSuite, GlobTest, testMisc);
CppUnit_addTest(pSuite, GlobTest, testCaseless); CppUnit_addTest(pSuite, GlobTest, testCaseless);
CppUnit_addTest(pSuite, GlobTest, testGlob); CppUnit_addTest(pSuite, GlobTest, testGlob);
CppUnit_addTest(pSuite, GlobTest, testMatchEmptyPattern);
return pSuite; return pSuite;
} }

View File

@@ -54,6 +54,7 @@ public:
void testMisc(); void testMisc();
void testGlob(); void testGlob();
void testCaseless(); void testCaseless();
void testMatchEmptyPattern();
void setUp(); void setUp();
void tearDown(); void tearDown();

View File

@@ -1,7 +1,7 @@
// //
// HashSetTest.cpp // 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. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
@@ -37,6 +37,7 @@
#include <set> #include <set>
using Poco::Hash;
using Poco::HashSet; using Poco::HashSet;
@@ -54,16 +55,16 @@ void HashSetTest::testInsert()
{ {
const int N = 1000; const int N = 1000;
HashSet<int> hs; HashSet<int, Hash<int> > hs;
assert (hs.empty()); assert (hs.empty());
for (int i = 0; i < N; ++i) for (int i = 0; i < N; ++i)
{ {
std::pair<HashSet<int>::Iterator, bool> res = hs.insert(i); std::pair<HashSet<int, Hash<int> >::Iterator, bool> res = hs.insert(i);
assert (*res.first == i); assert (*res.first == i);
assert (res.second); assert (res.second);
HashSet<int>::Iterator it = hs.find(i); HashSet<int, Hash<int> >::Iterator it = hs.find(i);
assert (it != hs.end()); assert (it != hs.end());
assert (*it == i); assert (*it == i);
assert (hs.size() == i + 1); assert (hs.size() == i + 1);
@@ -73,14 +74,14 @@ void HashSetTest::testInsert()
for (int i = 0; i < N; ++i) for (int i = 0; i < N; ++i)
{ {
HashSet<int>::Iterator it = hs.find(i); HashSet<int, Hash<int> >::Iterator it = hs.find(i);
assert (it != hs.end()); assert (it != hs.end());
assert (*it == i); assert (*it == i);
} }
for (int i = 0; i < N; ++i) for (int i = 0; i < N; ++i)
{ {
std::pair<HashSet<int>::Iterator, bool> res = hs.insert(i); std::pair<HashSet<int, Hash<int> >::Iterator, bool> res = hs.insert(i);
assert (*res.first == i); assert (*res.first == i);
assert (!res.second); assert (!res.second);
} }
@@ -91,7 +92,7 @@ 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)
{ {
@@ -102,20 +103,20 @@ void HashSetTest::testErase()
for (int i = 0; i < N; i += 2) for (int i = 0; i < N; i += 2)
{ {
hs.erase(i); hs.erase(i);
HashSet<int>::Iterator it = hs.find(i); HashSet<int, Hash<int> >::Iterator it = hs.find(i);
assert (it == hs.end()); assert (it == hs.end());
} }
assert (hs.size() == N/2); assert (hs.size() == N/2);
for (int i = 0; i < N; i += 2) for (int i = 0; i < N; i += 2)
{ {
HashSet<int>::Iterator it = hs.find(i); HashSet<int, Hash<int> >::Iterator it = hs.find(i);
assert (it == hs.end()); assert (it == hs.end());
} }
for (int i = 1; i < N; i += 2) for (int i = 1; i < N; i += 2)
{ {
HashSet<int>::Iterator it = hs.find(i); HashSet<int, Hash<int> >::Iterator it = hs.find(i);
assert (it != hs.end()); assert (it != hs.end());
assert (*it == i); assert (*it == i);
} }
@@ -127,7 +128,7 @@ void HashSetTest::testErase()
for (int i = 0; i < N; ++i) for (int i = 0; i < N; ++i)
{ {
HashSet<int>::Iterator it = hs.find(i); HashSet<int, Hash<int> >::Iterator it = hs.find(i);
assert (it != hs.end()); assert (it != hs.end());
assert (*it == i); assert (*it == i);
} }
@@ -138,7 +139,7 @@ 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)
{ {
@@ -146,7 +147,7 @@ void HashSetTest::testIterator()
} }
std::set<int> values; std::set<int> values;
HashSet<int>::Iterator it = hs.begin(); HashSet<int, Hash<int> >::Iterator it = hs.begin();
while (it != hs.end()) while (it != hs.end())
{ {
assert (values.find(*it) == values.end()); assert (values.find(*it) == values.end());
@@ -162,7 +163,7 @@ 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)
{ {
@@ -170,7 +171,7 @@ void HashSetTest::testConstIterator()
} }
std::set<int> values; std::set<int> values;
HashSet<int>::ConstIterator it = hs.begin(); HashSet<int, Hash<int> >::ConstIterator it = hs.begin();
while (it != hs.end()) while (it != hs.end())
{ {
assert (values.find(*it) == values.end()); assert (values.find(*it) == values.end());

View File

@@ -1,7 +1,7 @@
// //
// LinearHashTableTest.cpp // 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. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
@@ -42,6 +42,7 @@
using Poco::LinearHashTable; using Poco::LinearHashTable;
using Poco::Hash;
using Poco::HashTable; using Poco::HashTable;
using Poco::Stopwatch; using Poco::Stopwatch;
using Poco::NumberFormatter; using Poco::NumberFormatter;
@@ -61,35 +62,38 @@ void LinearHashTableTest::testInsert()
{ {
const int N = 1000; const int N = 1000;
LinearHashTable<int> ht; LinearHashTable<int, Hash<int> > ht;
assert (ht.empty()); assert (ht.empty());
for (int i = 0; i < N; ++i) for (int i = 0; i < N; ++i)
{ {
std::pair<LinearHashTable<int>::Iterator, bool> res = ht.insert(i); std::pair<LinearHashTable<int, Hash<int> >::Iterator, bool> res = ht.insert(i);
assert (*res.first == i); assert (*res.first == i);
assert (res.second); assert (res.second);
LinearHashTable<int>::Iterator it = ht.find(i); LinearHashTable<int, Hash<int> >::Iterator it = ht.find(i);
assert (it != ht.end()); assert (it != ht.end());
assert (*it == i); assert (*it == i);
assert (ht.size() == i + 1); assert (ht.size() == i + 1);
} }
assert (ht.buckets() == N + 1);
assert (!ht.empty()); assert (!ht.empty());
for (int i = 0; i < N; ++i) for (int i = 0; i < N; ++i)
{ {
LinearHashTable<int>::Iterator it = ht.find(i); LinearHashTable<int, Hash<int> >::Iterator it = ht.find(i);
assert (it != ht.end()); assert (it != ht.end());
assert (*it == i); assert (*it == i);
} }
for (int i = 0; i < N; ++i) for (int i = 0; i < N; ++i)
{ {
std::pair<LinearHashTable<int>::Iterator, bool> res = ht.insert(i); std::pair<LinearHashTable<int, Hash<int> >::Iterator, bool> res = ht.insert(i);
assert (*res.first == i); assert (*res.first == i);
assert (!res.second); assert (!res.second);
assert (ht.size() == N);
assert (ht.buckets() == N + 1);
} }
} }
@@ -98,7 +102,7 @@ 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)
{ {
@@ -109,20 +113,20 @@ void LinearHashTableTest::testErase()
for (int i = 0; i < N; i += 2) for (int i = 0; i < N; i += 2)
{ {
ht.erase(i); ht.erase(i);
LinearHashTable<int>::Iterator it = ht.find(i); LinearHashTable<int, Hash<int> >::Iterator it = ht.find(i);
assert (it == ht.end()); assert (it == ht.end());
} }
assert (ht.size() == N/2); assert (ht.size() == N/2);
for (int i = 0; i < N; i += 2) for (int i = 0; i < N; i += 2)
{ {
LinearHashTable<int>::Iterator it = ht.find(i); LinearHashTable<int, Hash<int> >::Iterator it = ht.find(i);
assert (it == ht.end()); assert (it == ht.end());
} }
for (int i = 1; i < N; i += 2) for (int i = 1; i < N; i += 2)
{ {
LinearHashTable<int>::Iterator it = ht.find(i); LinearHashTable<int, Hash<int> >::Iterator it = ht.find(i);
assert (it != ht.end()); assert (it != ht.end());
assert (*it == i); assert (*it == i);
} }
@@ -134,7 +138,7 @@ void LinearHashTableTest::testErase()
for (int i = 0; i < N; ++i) for (int i = 0; i < N; ++i)
{ {
LinearHashTable<int>::Iterator it = ht.find(i); LinearHashTable<int, Hash<int> >::Iterator it = ht.find(i);
assert (it != ht.end()); assert (it != ht.end());
assert (*it == i); assert (*it == i);
} }
@@ -145,7 +149,7 @@ 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)
{ {
@@ -153,7 +157,7 @@ void LinearHashTableTest::testIterator()
} }
std::set<int> values; std::set<int> values;
LinearHashTable<int>::Iterator it = ht.begin(); LinearHashTable<int, Hash<int> >::Iterator it = ht.begin();
while (it != ht.end()) while (it != ht.end())
{ {
assert (values.find(*it) == values.end()); assert (values.find(*it) == values.end());
@@ -169,7 +173,7 @@ 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)
{ {
@@ -177,7 +181,7 @@ void LinearHashTableTest::testConstIterator()
} }
std::set<int> values; std::set<int> values;
LinearHashTable<int>::ConstIterator it = ht.begin(); LinearHashTable<int, Hash<int> >::ConstIterator it = ht.begin();
while (it != ht.end()) while (it != ht.end())
{ {
assert (values.find(*it) == values.end()); assert (values.find(*it) == values.end());
@@ -188,9 +192,9 @@ void LinearHashTableTest::testConstIterator()
assert (values.size() == N); assert (values.size() == N);
values.clear(); values.clear();
const LinearHashTable<int> cht(ht); const LinearHashTable<int, Hash<int> > cht(ht);
LinearHashTable<int>::ConstIterator cit = cht.begin(); LinearHashTable<int, Hash<int> >::ConstIterator cit = cht.begin();
while (cit != cht.end()) while (cit != cht.end())
{ {
assert (values.find(*cit) == values.end()); assert (values.find(*cit) == values.end());
@@ -208,7 +212,7 @@ void LinearHashTableTest::testPerformanceInt()
Stopwatch sw; Stopwatch sw;
{ {
LinearHashTable<int> lht(N); LinearHashTable<int, Hash<int> > lht(N);
sw.start(); sw.start();
for (int i = 0; i < N; ++i) for (int i = 0; i < N; ++i)
{ {
@@ -285,7 +289,7 @@ void LinearHashTableTest::testPerformanceStr()
} }
{ {
LinearHashTable<std::string> lht(N); LinearHashTable<std::string, Hash<std::string> > lht(N);
sw.start(); sw.start();
for (int i = 0; i < N; ++i) for (int i = 0; i < N; ++i)
{ {

View File

@@ -1,7 +1,7 @@
// //
// LocalDateTimeTest.cpp // 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. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
@@ -42,13 +42,18 @@
#include "Poco/DateTimeFormatter.h" #include "Poco/DateTimeFormatter.h"
#include <ctime> #include <ctime>
#include <iostream> #include <iostream>
#if defined(_WIN32_WCE)
#include "wce_time.h"
#endif
using Poco::LocalDateTime; using Poco::LocalDateTime;
using Poco::DateTime; using Poco::DateTime;
using Poco::Timestamp; using Poco::Timestamp;
using Poco::Timespan; using Poco::Timespan;
using Poco::Timezone; using Poco::Timezone;
#ifndef _WIN32_WCE
using std::strftime;
#endif
LocalDateTimeTest::LocalDateTimeTest(const std::string& name): CppUnit::TestCase(name) LocalDateTimeTest::LocalDateTimeTest(const std::string& name): CppUnit::TestCase(name)
@@ -379,6 +384,7 @@ void LocalDateTimeTest::testSwap()
void LocalDateTimeTest::testTimezone() void LocalDateTimeTest::testTimezone()
{ {
#if !defined(_WIN32_WCE)
std::time_t tINCREMENT = (30 * 24 * 60 * 60); // 30 days std::time_t tINCREMENT = (30 * 24 * 60 * 60); // 30 days
Timespan tsINCREMENT(30*Timespan::DAYS); Timespan tsINCREMENT(30*Timespan::DAYS);
LocalDateTime now; LocalDateTime now;
@@ -461,6 +467,7 @@ void LocalDateTimeTest::testTimezone()
<< " - failed to locate DST boundary, timezone test skipped." << " - failed to locate DST boundary, timezone test skipped."
<< std::endl; << std::endl;
} }
#endif
} }

View File

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

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 // 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. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
@@ -72,10 +72,14 @@ void NotificationCenterTest::test2()
{ {
NotificationCenter nc; NotificationCenter nc;
nc.addObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1)); nc.addObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
assert (nc.hasObservers());
assert (nc.countObservers() == 1);
nc.postNotification(new Notification); nc.postNotification(new Notification);
assert (_set.size() == 1); assert (_set.size() == 1);
assert (_set.find("handle1") != _set.end()); assert (_set.find("handle1") != _set.end());
nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1)); nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
assert (!nc.hasObservers());
assert (nc.countObservers() == 0);
} }
@@ -84,12 +88,16 @@ void NotificationCenterTest::test3()
NotificationCenter nc; NotificationCenter nc;
nc.addObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1)); nc.addObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
nc.addObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle2)); nc.addObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle2));
assert (nc.hasObservers());
assert (nc.countObservers() == 2);
nc.postNotification(new Notification); nc.postNotification(new Notification);
assert (_set.size() == 2); assert (_set.size() == 2);
assert (_set.find("handle1") != _set.end()); assert (_set.find("handle1") != _set.end());
assert (_set.find("handle2") != _set.end()); assert (_set.find("handle2") != _set.end());
nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1)); nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle2)); nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle2));
assert (!nc.hasObservers());
assert (nc.countObservers() == 0);
} }

View File

@@ -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() void NumberFormatterTest::setUp()
{ {
} }
@@ -168,6 +182,7 @@ CppUnit::Test* NumberFormatterTest::suite()
CppUnit_addTest(pSuite, NumberFormatterTest, testFormat); CppUnit_addTest(pSuite, NumberFormatterTest, testFormat);
CppUnit_addTest(pSuite, NumberFormatterTest, testFormat0); CppUnit_addTest(pSuite, NumberFormatterTest, testFormat0);
CppUnit_addTest(pSuite, NumberFormatterTest, testFormatHex); CppUnit_addTest(pSuite, NumberFormatterTest, testFormatHex);
CppUnit_addTest(pSuite, NumberFormatterTest, testFormatFloat);
return pSuite; return pSuite;
} }

View File

@@ -49,6 +49,7 @@ public:
void testFormat(); void testFormat();
void testFormat0(); void testFormat0();
void testFormatHex(); void testFormatHex();
void testFormatFloat();
void setUp(); void setUp();
void tearDown(); void tearDown();

View File

@@ -1563,6 +1563,9 @@ void PathTest::testFind()
bool found = Path::find(Environment::get("PATH"), "ls", p); bool found = Path::find(Environment::get("PATH"), "ls", p);
bool notfound = Path::find(Environment::get("PATH"), "xxxyyy123", p); bool notfound = Path::find(Environment::get("PATH"), "xxxyyy123", p);
#elif defined(POCO_OS_FAMILY_WINDOWS) #elif defined(POCO_OS_FAMILY_WINDOWS)
#if defined(_WIN32_WCE)
return;
#endif
bool found = Path::find(Environment::get("PATH"), "cmd.exe", p); bool found = Path::find(Environment::get("PATH"), "cmd.exe", p);
bool notfound = Path::find(Environment::get("PATH"), "xxxyyy123.zzz", p); bool notfound = Path::find(Environment::get("PATH"), "xxxyyy123.zzz", p);
#else #else
@@ -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() void PathTest::setUp()
{ {
} }
@@ -1647,6 +1666,7 @@ CppUnit::Test* PathTest::suite()
CppUnit_addTest(pSuite, PathTest, testFind); CppUnit_addTest(pSuite, PathTest, testFind);
CppUnit_addTest(pSuite, PathTest, testSwap); CppUnit_addTest(pSuite, PathTest, testSwap);
CppUnit_addTest(pSuite, PathTest, testResolve); CppUnit_addTest(pSuite, PathTest, testResolve);
CppUnit_addTest(pSuite, PathTest, testPushPop);
return pSuite; return pSuite;
} }

View File

@@ -1,7 +1,7 @@
// //
// ProcessTest.cpp // 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. // Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
@@ -66,6 +66,10 @@ void ProcessTest::testLaunch()
#if defined(POCO_OS_FAMILY_UNIX) #if defined(POCO_OS_FAMILY_UNIX)
cmd = "./"; cmd = "./";
cmd += name; cmd += name;
#elif defined(_WIN32_WCE)
cmd = "\\";
cmd += name;
cmd += ".EXE";
#else #else
cmd = name; cmd = name;
#endif #endif
@@ -82,6 +86,7 @@ void ProcessTest::testLaunch()
void ProcessTest::testLaunchRedirectIn() void ProcessTest::testLaunchRedirectIn()
{ {
#if !defined(_WIN32_WCE)
std::string name("TestApp"); std::string name("TestApp");
std::string cmd; std::string cmd;
#if defined(_DEBUG) #if defined(_DEBUG)
@@ -104,11 +109,13 @@ void ProcessTest::testLaunchRedirectIn()
ostr.close(); ostr.close();
int rc = ph.wait(); int rc = ph.wait();
assert (rc == 100); assert (rc == 100);
#endif // !defined(_WIN32_WCE)
} }
void ProcessTest::testLaunchRedirectOut() void ProcessTest::testLaunchRedirectOut()
{ {
#if !defined(_WIN32_WCE)
std::string name("TestApp"); std::string name("TestApp");
std::string cmd; std::string cmd;
#if defined(_DEBUG) #if defined(_DEBUG)
@@ -133,6 +140,7 @@ void ProcessTest::testLaunchRedirectOut()
assert (s == "Hello, world!"); assert (s == "Hello, world!");
int rc = ph.wait(); int rc = ph.wait();
assert (rc == 1); assert (rc == 1);
#endif // !defined(_WIN32_WCE)
} }

View File

@@ -40,9 +40,12 @@ 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(ManifestTest::suite());
#if !defined(_WIN32) || defined(_DLL)
pSuite->addTest(SharedLibraryTest::suite());
pSuite->addTest(ClassLoaderTest::suite()); pSuite->addTest(ClassLoaderTest::suite());
#endif
return pSuite; return pSuite;
} }

View File

@@ -144,6 +144,18 @@ void StreamConverterTest::testIdentityUTF8In()
StreamCopier::copyStream(converter4, ostr4); StreamCopier::copyStream(converter4, ostr4);
assert (ostr4.str() == text); assert (ostr4.str() == text);
assert (converter4.errors() == 0); 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 // 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. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
@@ -35,7 +35,7 @@
#include "CppUnit/TestSuite.h" #include "CppUnit/TestSuite.h"
#include "Poco/StreamTokenizer.h" #include "Poco/StreamTokenizer.h"
#include "Poco/Token.h" #include "Poco/Token.h"
#include <cctype> #include "Poco/Ascii.h"
#include <sstream> #include <sstream>
@@ -44,6 +44,7 @@ using Poco::Token;
using Poco::InvalidToken; using Poco::InvalidToken;
using Poco::EOFToken; using Poco::EOFToken;
using Poco::WhitespaceToken; using Poco::WhitespaceToken;
using Poco::Ascii;
class IdentifierToken: public Token class IdentifierToken: public Token
@@ -64,7 +65,7 @@ public:
bool start(char c, std::istream& istr) bool start(char c, std::istream& istr)
{ {
if (std::isalpha(c)) if (c != -1 && Ascii::isAlpha(c))
{ {
_value = c; _value = c;
return true; return true;
@@ -75,7 +76,7 @@ public:
void finish(std::istream& istr) void finish(std::istream& istr)
{ {
int c = istr.peek(); int c = istr.peek();
while (std::isalnum(c)) while (c != -1 && Ascii::isAlphaNumeric(c))
{ {
istr.get(); istr.get();
_value += c; _value += c;
@@ -103,7 +104,7 @@ public:
bool start(char c, std::istream& istr) bool start(char c, std::istream& istr)
{ {
if (std::isdigit(c)) if (c != -1 && Ascii::isDigit(c))
{ {
_value = c; _value = c;
return true; return true;
@@ -114,7 +115,7 @@ public:
void finish(std::istream& istr) void finish(std::istream& istr)
{ {
int c = istr.peek(); int c = istr.peek();
while (std::isdigit(c)) while (c != -1 && Ascii::isDigit(c))
{ {
istr.get(); istr.get();
_value += c; _value += c;

View File

@@ -42,6 +42,7 @@
#include "LineEndingConverterTest.h" #include "LineEndingConverterTest.h"
#include "TeeStreamTest.h" #include "TeeStreamTest.h"
#include "FileStreamTest.h" #include "FileStreamTest.h"
#include "MemoryStreamTest.h"
CppUnit::Test* StreamsTestSuite::suite() CppUnit::Test* StreamsTestSuite::suite()
@@ -59,6 +60,7 @@ CppUnit::Test* StreamsTestSuite::suite()
pSuite->addTest(LineEndingConverterTest::suite()); pSuite->addTest(LineEndingConverterTest::suite());
pSuite->addTest(TeeStreamTest::suite()); pSuite->addTest(TeeStreamTest::suite());
pSuite->addTest(FileStreamTest::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 // 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. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
@@ -36,11 +36,13 @@
#include "Poco/TextIterator.h" #include "Poco/TextIterator.h"
#include "Poco/Latin1Encoding.h" #include "Poco/Latin1Encoding.h"
#include "Poco/UTF8Encoding.h" #include "Poco/UTF8Encoding.h"
#include "Poco/UTF16Encoding.h"
using Poco::TextIterator; using Poco::TextIterator;
using Poco::Latin1Encoding; using Poco::Latin1Encoding;
using Poco::UTF8Encoding; using Poco::UTF8Encoding;
using Poco::UTF16Encoding;
TextIteratorTest::TextIteratorTest(const std::string& name): CppUnit::TestCase(name) TextIteratorTest::TextIteratorTest(const std::string& name): CppUnit::TestCase(name)
@@ -202,6 +204,50 @@ 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() void TextIteratorTest::testSwap()
{ {
Latin1Encoding encoding; Latin1Encoding encoding;
@@ -238,6 +284,8 @@ CppUnit::Test* TextIteratorTest::suite()
CppUnit_addTest(pSuite, TextIteratorTest, testEmptyUTF8); CppUnit_addTest(pSuite, TextIteratorTest, testEmptyUTF8);
CppUnit_addTest(pSuite, TextIteratorTest, testOneUTF8); CppUnit_addTest(pSuite, TextIteratorTest, testOneUTF8);
CppUnit_addTest(pSuite, TextIteratorTest, testUTF8); CppUnit_addTest(pSuite, TextIteratorTest, testUTF8);
CppUnit_addTest(pSuite, TextIteratorTest, testUTF8Supplementary);
CppUnit_addTest(pSuite, TextIteratorTest, testUTF16Supplementary);
CppUnit_addTest(pSuite, TextIteratorTest, testSwap); CppUnit_addTest(pSuite, TextIteratorTest, testSwap);
return pSuite; return pSuite;

View File

@@ -52,6 +52,8 @@ public:
void testEmptyUTF8(); void testEmptyUTF8();
void testOneUTF8(); void testOneUTF8();
void testUTF8(); void testUTF8();
void testUTF8Supplementary();
void testUTF16Supplementary();
void testSwap(); void testSwap();
void setUp(); void setUp();

View File

@@ -1,7 +1,7 @@
// //
// TextTestSuite.cpp // 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. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
@@ -32,10 +32,14 @@
#include "TextTestSuite.h" #include "TextTestSuite.h"
#include "TextIteratorTest.h" #include "TextIteratorTest.h"
#include "TextBufferIteratorTest.h"
#include "TextConverterTest.h" #include "TextConverterTest.h"
#include "StreamConverterTest.h" #include "StreamConverterTest.h"
#include "TextEncodingTest.h" #include "TextEncodingTest.h"
#include "UTF8StringTest.h" #include "UTF8StringTest.h"
#ifdef _WINDOWS
#include "UnicodeConverterTest.h"
#endif
CppUnit::Test* TextTestSuite::suite() CppUnit::Test* TextTestSuite::suite()
@@ -43,10 +47,14 @@ CppUnit::Test* TextTestSuite::suite()
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("TextTestSuite"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("TextTestSuite");
pSuite->addTest(TextIteratorTest::suite()); pSuite->addTest(TextIteratorTest::suite());
pSuite->addTest(TextBufferIteratorTest::suite());
pSuite->addTest(TextConverterTest::suite()); pSuite->addTest(TextConverterTest::suite());
pSuite->addTest(StreamConverterTest::suite()); pSuite->addTest(StreamConverterTest::suite());
pSuite->addTest(TextEncodingTest::suite()); pSuite->addTest(TextEncodingTest::suite());
pSuite->addTest(UTF8StringTest::suite()); pSuite->addTest(UTF8StringTest::suite());
#ifdef _WINDOWS
pSuite->addTest(UnicodeConverterTest::suite());
#endif
return pSuite; return pSuite;
} }

View File

@@ -39,12 +39,12 @@
#include "Poco/Event.h" #include "Poco/Event.h"
#if defined(__sun) && defined(__SVR4) #if defined(__sun) && defined(__SVR4)
# if !defined(__EXTENSIONS__) # if !defined(__EXTENSIONS__)
# define __EXTENSIONS__ #define __EXTENSIONS__
# endif #endif
// must be limits.h for PTHREAD_STACK_MIN on Solaris // must be limits.h for PTHREAD_STACK_MIN on Solaris
# include <limits.h> # include <limits.h>
#else #else
# include <climits> #include <climits>
#endif #endif
@@ -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() void ThreadTest::setUp()
{ {
} }
@@ -329,6 +338,7 @@ CppUnit::Test* ThreadTest::suite()
CppUnit_addTest(pSuite, ThreadTest, testThreadTarget); CppUnit_addTest(pSuite, ThreadTest, testThreadTarget);
CppUnit_addTest(pSuite, ThreadTest, testThreadFunction); CppUnit_addTest(pSuite, ThreadTest, testThreadFunction);
CppUnit_addTest(pSuite, ThreadTest, testThreadStackSize); CppUnit_addTest(pSuite, ThreadTest, testThreadStackSize);
CppUnit_addTest(pSuite, ThreadTest, testSleep);
return pSuite; return pSuite;
} }

View File

@@ -54,6 +54,7 @@ public:
void testThreadTarget(); void testThreadTarget();
void testThreadFunction(); void testThreadFunction();
void testThreadStackSize(); void testThreadStackSize();
void testSleep();
void setUp(); void setUp();
void tearDown(); void tearDown();

View File

@@ -65,15 +65,15 @@ void TimerTest::testTimer()
t.start(tc); t.start(tc);
_event.wait(); _event.wait();
sw.stop(); sw.stop();
assert (sw.elapsed() >= 90000 && sw.elapsed() < 150000); assert (sw.elapsed() >= 80000 && sw.elapsed() < 250000);
sw.restart(); sw.restart();
_event.wait(); _event.wait();
sw.stop(); sw.stop();
assert (sw.elapsed() >= 190000 && sw.elapsed() < 250000); assert (sw.elapsed() >= 180000 && sw.elapsed() < 250000);
sw.restart(); sw.restart();
_event.wait(); _event.wait();
sw.stop(); sw.stop();
assert (sw.elapsed() >= 190000 && sw.elapsed() < 250000); assert (sw.elapsed() >= 180000 && sw.elapsed() < 250000);
t.stop(); t.stop();
} }

View File

@@ -168,7 +168,7 @@ void URITest::testConstruction()
URI uri10("ldap", "[2001:db8::7]", "/c=GB?objectClass?one"); URI uri10("ldap", "[2001:db8::7]", "/c=GB?objectClass?one");
assert (uri10.getScheme() == "ldap"); assert (uri10.getScheme() == "ldap");
assert (uri10.getUserInfo().empty()); assert (uri10.getUserInfo().empty());
assert (uri10.getHost() == "[2001:db8::7]"); assert (uri10.getHost() == "2001:db8::7");
assert (uri10.getPort() == 389); assert (uri10.getPort() == 389);
assert (uri10.getAuthority() == "[2001:db8::7]"); assert (uri10.getAuthority() == "[2001:db8::7]");
assert (uri10.getPathEtc() == "/c=GB?objectClass?one"); assert (uri10.getPathEtc() == "/c=GB?objectClass?one");
@@ -180,7 +180,6 @@ void URITest::testConstruction()
assert (uri11.getPathEtc() == "/index.html?query=test#fragment"); assert (uri11.getPathEtc() == "/index.html?query=test#fragment");
assert (uri11.getQuery() == "query=test"); assert (uri11.getQuery() == "query=test");
assert (uri11.getFragment() == "fragment"); assert (uri11.getFragment() == "fragment");
} }
@@ -253,7 +252,7 @@ void URITest::testParse()
uri = "ldap://[2001:db8::7]/c=GB?objectClass?one"; uri = "ldap://[2001:db8::7]/c=GB?objectClass?one";
assert (uri.getScheme() == "ldap"); assert (uri.getScheme() == "ldap");
assert (uri.getUserInfo().empty()); assert (uri.getUserInfo().empty());
assert (uri.getHost() == "[2001:db8::7]"); assert (uri.getHost() == "2001:db8::7");
assert (uri.getPort() == 389); assert (uri.getPort() == 389);
assert (uri.getAuthority() == "[2001:db8::7]"); assert (uri.getAuthority() == "[2001:db8::7]");
assert (uri.getPath() == "/c=GB"); assert (uri.getPath() == "/c=GB");
@@ -543,6 +542,10 @@ void URITest::testToString()
uri = "./c:/Windows/system32/"; uri = "./c:/Windows/system32/";
assert (uri.toString() == "./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");
} }
@@ -735,7 +738,6 @@ void URITest::testSwap()
assert (uri2.toString() == "http://www.appinf.com/search.cgi?keyword=test%20encoded&scope=all#result"); assert (uri2.toString() == "http://www.appinf.com/search.cgi?keyword=test%20encoded&scope=all#result");
} }
void URITest::testOther() void URITest::testOther()
{ {
// The search string is "hello%world"; google happens to ignore the '%' // The search string is "hello%world"; google happens to ignore the '%'
@@ -764,6 +766,7 @@ void URITest::testOther()
assert(uri.getPathEtc() == "/search?q=pony%7eride#frag%20ment"); assert(uri.getPathEtc() == "/search?q=pony%7eride#frag%20ment");
} }
void URITest::setUp() void URITest::setUp()
{ {
} }

View File

@@ -1,7 +1,7 @@
// //
// UUIDTest.cpp // 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. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
@@ -72,37 +72,37 @@ void UUIDTest::testBuffer()
void UUIDTest::testCompare() void UUIDTest::testCompare()
{ {
UUID nil; UUID null;
assert (nil.isNil()); assert (null.isNull());
assert (UUID::nil().isNil()); assert (UUID::null().isNull());
UUID uuid1 = nil; UUID uuid1 = null;
UUID uuid2; UUID uuid2;
assert (uuid1.isNil()); assert (uuid1.isNull());
assert (uuid1 == nil); assert (uuid1 == null);
assert (!(uuid1 != nil)); assert (!(uuid1 != null));
assert (uuid1 >= nil); assert (uuid1 >= null);
assert (uuid1 <= nil); assert (uuid1 <= null);
assert (!(uuid1 > nil)); assert (!(uuid1 > null));
assert (!(uuid1 < nil)); assert (!(uuid1 < null));
assert (uuid1.toString() == "00000000-0000-0000-0000-000000000000"); assert (uuid1.toString() == "00000000-0000-0000-0000-000000000000");
uuid1 = UUID::dns(); uuid1 = UUID::dns();
assert (!uuid1.isNil()); assert (!uuid1.isNull());
assert (uuid1 != nil); assert (uuid1 != null);
assert (!(uuid1 == nil)); assert (!(uuid1 == null));
assert (uuid1 >= nil); assert (uuid1 >= null);
assert (!(uuid1 <= nil)); assert (!(uuid1 <= null));
assert (uuid1 > nil); assert (uuid1 > null);
assert (!(uuid1 < nil)); assert (!(uuid1 < null));
assert (uuid1.toString() == "6ba7b810-9dad-11d1-80b4-00c04fd430c8"); assert (uuid1.toString() == "6ba7b810-9dad-11d1-80b4-00c04fd430c8");
assert (nil != uuid1); assert (null != uuid1);
assert (!(nil == uuid1)); assert (!(null == uuid1));
assert (!(nil >= uuid1)); assert (!(null >= uuid1));
assert (nil <= uuid1); assert (null <= uuid1);
assert (!(nil > uuid1)); assert (!(null > uuid1));
assert (nil < uuid1); assert (null < uuid1);
uuid2 = uuid1; uuid2 = uuid1;
assert (uuid2 == uuid1); assert (uuid2 == uuid1);
@@ -163,6 +163,16 @@ void UUIDTest::testSwap()
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() void UUIDTest::setUp()
{ {
@@ -184,6 +194,7 @@ CppUnit::Test* UUIDTest::suite()
CppUnit_addTest(pSuite, UUIDTest, testVersion); CppUnit_addTest(pSuite, UUIDTest, testVersion);
CppUnit_addTest(pSuite, UUIDTest, testVariant); CppUnit_addTest(pSuite, UUIDTest, testVariant);
CppUnit_addTest(pSuite, UUIDTest, testSwap); CppUnit_addTest(pSuite, UUIDTest, testSwap);
CppUnit_addTest(pSuite, UUIDTest, testTryParse);
return pSuite; return pSuite;
} }

View File

@@ -52,6 +52,7 @@ public:
void testVersion(); void testVersion();
void testVariant(); void testVariant();
void testSwap(); void testSwap();
void testTryParse();
void setUp(); void setUp();
void tearDown(); void tearDown();

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 // 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. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // 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() void ZLibTest::setUp()
{ {
} }
@@ -169,6 +198,7 @@ CppUnit::Test* ZLibTest::suite()
CppUnit_addTest(pSuite, ZLibTest, testDeflate3); CppUnit_addTest(pSuite, ZLibTest, testDeflate3);
CppUnit_addTest(pSuite, ZLibTest, testGzip1); CppUnit_addTest(pSuite, ZLibTest, testGzip1);
CppUnit_addTest(pSuite, ZLibTest, testGzip2); CppUnit_addTest(pSuite, ZLibTest, testGzip2);
CppUnit_addTest(pSuite, ZLibTest, testGzip3);
return pSuite; return pSuite;
} }

View File

@@ -51,6 +51,7 @@ public:
void testDeflate3(); void testDeflate3();
void testGzip1(); void testGzip1();
void testGzip2(); void testGzip2();
void testGzip3();
void setUp(); void setUp();
void tearDown(); void tearDown();