summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Base/UnitTest/URLTest.cpp')
-rw-r--r--Swiften/Base/UnitTest/URLTest.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/Swiften/Base/UnitTest/URLTest.cpp b/Swiften/Base/UnitTest/URLTest.cpp
index 55c81f6..09912ed 100644
--- a/Swiften/Base/UnitTest/URLTest.cpp
+++ b/Swiften/Base/UnitTest/URLTest.cpp
@@ -16,6 +16,7 @@ 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_WithPortWithoutPath);
CPPUNIT_TEST(testFromString_WithUserInfo);
@@ -32,7 +33,7 @@ class URLTest : public CppUnit::TestFixture {
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());
+ CPPUNIT_ASSERT_EQUAL(std::string("baz/bam"), url.getPath());
}
void testFromString_WithoutPath() {
@@ -44,13 +45,22 @@ class URLTest : public CppUnit::TestFixture {
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());
+ CPPUNIT_ASSERT_EQUAL(std::string("baz/bam"), url.getPath());
}
void testFromString_WithPortWithoutPath() {
@@ -67,7 +77,7 @@ class URLTest : public CppUnit::TestFixture {
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());
+ CPPUNIT_ASSERT_EQUAL(std::string("baz/bam"), url.getPath());
}
void testFromString_NonASCIIHost() {
@@ -79,7 +89,7 @@ class URLTest : public CppUnit::TestFixture {
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());
+ CPPUNIT_ASSERT_EQUAL(std::string("baz/tron\xc3\xa7on/bam"), url.getPath());
}
void testToString() {