summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kaluza <hanzz.k@gmail.com>2011-04-14 08:50:27 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-04-18 19:11:43 (GMT)
commita4e59529239902ac352e791767db63a31e2e0634 (patch)
tree8ac3da7c6f63f8a5fe523525f31e08742174f33f /Swiften/JID/UnitTest
parent07152630c3a9d04dd86f7b370ee30b553665f5c7 (diff)
downloadswift-contrib-a4e59529239902ac352e791767db63a31e2e0634.zip
swift-contrib-a4e59529239902ac352e791767db63a31e2e0634.tar.bz2
Added support for JID Escaping XEP.
License: This patch is BSD-licensed, see http://www.opensource.org/licenses/bsd-license.php
Diffstat (limited to 'Swiften/JID/UnitTest')
-rw-r--r--Swiften/JID/UnitTest/JIDTest.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/Swiften/JID/UnitTest/JIDTest.cpp b/Swiften/JID/UnitTest/JIDTest.cpp
index 0f22e15..619df7f 100644
--- a/Swiften/JID/UnitTest/JIDTest.cpp
+++ b/Swiften/JID/UnitTest/JIDTest.cpp
@@ -51,6 +51,8 @@ class JIDTest : public CppUnit::TestFixture
CPPUNIT_TEST(testSmallerThan_Larger);
CPPUNIT_TEST(testHasResource);
CPPUNIT_TEST(testHasResource_NoResource);
+ CPPUNIT_TEST(testGetEscapedNode);
+ CPPUNIT_TEST(testGetUnescapedNode);
CPPUNIT_TEST_SUITE_END();
public:
@@ -311,6 +313,21 @@ class JIDTest : public CppUnit::TestFixture
CPPUNIT_ASSERT(testling.isBare());
}
+
+ void testGetEscapedNode() {
+ std::string escaped = JID::getEscapedNode("alice@wonderland.lit");
+ CPPUNIT_ASSERT_EQUAL(std::string("alice\\40wonderland.lit"), escaped);
+
+ escaped = JID::getEscapedNode("\\& \" ' / <\\\\> @ :\\3a\\40");
+ CPPUNIT_ASSERT_EQUAL(std::string("\\5c\\26\\20\\22\\20\\27\\20\\2f\\20\\3c\\5c\\5c\\3e\\20\\40\\20\\3a\\5c3a\\5c40"), escaped);
+ }
+
+ void testGetUnescapedNode() {
+ std::string input = "\\& \" ' / <\\\\> @ : \\5c\\40";
+ JID testling(JID::getEscapedNode(input) + "@y");
+ CPPUNIT_ASSERT(testling.isValid());
+ CPPUNIT_ASSERT_EQUAL(input, testling.getUnescapedNode());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(JIDTest);