diff options
Diffstat (limited to 'Swiften/JID/UnitTest/JIDTest.cpp')
| -rw-r--r-- | Swiften/JID/UnitTest/JIDTest.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Swiften/JID/UnitTest/JIDTest.cpp b/Swiften/JID/UnitTest/JIDTest.cpp index 0753fb5..894378d 100644 --- a/Swiften/JID/UnitTest/JIDTest.cpp +++ b/Swiften/JID/UnitTest/JIDTest.cpp | |||
| @@ -71,6 +71,12 @@ class JIDTest : public CppUnit::TestFixture | |||
| 71 | CPPUNIT_TEST(testGetUnescapedNode); | 71 | CPPUNIT_TEST(testGetUnescapedNode); |
| 72 | CPPUNIT_TEST(testGetUnescapedNode_XEP106Examples); | 72 | CPPUNIT_TEST(testGetUnescapedNode_XEP106Examples); |
| 73 | CPPUNIT_TEST(testStringPrepFailures); | 73 | CPPUNIT_TEST(testStringPrepFailures); |
| 74 | CPPUNIT_TEST(testConstructorWithString_DomainIPv4); | ||
| 75 | CPPUNIT_TEST(testConstructorWithString_DomainNOTIPv4); | ||
| 76 | CPPUNIT_TEST(testConstructorWithString_ValidDomainNOTIPv4); | ||
| 77 | CPPUNIT_TEST(testConstructorWithString_DomainIPv6); | ||
| 78 | CPPUNIT_TEST(testConstructorWithString_DomainInvalidIPv6); | ||
| 79 | CPPUNIT_TEST(testConstructorWithString_DomainIPv6NoBrackets); | ||
| 74 | CPPUNIT_TEST_SUITE_END(); | 80 | CPPUNIT_TEST_SUITE_END(); |
| 75 | 81 | ||
| 76 | public: | 82 | public: |
| @@ -492,6 +498,46 @@ class JIDTest : public CppUnit::TestFixture | |||
| 492 | CPPUNIT_ASSERT_EQUAL(std::string("c:\\cool stuff"), JID("c\\3a\\cool\\20stuff@example.com").getUnescapedNode()); | 498 | CPPUNIT_ASSERT_EQUAL(std::string("c:\\cool stuff"), JID("c\\3a\\cool\\20stuff@example.com").getUnescapedNode()); |
| 493 | CPPUNIT_ASSERT_EQUAL(std::string("c:\\5commas"), JID("c\\3a\\5c5commas@example.com").getUnescapedNode()); | 499 | CPPUNIT_ASSERT_EQUAL(std::string("c:\\5commas"), JID("c\\3a\\5c5commas@example.com").getUnescapedNode()); |
| 494 | } | 500 | } |
| 501 | |||
| 502 | void testConstructorWithString_DomainIPv4() { | ||
| 503 | JID testling("foo@192.34.12.1/resource"); | ||
| 504 | |||
| 505 | CPPUNIT_ASSERT_EQUAL(std::string("foo"), testling.getNode()); | ||
| 506 | CPPUNIT_ASSERT_EQUAL(std::string("192.34.12.1"), testling.getDomain()); | ||
| 507 | CPPUNIT_ASSERT_EQUAL(std::string("resource"), testling.getResource()); | ||
| 508 | CPPUNIT_ASSERT(!testling.isBare()); | ||
| 509 | CPPUNIT_ASSERT(testling.isValid()); | ||
| 510 | } | ||
| 511 | |||
| 512 | void testConstructorWithString_DomainNOTIPv4() { | ||
| 513 | JID testling("foo@500.34.12.1/resource"); | ||
| 514 | CPPUNIT_ASSERT(!testling.isValid()); | ||
| 515 | } | ||
| 516 | |||
| 517 | void testConstructorWithString_ValidDomainNOTIPv4() { | ||
| 518 | JID testling("foo@500.34.12.1a/resource"); | ||
| 519 | CPPUNIT_ASSERT(testling.isValid()); | ||
| 520 | } | ||
| 521 | |||
| 522 | void testConstructorWithString_DomainIPv6() { | ||
| 523 | JID testling("foo@[fe80::a857:33ff:febd:3580]/resource"); | ||
| 524 | |||
| 525 | CPPUNIT_ASSERT_EQUAL(std::string("foo"), testling.getNode()); | ||
| 526 | CPPUNIT_ASSERT_EQUAL(std::string("[fe80::a857:33ff:febd:3580]"), testling.getDomain()); | ||
| 527 | CPPUNIT_ASSERT_EQUAL(std::string("resource"), testling.getResource()); | ||
| 528 | CPPUNIT_ASSERT(!testling.isBare()); | ||
| 529 | CPPUNIT_ASSERT(testling.isValid()); | ||
| 530 | } | ||
| 531 | |||
| 532 | void testConstructorWithString_DomainInvalidIPv6() { | ||
| 533 | JID testling("foo@[1111::a1111:1111:111!:!!!!]/resource"); | ||
| 534 | CPPUNIT_ASSERT(!testling.isValid()); | ||
| 535 | } | ||
| 536 | |||
| 537 | void testConstructorWithString_DomainIPv6NoBrackets() { | ||
| 538 | JID testling("foo@fe80::a857:33ff:febd:3580/resource"); | ||
| 539 | CPPUNIT_ASSERT(!testling.isValid()); | ||
| 540 | } | ||
| 495 | }; | 541 | }; |
| 496 | 542 | ||
| 497 | CPPUNIT_TEST_SUITE_REGISTRATION(JIDTest); | 543 | CPPUNIT_TEST_SUITE_REGISTRATION(JIDTest); |
Swift