diff options
author | Tobias Markmann <tm@ayena.de> | 2016-03-31 14:57:35 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2016-03-31 14:57:35 (GMT) |
commit | cfbdb43d2cadd40aa87338d41548e4bf89e146e6 (patch) | |
tree | 18d94153a302445196fc0c18586abf44a1ce4a38 /Swiften/Base/UnitTest | |
parent | 1d545a4a7fb877f021508094b88c1f17b30d8b4e (diff) | |
download | swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.zip swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.tar.bz2 |
Convert tabs to 4 spaces for all source files
Removed trailing spaces and whitespace on empty lines
in the process.
Changed CheckTabs.py tool to disallow hard tabs in source
files.
Test-Information:
Manually checked 30 random files that the conversion worked
as expected.
Change-Id: I874f99d617bd3d2bb55f02d58f22f58f9b094480
Diffstat (limited to 'Swiften/Base/UnitTest')
-rw-r--r-- | Swiften/Base/UnitTest/ByteArrayTest.cpp | 56 | ||||
-rw-r--r-- | Swiften/Base/UnitTest/DateTimeTest.cpp | 46 | ||||
-rw-r--r-- | Swiften/Base/UnitTest/IDGeneratorTest.cpp | 42 | ||||
-rw-r--r-- | Swiften/Base/UnitTest/PathTest.cpp | 24 | ||||
-rw-r--r-- | Swiften/Base/UnitTest/SimpleIDGeneratorTest.cpp | 42 | ||||
-rw-r--r-- | Swiften/Base/UnitTest/StringTest.cpp | 168 | ||||
-rw-r--r-- | Swiften/Base/UnitTest/URLTest.cpp | 192 |
7 files changed, 285 insertions, 285 deletions
diff --git a/Swiften/Base/UnitTest/ByteArrayTest.cpp b/Swiften/Base/UnitTest/ByteArrayTest.cpp index ce6b9db..2eb601b 100644 --- a/Swiften/Base/UnitTest/ByteArrayTest.cpp +++ b/Swiften/Base/UnitTest/ByteArrayTest.cpp @@ -14,44 +14,44 @@ using namespace Swift; class ByteArrayTest : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(ByteArrayTest); - CPPUNIT_TEST(testGetData_NoData); - CPPUNIT_TEST(testToString); - CPPUNIT_TEST(testToString_NullTerminated); - CPPUNIT_TEST(testToString_TwoNullTerminated); - CPPUNIT_TEST(testToString_AllNull); - CPPUNIT_TEST_SUITE_END(); + CPPUNIT_TEST_SUITE(ByteArrayTest); + CPPUNIT_TEST(testGetData_NoData); + CPPUNIT_TEST(testToString); + CPPUNIT_TEST(testToString_NullTerminated); + CPPUNIT_TEST(testToString_TwoNullTerminated); + CPPUNIT_TEST(testToString_AllNull); + CPPUNIT_TEST_SUITE_END(); - public: - void testGetData_NoData() { - ByteArray testling; + public: + void testGetData_NoData() { + ByteArray testling; - CPPUNIT_ASSERT_EQUAL(reinterpret_cast<const char*>(NULL), reinterpret_cast<const char*>(vecptr(testling))); - } + CPPUNIT_ASSERT_EQUAL(reinterpret_cast<const char*>(NULL), reinterpret_cast<const char*>(vecptr(testling))); + } - void testToString() { - ByteArray testling(createByteArray("abcde")); + void testToString() { + ByteArray testling(createByteArray("abcde")); - CPPUNIT_ASSERT_EQUAL(std::string("abcde"), byteArrayToString(testling)); - } + CPPUNIT_ASSERT_EQUAL(std::string("abcde"), byteArrayToString(testling)); + } - void testToString_NullTerminated() { - ByteArray testling(createByteArray("abcde\0", 6)); + void testToString_NullTerminated() { + ByteArray testling(createByteArray("abcde\0", 6)); - CPPUNIT_ASSERT_EQUAL(std::string("abcde"), byteArrayToString(testling)); - } + CPPUNIT_ASSERT_EQUAL(std::string("abcde"), byteArrayToString(testling)); + } - void testToString_TwoNullTerminated() { - ByteArray testling(createByteArray("abcde\0\0", 7)); + void testToString_TwoNullTerminated() { + ByteArray testling(createByteArray("abcde\0\0", 7)); - CPPUNIT_ASSERT_EQUAL(std::string("abcde"), byteArrayToString(testling)); - } + CPPUNIT_ASSERT_EQUAL(std::string("abcde"), byteArrayToString(testling)); + } - void testToString_AllNull() { - ByteArray testling(createByteArray("\0\0", 2)); + void testToString_AllNull() { + ByteArray testling(createByteArray("\0\0", 2)); - CPPUNIT_ASSERT_EQUAL(std::string(""), byteArrayToString(testling)); - } + CPPUNIT_ASSERT_EQUAL(std::string(""), byteArrayToString(testling)); + } }; CPPUNIT_TEST_SUITE_REGISTRATION(ByteArrayTest); diff --git a/Swiften/Base/UnitTest/DateTimeTest.cpp b/Swiften/Base/UnitTest/DateTimeTest.cpp index 527e251..6a82d96 100644 --- a/Swiften/Base/UnitTest/DateTimeTest.cpp +++ b/Swiften/Base/UnitTest/DateTimeTest.cpp @@ -16,37 +16,37 @@ using namespace Swift; class DateTimeTest : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(DateTimeTest); - CPPUNIT_TEST(testStringToDateTime_UTC); - CPPUNIT_TEST(testStringToDateTime_WithTimezone); - CPPUNIT_TEST(testDateTimeToString); - CPPUNIT_TEST(testDateTimeToLocalStringNotThrowingException); - CPPUNIT_TEST_SUITE_END(); + CPPUNIT_TEST_SUITE(DateTimeTest); + CPPUNIT_TEST(testStringToDateTime_UTC); + CPPUNIT_TEST(testStringToDateTime_WithTimezone); + CPPUNIT_TEST(testDateTimeToString); + CPPUNIT_TEST(testDateTimeToLocalStringNotThrowingException); + CPPUNIT_TEST_SUITE_END(); - public: - void testStringToDateTime_UTC() { - boost::posix_time::ptime time = stringToDateTime("1969-07-21T02:56:15Z"); + public: + void testStringToDateTime_UTC() { + boost::posix_time::ptime time = stringToDateTime("1969-07-21T02:56:15Z"); - CPPUNIT_ASSERT_EQUAL(std::string("1969-07-21T02:56:15"), boost::posix_time::to_iso_extended_string(time)); - } + CPPUNIT_ASSERT_EQUAL(std::string("1969-07-21T02:56:15"), boost::posix_time::to_iso_extended_string(time)); + } - void testStringToDateTime_WithTimezone() { - boost::posix_time::ptime time = stringToDateTime("1969-07-20T21:56:15-05:00"); + void testStringToDateTime_WithTimezone() { + boost::posix_time::ptime time = stringToDateTime("1969-07-20T21:56:15-05:00"); - CPPUNIT_ASSERT_EQUAL(std::string("1969-07-21T02:56:15"), boost::posix_time::to_iso_extended_string(time)); - } + CPPUNIT_ASSERT_EQUAL(std::string("1969-07-21T02:56:15"), boost::posix_time::to_iso_extended_string(time)); + } - void testDateTimeToString() { - boost::posix_time::ptime time = stringToDateTime("1969-07-20T21:56:15-05:00"); + void testDateTimeToString() { + boost::posix_time::ptime time = stringToDateTime("1969-07-20T21:56:15-05:00"); - CPPUNIT_ASSERT_EQUAL(std::string("1969-07-21T02:56:15Z"), dateTimeToString(time)); - } + CPPUNIT_ASSERT_EQUAL(std::string("1969-07-21T02:56:15Z"), dateTimeToString(time)); + } - void testDateTimeToLocalStringNotThrowingException() { - boost::posix_time::ptime time = stringToDateTime("1954-07-20T21:56:15-05:00"); + void testDateTimeToLocalStringNotThrowingException() { + boost::posix_time::ptime time = stringToDateTime("1954-07-20T21:56:15-05:00"); - CPPUNIT_ASSERT_EQUAL(std::string(""), dateTimeToLocalString(time)); - } + CPPUNIT_ASSERT_EQUAL(std::string(""), dateTimeToLocalString(time)); + } }; CPPUNIT_TEST_SUITE_REGISTRATION(DateTimeTest); diff --git a/Swiften/Base/UnitTest/IDGeneratorTest.cpp b/Swiften/Base/UnitTest/IDGeneratorTest.cpp index d03969b..08bd48b 100644 --- a/Swiften/Base/UnitTest/IDGeneratorTest.cpp +++ b/Swiften/Base/UnitTest/IDGeneratorTest.cpp @@ -15,27 +15,27 @@ using namespace Swift; class IDGeneratorTest : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(IDGeneratorTest); - CPPUNIT_TEST(testGenerate); - CPPUNIT_TEST_SUITE_END(); - - public: - IDGeneratorTest() {} - - void setUp() { - generatedIDs_.clear(); - } - - void testGenerate() { - IDGenerator testling; - for (unsigned int i = 0; i < 26*4; ++i) { - std::string id = testling.generateID(); - CPPUNIT_ASSERT(generatedIDs_.insert(id).second); - } - } - - private: - std::set<std::string> generatedIDs_; + CPPUNIT_TEST_SUITE(IDGeneratorTest); + CPPUNIT_TEST(testGenerate); + CPPUNIT_TEST_SUITE_END(); + + public: + IDGeneratorTest() {} + + void setUp() { + generatedIDs_.clear(); + } + + void testGenerate() { + IDGenerator testling; + for (unsigned int i = 0; i < 26*4; ++i) { + std::string id = testling.generateID(); + CPPUNIT_ASSERT(generatedIDs_.insert(id).second); + } + } + + private: + std::set<std::string> generatedIDs_; }; CPPUNIT_TEST_SUITE_REGISTRATION(IDGeneratorTest); diff --git a/Swiften/Base/UnitTest/PathTest.cpp b/Swiften/Base/UnitTest/PathTest.cpp index b22b570..dd2233b 100644 --- a/Swiften/Base/UnitTest/PathTest.cpp +++ b/Swiften/Base/UnitTest/PathTest.cpp @@ -13,23 +13,23 @@ using namespace Swift; class PathTest : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(PathTest); - CPPUNIT_TEST(testStringToPath); - CPPUNIT_TEST(testPathToString); - CPPUNIT_TEST_SUITE_END(); + CPPUNIT_TEST_SUITE(PathTest); + CPPUNIT_TEST(testStringToPath); + CPPUNIT_TEST(testPathToString); + CPPUNIT_TEST_SUITE_END(); - public: - void testStringToPath() { + public: + void testStringToPath() { #ifdef SWIFTEN_PLATFORM_WINDOWS - CPPUNIT_ASSERT(std::wstring(L"tron\xe7on") == stringToPath("tron\xc3\xa7on").native()); + CPPUNIT_ASSERT(std::wstring(L"tron\xe7on") == stringToPath("tron\xc3\xa7on").native()); #else - CPPUNIT_ASSERT_EQUAL(std::string("tron\xc3\xa7on"), stringToPath("tron\xc3\xa7on").native()); + CPPUNIT_ASSERT_EQUAL(std::string("tron\xc3\xa7on"), stringToPath("tron\xc3\xa7on").native()); #endif - } + } - void testPathToString() { - CPPUNIT_ASSERT_EQUAL(std::string("tron\xc3\xa7on"), pathToString(stringToPath("tron\xc3\xa7on"))); - } + void testPathToString() { + CPPUNIT_ASSERT_EQUAL(std::string("tron\xc3\xa7on"), pathToString(stringToPath("tron\xc3\xa7on"))); + } }; CPPUNIT_TEST_SUITE_REGISTRATION(PathTest); diff --git a/Swiften/Base/UnitTest/SimpleIDGeneratorTest.cpp b/Swiften/Base/UnitTest/SimpleIDGeneratorTest.cpp index 1c5fb2b..9b49c0a 100644 --- a/Swiften/Base/UnitTest/SimpleIDGeneratorTest.cpp +++ b/Swiften/Base/UnitTest/SimpleIDGeneratorTest.cpp @@ -15,27 +15,27 @@ using namespace Swift; class SimpleIDGeneratorTest : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(SimpleIDGeneratorTest); - CPPUNIT_TEST(testGenerate); - CPPUNIT_TEST_SUITE_END(); - - public: - SimpleIDGeneratorTest() {} - - void setUp() { - generatedIDs_.clear(); - } - - void testGenerate() { - SimpleIDGenerator testling; - for (unsigned int i = 0; i < 26*4; ++i) { - std::string id = testling.generateID(); - CPPUNIT_ASSERT(generatedIDs_.insert(id).second); - } - } - - private: - std::set<std::string> generatedIDs_; + CPPUNIT_TEST_SUITE(SimpleIDGeneratorTest); + CPPUNIT_TEST(testGenerate); + CPPUNIT_TEST_SUITE_END(); + + public: + SimpleIDGeneratorTest() {} + + void setUp() { + generatedIDs_.clear(); + } + + void testGenerate() { + SimpleIDGenerator testling; + for (unsigned int i = 0; i < 26*4; ++i) { + std::string id = testling.generateID(); + CPPUNIT_ASSERT(generatedIDs_.insert(id).second); + } + } + + private: + std::set<std::string> generatedIDs_; }; CPPUNIT_TEST_SUITE_REGISTRATION(SimpleIDGeneratorTest); diff --git a/Swiften/Base/UnitTest/StringTest.cpp b/Swiften/Base/UnitTest/StringTest.cpp index a17a253..e2e1665 100644 --- a/Swiften/Base/UnitTest/StringTest.cpp +++ b/Swiften/Base/UnitTest/StringTest.cpp @@ -15,115 +15,115 @@ using namespace Swift; class StringTest : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(StringTest); - CPPUNIT_TEST(testGetUnicodeCodePoints); - CPPUNIT_TEST(testGetSplittedAtFirst); - CPPUNIT_TEST(testGetSplittedAtFirst_CharacterAtBegin); - CPPUNIT_TEST(testGetSplittedAtFirst_CharacterAtEnd); - CPPUNIT_TEST(testGetSplittedAtFirst_NoSuchCharacter); - CPPUNIT_TEST(testReplaceAll); - CPPUNIT_TEST(testReplaceAll_LastChar); - CPPUNIT_TEST(testReplaceAll_ConsecutiveChars); - CPPUNIT_TEST(testReplaceAll_MatchingReplace); - CPPUNIT_TEST(testSplit); + CPPUNIT_TEST_SUITE(StringTest); + CPPUNIT_TEST(testGetUnicodeCodePoints); + CPPUNIT_TEST(testGetSplittedAtFirst); + CPPUNIT_TEST(testGetSplittedAtFirst_CharacterAtBegin); + CPPUNIT_TEST(testGetSplittedAtFirst_CharacterAtEnd); + CPPUNIT_TEST(testGetSplittedAtFirst_NoSuchCharacter); + CPPUNIT_TEST(testReplaceAll); + CPPUNIT_TEST(testReplaceAll_LastChar); + CPPUNIT_TEST(testReplaceAll_ConsecutiveChars); + CPPUNIT_TEST(testReplaceAll_MatchingReplace); + CPPUNIT_TEST(testSplit); #ifdef SWIFTEN_PLATFORM_WINDOWS - CPPUNIT_TEST(testConvertWStringToString); - CPPUNIT_TEST(testConvertStringToWString); + CPPUNIT_TEST(testConvertWStringToString); + CPPUNIT_TEST(testConvertStringToWString); #endif - CPPUNIT_TEST_SUITE_END(); + CPPUNIT_TEST_SUITE_END(); - public: - void testGetUnicodeCodePoints() { - std::string testling("$\xc2\xa2\xe2\x82\xac\xf4\x8a\xaf\x8d"); - std::vector<unsigned int> points = String::getUnicodeCodePoints(testling); + public: + void testGetUnicodeCodePoints() { + std::string testling("$\xc2\xa2\xe2\x82\xac\xf4\x8a\xaf\x8d"); + std::vector<unsigned int> points = String::getUnicodeCodePoints(testling); - CPPUNIT_ASSERT_EQUAL(0x24U, points[0]); - CPPUNIT_ASSERT_EQUAL(0xA2U, points[1]); - CPPUNIT_ASSERT_EQUAL(0x20ACU, points[2]); - CPPUNIT_ASSERT_EQUAL(0x10ABCDU, points[3]); - } + CPPUNIT_ASSERT_EQUAL(0x24U, points[0]); + CPPUNIT_ASSERT_EQUAL(0xA2U, points[1]); + CPPUNIT_ASSERT_EQUAL(0x20ACU, points[2]); + CPPUNIT_ASSERT_EQUAL(0x10ABCDU, points[3]); + } - void testGetSplittedAtFirst() { - std::string testling("ab@cd@ef"); + void testGetSplittedAtFirst() { + std::string testling("ab@cd@ef"); - std::pair<std::string,std::string> result = String::getSplittedAtFirst(testling, '@'); - CPPUNIT_ASSERT_EQUAL(std::string("ab"), result.first); - CPPUNIT_ASSERT_EQUAL(std::string("cd@ef"), result.second); - } + std::pair<std::string,std::string> result = String::getSplittedAtFirst(testling, '@'); + CPPUNIT_ASSERT_EQUAL(std::string("ab"), result.first); + CPPUNIT_ASSERT_EQUAL(std::string("cd@ef"), result.second); + } - void testGetSplittedAtFirst_CharacterAtBegin() { - std::string testling(" ab"); + void testGetSplittedAtFirst_CharacterAtBegin() { + std::string testling(" ab"); - std::pair<std::string,std::string> result = String::getSplittedAtFirst(testling, ' '); - CPPUNIT_ASSERT(result.first.empty()); - CPPUNIT_ASSERT_EQUAL(std::string("ab"), result.second); - } + std::pair<std::string,std::string> result = String::getSplittedAtFirst(testling, ' '); + CPPUNIT_ASSERT(result.first.empty()); + CPPUNIT_ASSERT_EQUAL(std::string("ab"), result.second); + } - void testGetSplittedAtFirst_CharacterAtEnd() { - std::string testling("ab@"); + void testGetSplittedAtFirst_CharacterAtEnd() { + std::string testling("ab@"); - std::pair<std::string,std::string> result = String::getSplittedAtFirst(testling, '@'); - CPPUNIT_ASSERT_EQUAL(std::string("ab"), result.first); - CPPUNIT_ASSERT(result.second.empty()); - } + std::pair<std::string,std::string> result = String::getSplittedAtFirst(testling, '@'); + CPPUNIT_ASSERT_EQUAL(std::string("ab"), result.first); + CPPUNIT_ASSERT(result.second.empty()); + } - void testGetSplittedAtFirst_NoSuchCharacter() { - std::string testling("ab"); + void testGetSplittedAtFirst_NoSuchCharacter() { + std::string testling("ab"); - std::pair<std::string,std::string> result = String::getSplittedAtFirst(testling, '@'); - CPPUNIT_ASSERT_EQUAL(std::string("ab"), result.first); - CPPUNIT_ASSERT(result.second.empty()); - } + std::pair<std::string,std::string> result = String::getSplittedAtFirst(testling, '@'); + CPPUNIT_ASSERT_EQUAL(std::string("ab"), result.first); + CPPUNIT_ASSERT(result.second.empty()); + } - void testReplaceAll() { - std::string testling("abcbd"); + void testReplaceAll() { + std::string testling("abcbd"); - String::replaceAll(testling, 'b', "xyz"); - - CPPUNIT_ASSERT_EQUAL(std::string("axyzcxyzd"), testling); - } + String::replaceAll(testling, 'b', "xyz"); - void testReplaceAll_LastChar() { - std::string testling("abc"); + CPPUNIT_ASSERT_EQUAL(std::string("axyzcxyzd"), testling); + } - String::replaceAll(testling, 'c', "xyz"); - - CPPUNIT_ASSERT_EQUAL(std::string("abxyz"), testling); - } + void testReplaceAll_LastChar() { + std::string testling("abc"); - void testReplaceAll_ConsecutiveChars() { - std::string testling("abbc"); + String::replaceAll(testling, 'c', "xyz"); - String::replaceAll(testling, 'b',"xyz"); - - CPPUNIT_ASSERT_EQUAL(std::string("axyzxyzc"), testling); - } + CPPUNIT_ASSERT_EQUAL(std::string("abxyz"), testling); + } - void testReplaceAll_MatchingReplace() { - std::string testling("abc"); + void testReplaceAll_ConsecutiveChars() { + std::string testling("abbc"); - String::replaceAll(testling, 'b',"bbb"); - - CPPUNIT_ASSERT_EQUAL(std::string("abbbc"), testling); - } + String::replaceAll(testling, 'b',"xyz"); - void testSplit() { - std::vector<std::string> result = String::split("abc def ghi", ' '); + CPPUNIT_ASSERT_EQUAL(std::string("axyzxyzc"), testling); + } - CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(result.size())); - CPPUNIT_ASSERT_EQUAL(std::string("abc"), result[0]); - CPPUNIT_ASSERT_EQUAL(std::string("def"), result[1]); - CPPUNIT_ASSERT_EQUAL(std::string("ghi"), result[2]); - } + void testReplaceAll_MatchingReplace() { + std::string testling("abc"); + + String::replaceAll(testling, 'b',"bbb"); + + CPPUNIT_ASSERT_EQUAL(std::string("abbbc"), testling); + } + + void testSplit() { + std::vector<std::string> result = String::split("abc def ghi", ' '); + + CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(result.size())); + CPPUNIT_ASSERT_EQUAL(std::string("abc"), result[0]); + CPPUNIT_ASSERT_EQUAL(std::string("def"), result[1]); + CPPUNIT_ASSERT_EQUAL(std::string("ghi"), result[2]); + } #ifdef SWIFTEN_PLATFORM_WINDOWS - void testConvertWStringToString() { - CPPUNIT_ASSERT_EQUAL(std::string("tron\xc3\xa7on"), convertWStringToString(std::wstring(L"tron\xe7on"))); - } + void testConvertWStringToString() { + CPPUNIT_ASSERT_EQUAL(std::string("tron\xc3\xa7on"), convertWStringToString(std::wstring(L"tron\xe7on"))); + } - void testConvertStringToWString() { - CPPUNIT_ASSERT(std::wstring(L"tron\xe7on") == convertStringToWString(std::string("tron\xc3\xa7on"))); - } + void testConvertStringToWString() { + CPPUNIT_ASSERT(std::wstring(L"tron\xe7on") == convertStringToWString(std::string("tron\xc3\xa7on"))); + } #endif }; diff --git a/Swiften/Base/UnitTest/URLTest.cpp b/Swiften/Base/UnitTest/URLTest.cpp index d88269a..2d2ceba 100644 --- a/Swiften/Base/UnitTest/URLTest.cpp +++ b/Swiften/Base/UnitTest/URLTest.cpp @@ -14,102 +14,102 @@ using namespace Swift; class URLTest : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(URLTest); - CPPUNIT_TEST(testFromString); - CPPUNIT_TEST(testFromString_WithoutPath); - CPPUNIT_TEST(testFromString_WithRootPath); - CPPUNIT_TEST(testFromString_WithPort); - CPPUNIT_TEST(testFromString_WithPortOnePartPath); - CPPUNIT_TEST(testFromString_WithPortWithoutPath); - CPPUNIT_TEST(testFromString_WithUserInfo); - CPPUNIT_TEST(testFromString_NonASCIIHost); - CPPUNIT_TEST(testFromString_NonASCIIPath); - CPPUNIT_TEST(testToString); - CPPUNIT_TEST(testToString_WithPort); - CPPUNIT_TEST_SUITE_END(); - - public: - void testFromString() { - URL url = URL::fromString("http://foo.bar/baz/bam"); - - CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme()); - CPPUNIT_ASSERT_EQUAL(std::string("foo.bar"), url.getHost()); - CPPUNIT_ASSERT(!url.getPort()); - CPPUNIT_ASSERT_EQUAL(std::string("/baz/bam"), url.getPath()); - } - - void testFromString_WithoutPath() { - URL url = URL::fromString("http://foo.bar"); - - CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme()); - CPPUNIT_ASSERT_EQUAL(std::string("foo.bar"), url.getHost()); - CPPUNIT_ASSERT(!url.getPort()); - CPPUNIT_ASSERT_EQUAL(std::string(""), url.getPath()); - } - - void testFromString_WithRootPath() { - URL url = URL::fromString("http://foo.bar/"); - - CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme()); - CPPUNIT_ASSERT_EQUAL(std::string("foo.bar"), url.getHost()); - CPPUNIT_ASSERT(!url.getPort()); - CPPUNIT_ASSERT_EQUAL(std::string("/"), url.getPath()); - } - - void testFromString_WithPort() { - URL url = URL::fromString("http://foo.bar:1234/baz/bam"); - - CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme()); - CPPUNIT_ASSERT_EQUAL(std::string("foo.bar"), url.getHost()); - CPPUNIT_ASSERT_EQUAL(1234, *url.getPort()); - CPPUNIT_ASSERT_EQUAL(std::string("/baz/bam"), url.getPath()); - } - - void testFromString_WithPortOnePartPath() { - URL url = URL::fromString("http://foo.bar:11440/http-bind/"); - - CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme()); - CPPUNIT_ASSERT_EQUAL(std::string("foo.bar"), url.getHost()); - CPPUNIT_ASSERT_EQUAL(11440, *url.getPort()); - CPPUNIT_ASSERT_EQUAL(std::string("/http-bind/"), url.getPath()); - } - - void testFromString_WithPortWithoutPath() { - URL url = URL::fromString("http://foo.bar:1234"); - - CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme()); - CPPUNIT_ASSERT_EQUAL(std::string("foo.bar"), url.getHost()); - CPPUNIT_ASSERT_EQUAL(1234, *url.getPort()); - CPPUNIT_ASSERT_EQUAL(std::string(""), url.getPath()); - } - - void testFromString_WithUserInfo() { - URL url = URL::fromString("http://user:pass@foo.bar/baz/bam"); - - CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme()); - CPPUNIT_ASSERT_EQUAL(std::string("foo.bar"), url.getHost()); - CPPUNIT_ASSERT_EQUAL(std::string("/baz/bam"), url.getPath()); - } - - void testFromString_NonASCIIHost() { - URL url = URL::fromString("http://www.tron%C3%A7on.be/baz/bam"); - - CPPUNIT_ASSERT_EQUAL(std::string("www.tron\xc3\xa7on.be"), url.getHost()); - } - - void testFromString_NonASCIIPath() { - URL url = URL::fromString("http://foo.bar/baz/tron%C3%A7on/bam"); - - CPPUNIT_ASSERT_EQUAL(std::string("/baz/tron\xc3\xa7on/bam"), url.getPath()); - } - - void testToString() { - CPPUNIT_ASSERT_EQUAL(std::string("http://foo.bar/baz/bam"), URL("http", "foo.bar", "/baz/bam").toString()); - } - - void testToString_WithPort() { - CPPUNIT_ASSERT_EQUAL(std::string("http://foo.bar:1234/baz/bam"), URL("http", "foo.bar", 1234, "/baz/bam").toString()); - } + CPPUNIT_TEST_SUITE(URLTest); + CPPUNIT_TEST(testFromString); + CPPUNIT_TEST(testFromString_WithoutPath); + CPPUNIT_TEST(testFromString_WithRootPath); + CPPUNIT_TEST(testFromString_WithPort); + CPPUNIT_TEST(testFromString_WithPortOnePartPath); + CPPUNIT_TEST(testFromString_WithPortWithoutPath); + CPPUNIT_TEST(testFromString_WithUserInfo); + CPPUNIT_TEST(testFromString_NonASCIIHost); + CPPUNIT_TEST(testFromString_NonASCIIPath); + CPPUNIT_TEST(testToString); + CPPUNIT_TEST(testToString_WithPort); + CPPUNIT_TEST_SUITE_END(); + + public: + void testFromString() { + URL url = URL::fromString("http://foo.bar/baz/bam"); + + CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme()); + CPPUNIT_ASSERT_EQUAL(std::string("foo.bar"), url.getHost()); + CPPUNIT_ASSERT(!url.getPort()); + CPPUNIT_ASSERT_EQUAL(std::string("/baz/bam"), url.getPath()); + } + + void testFromString_WithoutPath() { + URL url = URL::fromString("http://foo.bar"); + + CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme()); + CPPUNIT_ASSERT_EQUAL(std::string("foo.bar"), url.getHost()); + CPPUNIT_ASSERT(!url.getPort()); + CPPUNIT_ASSERT_EQUAL(std::string(""), url.getPath()); + } + + void testFromString_WithRootPath() { + URL url = URL::fromString("http://foo.bar/"); + + CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme()); + CPPUNIT_ASSERT_EQUAL(std::string("foo.bar"), url.getHost()); + CPPUNIT_ASSERT(!url.getPort()); + CPPUNIT_ASSERT_EQUAL(std::string("/"), url.getPath()); + } + + void testFromString_WithPort() { + URL url = URL::fromString("http://foo.bar:1234/baz/bam"); + + CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme()); + CPPUNIT_ASSERT_EQUAL(std::string("foo.bar"), url.getHost()); + CPPUNIT_ASSERT_EQUAL(1234, *url.getPort()); + CPPUNIT_ASSERT_EQUAL(std::string("/baz/bam"), url.getPath()); + } + + void testFromString_WithPortOnePartPath() { + URL url = URL::fromString("http://foo.bar:11440/http-bind/"); + + CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme()); + CPPUNIT_ASSERT_EQUAL(std::string("foo.bar"), url.getHost()); + CPPUNIT_ASSERT_EQUAL(11440, *url.getPort()); + CPPUNIT_ASSERT_EQUAL(std::string("/http-bind/"), url.getPath()); + } + + void testFromString_WithPortWithoutPath() { + URL url = URL::fromString("http://foo.bar:1234"); + + CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme()); + CPPUNIT_ASSERT_EQUAL(std::string("foo.bar"), url.getHost()); + CPPUNIT_ASSERT_EQUAL(1234, *url.getPort()); + CPPUNIT_ASSERT_EQUAL(std::string(""), url.getPath()); + } + + void testFromString_WithUserInfo() { + URL url = URL::fromString("http://user:pass@foo.bar/baz/bam"); + + CPPUNIT_ASSERT_EQUAL(std::string("http"), url.getScheme()); + CPPUNIT_ASSERT_EQUAL(std::string("foo.bar"), url.getHost()); + CPPUNIT_ASSERT_EQUAL(std::string("/baz/bam"), url.getPath()); + } + + void testFromString_NonASCIIHost() { + URL url = URL::fromString("http://www.tron%C3%A7on.be/baz/bam"); + + CPPUNIT_ASSERT_EQUAL(std::string("www.tron\xc3\xa7on.be"), url.getHost()); + } + + void testFromString_NonASCIIPath() { + URL url = URL::fromString("http://foo.bar/baz/tron%C3%A7on/bam"); + + CPPUNIT_ASSERT_EQUAL(std::string("/baz/tron\xc3\xa7on/bam"), url.getPath()); + } + + void testToString() { + CPPUNIT_ASSERT_EQUAL(std::string("http://foo.bar/baz/bam"), URL("http", "foo.bar", "/baz/bam").toString()); + } + + void testToString_WithPort() { + CPPUNIT_ASSERT_EQUAL(std::string("http://foo.bar:1234/baz/bam"), URL("http", "foo.bar", 1234, "/baz/bam").toString()); + } }; CPPUNIT_TEST_SUITE_REGISTRATION(URLTest); |