summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/StringCodecs/UnitTest')
-rw-r--r--Swiften/StringCodecs/UnitTest/Base64Test.cpp12
-rw-r--r--Swiften/StringCodecs/UnitTest/SHA1Test.cpp7
2 files changed, 19 insertions, 0 deletions
diff --git a/Swiften/StringCodecs/UnitTest/Base64Test.cpp b/Swiften/StringCodecs/UnitTest/Base64Test.cpp
index fb05c90..0217758 100644
--- a/Swiften/StringCodecs/UnitTest/Base64Test.cpp
+++ b/Swiften/StringCodecs/UnitTest/Base64Test.cpp
@@ -10,7 +10,9 @@ class Base64Test : public CppUnit::TestFixture
CPPUNIT_TEST_SUITE(Base64Test);
CPPUNIT_TEST(testEncode);
CPPUNIT_TEST(testEncode_NonAscii);
+ CPPUNIT_TEST(testEncode_NoData);
CPPUNIT_TEST(testDecode);
+ CPPUNIT_TEST(testDecode_NoData);
CPPUNIT_TEST_SUITE_END();
public:
@@ -26,10 +28,20 @@ class Base64Test : public CppUnit::TestFixture
CPPUNIT_ASSERT_EQUAL(String("QgayPKawpkPSDYmwT/WM94uAlu0="), result);
}
+ void testEncode_NoData() {
+ String result(Base64::encode(ByteArray()));
+ CPPUNIT_ASSERT_EQUAL(String(""), result);
+ }
+
void testDecode() {
ByteArray result(Base64::decode("QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejEyMzQ1Njc4OTA="));
CPPUNIT_ASSERT_EQUAL(ByteArray("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"), result);
}
+
+ void testDecode_NoData() {
+ ByteArray result(Base64::decode(""));
+ CPPUNIT_ASSERT_EQUAL(ByteArray(), result);
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(Base64Test);
diff --git a/Swiften/StringCodecs/UnitTest/SHA1Test.cpp b/Swiften/StringCodecs/UnitTest/SHA1Test.cpp
index e556429..849dd6d 100644
--- a/Swiften/StringCodecs/UnitTest/SHA1Test.cpp
+++ b/Swiften/StringCodecs/UnitTest/SHA1Test.cpp
@@ -11,6 +11,7 @@ class SHA1Test : public CppUnit::TestFixture
CPPUNIT_TEST(testGetBinaryHash);
CPPUNIT_TEST(testGetBinaryHash_Twice);
CPPUNIT_TEST(testGetHexHash);
+ CPPUNIT_TEST(testGetHexHash_NoData);
CPPUNIT_TEST_SUITE_END();
public:
@@ -34,6 +35,12 @@ class SHA1Test : public CppUnit::TestFixture
String result(SHA1::getHexHash("client/pc//Exodus 0.9.1<http://jabber.org/protocol/caps<http://jabber.org/protocol/disco#info<http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc<"));
CPPUNIT_ASSERT_EQUAL(String("4206b23ca6b0a643d20d89b04ff58cf78b8096ed"), result);
}
+
+ void testGetHexHash_NoData() {
+ String result(SHA1::getHexHash(ByteArray()));
+
+ CPPUNIT_ASSERT_EQUAL(String("da39a3ee5e6b4b0d3255bfef95601890afd80709"), result);
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(SHA1Test);