mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-28 19:51:58 +01:00
trunk/branch integration: unit test integration
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user