Permalink
Browse files

test: full test for util::MD5Progressive class

  • Loading branch information...
1 parent 7edd56d commit a297c7fdc9e838b7a977adbc4d9c3e92f11d2d19 @karolherbst karolherbst committed Jun 25, 2012
Showing with 25 additions and 0 deletions.
  1. +1 −0 src/tests/CMakeLists.txt
  2. +24 −0 src/tests/util/MD5_test.cpp
View
@@ -1,4 +1,5 @@
if(NOT WIN32)
add_desura_test(UtilLinux_test util "util")
add_desura_test(gcBuff_test util "util")
+ add_desura_test(MD5_test util "util")
endif()
@@ -0,0 +1,24 @@
+#define BOOST_TEST_MODULE MD5_test
+#include <boost/test/unit_test.hpp>
+
+#include "Common.h"
+#include "util/MD5Progressive.h"
+
+#define EMPTY_MD5 "d41d8cd98f00b204e9800998ecf8427e"
+
+static const char TEST_CSTRING[] = "this is a little test";
+#define TEST_CSTRING_SIZE sizeof(TEST_CSTRING)
+#define TEST_MD5_RESULT "419d085dcebc10a7e6d7115216e9820d"
+
+BOOST_AUTO_TEST_CASE( MD5Progressive_cons )
+{
+ MD5Progressive md5;
+ BOOST_REQUIRE_EQUAL(md5.finish(), EMPTY_MD5);
+}
+
+BOOST_AUTO_TEST_CASE( MD5Progressive_update )
+{
+ MD5Progressive md5;
+ md5.update(TEST_CSTRING, TEST_CSTRING_SIZE - 1);
+ BOOST_REQUIRE_EQUAL(md5.finish(), TEST_MD5_RESULT);
+}

0 comments on commit a297c7f

Please sign in to comment.