diff options
author | Kevin Smith <git@kismith.co.uk> | 2012-11-13 10:15:29 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2012-11-13 10:50:15 (GMT) |
commit | 59c1b26ba8f85bfb52f7c8e95bf1eca208d3de7b (patch) | |
tree | 8b911fee527973ec3406640b0dfa8c7dcd6cf8b6 /Swiften/Base/UnitTest/URLTest.cpp | |
parent | d26ad781dd4d1fa2019d31d5effabb9d662a8417 (diff) | |
download | swift-59c1b26ba8f85bfb52f7c8e95bf1eca208d3de7b.zip swift-59c1b26ba8f85bfb52f7c8e95bf1eca208d3de7b.tar.bz2 |
Allow BOSH URL setting again.
Also fixes use of getPort() so that HTTP headers aren't all for port :1.
Change-Id: I8ead8a7f4826d1105bf1feafea21e6139e803de7
Resolves: #1178
Diffstat (limited to 'Swiften/Base/UnitTest/URLTest.cpp')
-rw-r--r-- | Swiften/Base/UnitTest/URLTest.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/Swiften/Base/UnitTest/URLTest.cpp b/Swiften/Base/UnitTest/URLTest.cpp index 09912ed..e82321f 100644 --- a/Swiften/Base/UnitTest/URLTest.cpp +++ b/Swiften/Base/UnitTest/URLTest.cpp @@ -18,6 +18,7 @@ class URLTest : public CppUnit::TestFixture { 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); @@ -33,7 +34,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() { @@ -51,7 +52,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(""), url.getPath()); + CPPUNIT_ASSERT_EQUAL(std::string("/"), url.getPath()); } void testFromString_WithPort() { @@ -60,7 +61,16 @@ 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(1234, *url.getPort()); - CPPUNIT_ASSERT_EQUAL(std::string("baz/bam"), url.getPath()); + 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() { @@ -77,7 +87,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() { @@ -89,7 +99,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() { |