summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/StringCodecs/UnitTest')
-rw-r--r--Swiften/StringCodecs/UnitTest/HexifyTest.cpp6
-rw-r--r--Swiften/StringCodecs/UnitTest/MD5Test.cpp11
2 files changed, 17 insertions, 0 deletions
diff --git a/Swiften/StringCodecs/UnitTest/HexifyTest.cpp b/Swiften/StringCodecs/UnitTest/HexifyTest.cpp
index 9cbd0d4..38233f9 100644
--- a/Swiften/StringCodecs/UnitTest/HexifyTest.cpp
+++ b/Swiften/StringCodecs/UnitTest/HexifyTest.cpp
@@ -17,6 +17,7 @@ class HexifyTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(HexifyTest);
CPPUNIT_TEST(testHexify);
CPPUNIT_TEST(testHexify_Byte);
+ CPPUNIT_TEST(testUnhexify);
CPPUNIT_TEST_SUITE_END();
public:
@@ -27,6 +28,11 @@ class HexifyTest : public CppUnit::TestFixture {
void testHexify_Byte() {
CPPUNIT_ASSERT_EQUAL(std::string("b2"), Hexify::hexify(0xb2));
}
+
+ void testUnhexify() {
+ CPPUNIT_ASSERT_EQUAL(std::string("ffaf02"), Hexify::hexify(Hexify::unhexify("ffaf02")));
+ CPPUNIT_ASSERT(createByteArray("\x01\x23\xf2", 3) == Hexify::unhexify("0123f2"));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(HexifyTest);
diff --git a/Swiften/StringCodecs/UnitTest/MD5Test.cpp b/Swiften/StringCodecs/UnitTest/MD5Test.cpp
index ce7e422..c62c46a 100644
--- a/Swiften/StringCodecs/UnitTest/MD5Test.cpp
+++ b/Swiften/StringCodecs/UnitTest/MD5Test.cpp
@@ -19,6 +19,7 @@ class MD5Test : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(MD5Test);
CPPUNIT_TEST(testGetHash_Empty);
CPPUNIT_TEST(testGetHash_Alphabet);
+ CPPUNIT_TEST(testIncrementalTest);
CPPUNIT_TEST_SUITE_END();
public:
@@ -33,6 +34,16 @@ class MD5Test : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(createByteArray("\xd1\x74\xab\x98\xd2\x77\xd9\xf5\xa5\x61\x1c\x2c\x9f\x41\x9d\x9f", 16), result);
}
+
+ void testIncrementalTest() {
+ MD5 testling;
+ testling.update(createByteArray("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
+ testling.update(createByteArray("abcdefghijklmnopqrstuvwxyz0123456789"));
+
+ ByteArray result = testling.getHash();
+
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\xd1\x74\xab\x98\xd2\x77\xd9\xf5\xa5\x61\x1c\x2c\x9f\x41\x9d\x9f", 16), result);
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(MD5Test);