summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-09-30 20:26:00 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-09-30 20:26:00 (GMT)
commitbe0d01be9d6e98c59c6484e3bd691c4354142c4c (patch)
tree7e8d1d1a06db1cf7f79b56da04f622f8505f9a78 /Swiften/StringCodecs
parent6c8f9f9619f464d21c81f850f7a73498568af5c4 (diff)
downloadswift-be0d01be9d6e98c59c6484e3bd691c4354142c4c.zip
swift-be0d01be9d6e98c59c6484e3bd691c4354142c4c.tar.bz2
Added SHA-1 and Base64 tests for empty input data.
Diffstat (limited to 'Swiften/StringCodecs')
-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);