diff options
Diffstat (limited to 'Swiften/JID/UnitTest/JIDTest.cpp')
-rw-r--r-- | Swiften/JID/UnitTest/JIDTest.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Swiften/JID/UnitTest/JIDTest.cpp b/Swiften/JID/UnitTest/JIDTest.cpp index 72ca884..03203de 100644 --- a/Swiften/JID/UnitTest/JIDTest.cpp +++ b/Swiften/JID/UnitTest/JIDTest.cpp @@ -1,56 +1,57 @@ /* * Copyright (c) 2010 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> #include <Swiften/JID/JID.h> using namespace Swift; class JIDTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(JIDTest); CPPUNIT_TEST(testConstructorWithString); CPPUNIT_TEST(testConstructorWithString_NoResource); CPPUNIT_TEST(testConstructorWithString_NoNode); CPPUNIT_TEST(testConstructorWithString_EmptyResource); CPPUNIT_TEST(testConstructorWithString_OnlyDomain); + CPPUNIT_TEST(testConstructorWithString_InvalidDomain); CPPUNIT_TEST(testConstructorWithString_UpperCaseNode); CPPUNIT_TEST(testConstructorWithString_UpperCaseDomain); CPPUNIT_TEST(testConstructorWithString_UpperCaseResource); CPPUNIT_TEST(testConstructorWithString_EmptyNode); CPPUNIT_TEST(testConstructorWithString_IllegalResource); CPPUNIT_TEST(testConstructorWithString_SpacesInNode); CPPUNIT_TEST(testConstructorWithStrings); CPPUNIT_TEST(testConstructorWithStrings_EmptyDomain); CPPUNIT_TEST(testIsBare); CPPUNIT_TEST(testIsBare_NotBare); CPPUNIT_TEST(testToBare); CPPUNIT_TEST(testToBare_EmptyNode); CPPUNIT_TEST(testToBare_EmptyResource); CPPUNIT_TEST(testToString); CPPUNIT_TEST(testToString_EmptyNode); CPPUNIT_TEST(testToString_EmptyResource); CPPUNIT_TEST(testToString_NoResource); CPPUNIT_TEST(testCompare_SmallerNode); CPPUNIT_TEST(testCompare_LargerNode); CPPUNIT_TEST(testCompare_SmallerDomain); CPPUNIT_TEST(testCompare_LargerDomain); CPPUNIT_TEST(testCompare_SmallerResource); CPPUNIT_TEST(testCompare_LargerResource); CPPUNIT_TEST(testCompare_Equal); CPPUNIT_TEST(testCompare_EqualWithoutResource); CPPUNIT_TEST(testCompare_NoResourceAndEmptyResource); CPPUNIT_TEST(testCompare_EmptyResourceAndNoResource); CPPUNIT_TEST(testEquals); CPPUNIT_TEST(testEquals_NotEqual); CPPUNIT_TEST(testEquals_WithoutResource); CPPUNIT_TEST(testSmallerThan); CPPUNIT_TEST(testSmallerThan_Equal); CPPUNIT_TEST(testSmallerThan_Larger); CPPUNIT_TEST(testHasResource); CPPUNIT_TEST(testHasResource_NoResource); @@ -75,70 +76,74 @@ class JIDTest : public CppUnit::TestFixture void testConstructorWithString_NoResource() { JID testling("foo@bar"); CPPUNIT_ASSERT_EQUAL(std::string("foo"), testling.getNode()); CPPUNIT_ASSERT_EQUAL(std::string("bar"), testling.getDomain()); CPPUNIT_ASSERT_EQUAL(std::string(""), testling.getResource()); CPPUNIT_ASSERT(testling.isBare()); } void testConstructorWithString_EmptyResource() { JID testling("bar/"); CPPUNIT_ASSERT(testling.isValid()); CPPUNIT_ASSERT(!testling.isBare()); } void testConstructorWithString_NoNode() { JID testling("bar/baz"); CPPUNIT_ASSERT_EQUAL(std::string(""), testling.getNode()); CPPUNIT_ASSERT_EQUAL(std::string("bar"), testling.getDomain()); CPPUNIT_ASSERT_EQUAL(std::string("baz"), testling.getResource()); CPPUNIT_ASSERT(!testling.isBare()); } void testConstructorWithString_OnlyDomain() { JID testling("bar"); CPPUNIT_ASSERT_EQUAL(std::string(""), testling.getNode()); CPPUNIT_ASSERT_EQUAL(std::string("bar"), testling.getDomain()); CPPUNIT_ASSERT_EQUAL(std::string(""), testling.getResource()); CPPUNIT_ASSERT(testling.isBare()); } + void testConstructorWithString_InvalidDomain() { + CPPUNIT_ASSERT(!JID("foo@bar,baz").isValid()); + } + void testConstructorWithString_UpperCaseNode() { JID testling("Fo\xCE\xA9@bar"); CPPUNIT_ASSERT_EQUAL(std::string("fo\xCF\x89"), testling.getNode()); CPPUNIT_ASSERT_EQUAL(std::string("bar"), testling.getDomain()); } void testConstructorWithString_UpperCaseDomain() { JID testling("Fo\xCE\xA9"); CPPUNIT_ASSERT_EQUAL(std::string("fo\xCF\x89"), testling.getDomain()); } void testConstructorWithString_UpperCaseResource() { JID testling("bar/Fo\xCE\xA9"); CPPUNIT_ASSERT_EQUAL(testling.getResource(), std::string("Fo\xCE\xA9")); } void testConstructorWithString_EmptyNode() { JID testling("@bar"); CPPUNIT_ASSERT(!testling.isValid()); } void testConstructorWithString_IllegalResource() { JID testling("foo@bar.com/\xd8\xb1\xd9\x85\xd9\x82\xd9\x87\x20\xd8\xaa\xd8\xb1\xd9\x86\xd8\xb3\x20"); CPPUNIT_ASSERT(!testling.isValid()); } void testConstructorWithString_SpacesInNode() { CPPUNIT_ASSERT(!JID(" alice@wonderland.lit").isValid()); CPPUNIT_ASSERT(!JID("alice @wonderland.lit").isValid()); } |