diff options
Diffstat (limited to 'Swiften/StringCodecs/UnitTest')
m--------- | Swiften | 0 | ||||
-rw-r--r-- | Swiften/StringCodecs/UnitTest/Base64Test.cpp | 44 | ||||
-rw-r--r-- | Swiften/StringCodecs/UnitTest/HMACSHA1Test.cpp | 21 | ||||
-rw-r--r-- | Swiften/StringCodecs/UnitTest/HexifyTest.cpp | 21 | ||||
-rw-r--r-- | Swiften/StringCodecs/UnitTest/MD5Test.cpp | 29 | ||||
-rw-r--r-- | Swiften/StringCodecs/UnitTest/PBKDF2Test.cpp | 36 | ||||
-rw-r--r-- | Swiften/StringCodecs/UnitTest/SHA1Test.cpp | 37 |
7 files changed, 0 insertions, 188 deletions
diff --git a/Swiften b/Swiften new file mode 160000 +Subproject 8213ba16d0043d2461f4b031c881d61dda5a38c diff --git a/Swiften/StringCodecs/UnitTest/Base64Test.cpp b/Swiften/StringCodecs/UnitTest/Base64Test.cpp deleted file mode 100644 index a28a9ab..0000000 --- a/Swiften/StringCodecs/UnitTest/Base64Test.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> - -#include "Swiften/StringCodecs/Base64.h" - -using namespace Swift; - -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: - void testEncode() { - String result(Base64::encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890")); - CPPUNIT_ASSERT_EQUAL(String("QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejEyMzQ1Njc4OTA="), result); - } - - void testEncode_NonAscii() { - String result(Base64::encode(ByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"))); - 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/HMACSHA1Test.cpp b/Swiften/StringCodecs/UnitTest/HMACSHA1Test.cpp deleted file mode 100644 index edfae10..0000000 --- a/Swiften/StringCodecs/UnitTest/HMACSHA1Test.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> - -#include "Swiften/Base/ByteArray.h" -#include "Swiften/StringCodecs/HMACSHA1.h" - -using namespace Swift; - -class HMACSHA1Test : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(HMACSHA1Test); - CPPUNIT_TEST(testGetResult); - CPPUNIT_TEST_SUITE_END(); - - public: - void testGetResult() { - ByteArray result(HMACSHA1::getResult("foo", "foobar")); - CPPUNIT_ASSERT_EQUAL(ByteArray("\xa4\xee\xba\x8e\x63\x3d\x77\x88\x69\xf5\x68\xd0\x5a\x1b\x3d\xc7\x2b\xfd\x4\xdd"), result); - } -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(HMACSHA1Test); diff --git a/Swiften/StringCodecs/UnitTest/HexifyTest.cpp b/Swiften/StringCodecs/UnitTest/HexifyTest.cpp deleted file mode 100644 index bf032a3..0000000 --- a/Swiften/StringCodecs/UnitTest/HexifyTest.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> - -#include "Swiften/StringCodecs/Hexify.h" -#include "Swiften/Base/String.h" -#include "Swiften/Base/ByteArray.h" - -using namespace Swift; - -class HexifyTest : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(HexifyTest); - CPPUNIT_TEST(testHexify); - CPPUNIT_TEST_SUITE_END(); - - public: - void testHexify() { - CPPUNIT_ASSERT_EQUAL(String("4206b23ca6b0a643d20d89b04ff58cf78b8096ed"), Hexify::hexify(ByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"))); - } -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(HexifyTest); diff --git a/Swiften/StringCodecs/UnitTest/MD5Test.cpp b/Swiften/StringCodecs/UnitTest/MD5Test.cpp deleted file mode 100644 index cad8754..0000000 --- a/Swiften/StringCodecs/UnitTest/MD5Test.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> - -#include "Swiften/StringCodecs/MD5.h" -#include "Swiften/Base/ByteArray.h" - -using namespace Swift; - -class MD5Test : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(MD5Test); - CPPUNIT_TEST(testGetHash_Empty); - CPPUNIT_TEST(testGetHash_Alphabet); - CPPUNIT_TEST_SUITE_END(); - - public: - void testGetHash_Empty() { - ByteArray result(MD5::getHash("")); - - CPPUNIT_ASSERT_EQUAL(ByteArray("\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04\xe9\x80\x09\x98\xec\xf8\x42\x7e", 16), result); - } - - void testGetHash_Alphabet() { - ByteArray result(MD5::getHash("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")); - - CPPUNIT_ASSERT_EQUAL(ByteArray("\xd1\x74\xab\x98\xd2\x77\xd9\xf5\xa5\x61\x1c\x2c\x9f\x41\x9d\x9f", 16), result); - } -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(MD5Test); diff --git a/Swiften/StringCodecs/UnitTest/PBKDF2Test.cpp b/Swiften/StringCodecs/UnitTest/PBKDF2Test.cpp deleted file mode 100644 index 92f4fe9..0000000 --- a/Swiften/StringCodecs/UnitTest/PBKDF2Test.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> - -#include "Swiften/Base/ByteArray.h" -#include "Swiften/StringCodecs/PBKDF2.h" - -using namespace Swift; - -class PBKDF2Test : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(PBKDF2Test); - CPPUNIT_TEST(testGetResult_I1); - CPPUNIT_TEST(testGetResult_I2); - CPPUNIT_TEST(testGetResult_I4096); - CPPUNIT_TEST_SUITE_END(); - - public: - void testGetResult_I1() { - ByteArray result(PBKDF2::encode("password", "salt", 1)); - - CPPUNIT_ASSERT_EQUAL(ByteArray("\x0c\x60\xc8\x0f\x96\x1f\x0e\x71\xf3\xa9\xb5\x24\xaf\x60\x12\x06\x2f\xe0\x37\xa6"), result); - } - - void testGetResult_I2() { - ByteArray result(PBKDF2::encode("password", "salt", 2)); - - CPPUNIT_ASSERT_EQUAL(ByteArray("\xea\x6c\x1\x4d\xc7\x2d\x6f\x8c\xcd\x1e\xd9\x2a\xce\x1d\x41\xf0\xd8\xde\x89\x57"), result); - } - - void testGetResult_I4096() { - ByteArray result(PBKDF2::encode("password", "salt", 4096)); - - CPPUNIT_ASSERT_EQUAL(ByteArray("\x4b\x00\x79\x1\xb7\x65\x48\x9a\xbe\xad\x49\xd9\x26\xf7\x21\xd0\x65\xa4\x29\xc1", 20), result); - } -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(PBKDF2Test); diff --git a/Swiften/StringCodecs/UnitTest/SHA1Test.cpp b/Swiften/StringCodecs/UnitTest/SHA1Test.cpp deleted file mode 100644 index 3dbf341..0000000 --- a/Swiften/StringCodecs/UnitTest/SHA1Test.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> - -#include "Swiften/StringCodecs/SHA1.h" - -using namespace Swift; - -class SHA1Test : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(SHA1Test); - CPPUNIT_TEST(testGetHash); - CPPUNIT_TEST(testGetHash_Twice); - CPPUNIT_TEST(testGetHash_NoData); - CPPUNIT_TEST_SUITE_END(); - - public: - void testGetHash() { - ByteArray result(SHA1::getHash("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(ByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"), result); - } - - - void testGetHash_Twice() { - ByteArray input("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<"); - SHA1::getHash(input); - ByteArray result(SHA1::getHash(input)); - - CPPUNIT_ASSERT_EQUAL(ByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"), result); - } - - void testGetHash_NoData() { - ByteArray result(SHA1::getHash(ByteArray())); - - CPPUNIT_ASSERT_EQUAL(ByteArray("\xda\x39\xa3\xee\x5e\x6b\x4b\x0d\x32\x55\xbf\xef\x95\x60\x18\x90\xaf\xd8\x07\x09"), result); - } -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(SHA1Test); |