summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-08-12 17:29:21 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-08-12 17:32:17 (GMT)
commitc6ffcd27e94d2f90fd4a3bcb5d2d3c6550ead59c (patch)
tree5968399a0d1ae73c1f197630bef3a0960e8525b5 /Swiften/StringCodecs/UnitTest/HMACTest.cpp
parent08cfaa06859238449d6848df4e170ffb6dc605d3 (diff)
downloadswift-contrib-c6ffcd27e94d2f90fd4a3bcb5d2d3c6550ead59c.zip
swift-contrib-c6ffcd27e94d2f90fd4a3bcb5d2d3c6550ead59c.tar.bz2
Refactored stringcodec functions to make them independent of hash algos.
Diffstat (limited to 'Swiften/StringCodecs/UnitTest/HMACTest.cpp')
-rw-r--r--Swiften/StringCodecs/UnitTest/HMACTest.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/Swiften/StringCodecs/UnitTest/HMACTest.cpp b/Swiften/StringCodecs/UnitTest/HMACTest.cpp
new file mode 100644
index 0000000..bdb0d96
--- /dev/null
+++ b/Swiften/StringCodecs/UnitTest/HMACTest.cpp
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <Swiften/Base/ByteArray.h>
+#include <QA/Checker/IO.h>
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+#include <Swiften/Base/ByteArray.h>
+#include <Swiften/StringCodecs/HMAC.h>
+#include <Swiften/StringCodecs/SHA1.h>
+
+using namespace Swift;
+
+class HMACTest : public CppUnit::TestFixture {
+ CPPUNIT_TEST_SUITE(HMACTest);
+ CPPUNIT_TEST(testGetResult);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testGetResult() {
+ ByteArray result(HMAC<SHA1>()(createSafeByteArray("foo"), createByteArray("foobar")));
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\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(HMACTest);