summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-06-22 11:55:05 (GMT)
committerTobias Markmann <tm@ayena.de>2016-06-22 11:55:18 (GMT)
commitfbc02ab3b96fb46231458d2e283cfdd191185fb5 (patch)
treedf86d5b7a351a733ace6ef7f798ff6ba9f423bd0 /Swiften/JID/UnitTest
parent545e17682e2cb97b537a0b6ebc2b2d026e3f0389 (diff)
downloadswift-fbc02ab3b96fb46231458d2e283cfdd191185fb5.zip
swift-fbc02ab3b96fb46231458d2e283cfdd191185fb5.tar.bz2
Treat JIDs with empty resources as invalid
Cleaned up JID.cpp in process. Test-Information: Adjusted tests accordingly. All tests pass pass on OS X 10.11.5. Change-Id: I774344c8f7378dafe9249217503c082f46890457
Diffstat (limited to 'Swiften/JID/UnitTest')
-rw-r--r--Swiften/JID/UnitTest/JIDTest.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/Swiften/JID/UnitTest/JIDTest.cpp b/Swiften/JID/UnitTest/JIDTest.cpp
index 432e7cb..ca3e5ae 100644
--- a/Swiften/JID/UnitTest/JIDTest.cpp
+++ b/Swiften/JID/UnitTest/JIDTest.cpp
@@ -95,7 +95,7 @@ class JIDTest : public CppUnit::TestFixture
void testConstructorWithString_EmptyResource() {
JID testling("bar/");
- CPPUNIT_ASSERT(testling.isValid());
+ CPPUNIT_ASSERT(!testling.isValid());
CPPUNIT_ASSERT(!testling.isBare());
}
@@ -212,8 +212,7 @@ class JIDTest : public CppUnit::TestFixture
JID testling("bar/");
CPPUNIT_ASSERT_EQUAL(std::string(""), testling.toBare().getNode());
- CPPUNIT_ASSERT_EQUAL(std::string("bar"), testling.toBare().getDomain());
- CPPUNIT_ASSERT(testling.toBare().isBare());
+ CPPUNIT_ASSERT(!testling.isValid());
}
void testToString() {
@@ -237,7 +236,7 @@ class JIDTest : public CppUnit::TestFixture
void testToString_EmptyResource() {
JID testling("foo@bar/");
- CPPUNIT_ASSERT_EQUAL(std::string("foo@bar/"), testling.toString());
+ CPPUNIT_ASSERT_EQUAL(false, testling.isValid());
}
void testCompare_SmallerNode() {
@@ -300,14 +299,14 @@ class JIDTest : public CppUnit::TestFixture
JID testling1("x@y/");
JID testling2("x@y");
- CPPUNIT_ASSERT_EQUAL(1, testling1.compare(testling2, JID::WithResource));
+ CPPUNIT_ASSERT_EQUAL(-1, testling1.compare(testling2, JID::WithResource));
}
void testCompare_EmptyResourceAndNoResource() {
JID testling1("x@y");
JID testling2("x@y/");
- CPPUNIT_ASSERT_EQUAL(-1, testling1.compare(testling2, JID::WithResource));
+ CPPUNIT_ASSERT_EQUAL(1, testling1.compare(testling2, JID::WithResource));
}
void testEquals() {
@@ -359,9 +358,17 @@ class JIDTest : public CppUnit::TestFixture
}
void testHasResource_NoResource() {
- JID testling("x@y");
+ {
+ JID testling("x@y");
- CPPUNIT_ASSERT(testling.isBare());
+ CPPUNIT_ASSERT(testling.isBare());
+ CPPUNIT_ASSERT_EQUAL(true, testling.isValid());
+ }
+
+ {
+ JID testling("node@domain/");
+ CPPUNIT_ASSERT_EQUAL(false, testling.isValid());
+ }
}
void testGetEscapedNode() {