From: Aki Tuomi Date: Mon, 27 May 2013 09:17:29 +0000 (+0300) Subject: Simple test suite to verify md5 summer X-Git-Tag: auth-3.3-rc1~1^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2e28d1f0dcb50a79d0ca60ae9696c5bea71943d9;p=pdns Simple test suite to verify md5 summer --- diff --git a/pdns/test-md5_hh.cc b/pdns/test-md5_hh.cc new file mode 100644 index 000000000..08960d330 --- /dev/null +++ b/pdns/test-md5_hh.cc @@ -0,0 +1,43 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_NO_MAIN +#include +#include +#include +#include "md5.hh" +#include "misc.hh" + +using namespace boost; + +BOOST_AUTO_TEST_SUITE(test_md5_hh) + +BOOST_AUTO_TEST_CASE(test_md5summer) +{ + std::string result = "a3 24 8c e3 1a 88 a6 40 e6 30 73 98 57 6d 06 9e "; + std::vector cases = boost::assign::list_of + ("a ") + ("quick ") + ("brown ") + ("fox ") + ("jumped ") + ("over ") + ("the ") + ("lazy ") + ("dog"); + + MD5Summer s; + BOOST_FOREACH(std::string item, cases) { + s.feed(item); + } + + BOOST_CHECK_EQUAL(makeHexDump(s.get()), result); +} + +BOOST_AUTO_TEST_CASE(test_pdns_md5sum) +{ + std::string result = "a3 24 8c e3 1a 88 a6 40 e6 30 73 98 57 6d 06 9e "; + std::string sum = pdns_md5sum("a quick brown fox jumped over the lazy dog"); + + BOOST_CHECK_EQUAL(makeHexDump(sum), result); +} + +BOOST_AUTO_TEST_SUITE_END()