summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2012-10-05 16:33:13 (GMT)
committerRemko Tronçon <git@el-tramo.be>2012-10-05 16:33:13 (GMT)
commita83d252c7e4aa6885319d64bbdb6aa54e1fb8f95 (patch)
treedbff8fe6da71fb500337881f04fcc1f755a38a88 /Swiften/Base/UnitTest
parentebe1a1b2ccf2ef8d88ab1981e6f7ab74866b008f (diff)
downloadswift-a83d252c7e4aa6885319d64bbdb6aa54e1fb8f95.zip
swift-a83d252c7e4aa6885319d64bbdb6aa54e1fb8f95.tar.bz2
Strip leading '/' from BOSH paths.
Resolves: #1167
Diffstat (limited to 'Swiften/Base/UnitTest')
-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() {