From 5bd7713a6b7aa3ad0eaa7f535cd932c2a316acb5 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Fri, 21 Apr 2017 05:51:46 +0200 Subject: add test for MD5 hashing Change-Id: If13f6d800b857cc6d581ef7800beb0f25b3f5a37 Reviewed-on: https://gerrit.libreoffice.org/36793 Tested-by: Jenkins Reviewed-by: Markus Mohrhard --- comphelper/qa/unit/test_hash.cxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'comphelper/qa/unit/test_hash.cxx') diff --git a/comphelper/qa/unit/test_hash.cxx b/comphelper/qa/unit/test_hash.cxx index 8888d31d1764..070da3c5c6c2 100644 --- a/comphelper/qa/unit/test_hash.cxx +++ b/comphelper/qa/unit/test_hash.cxx @@ -18,11 +18,13 @@ class TestHash : public CppUnit::TestFixture { public: + void testMD5(); void testSHA1(); void testSHA256(); void testSHA512(); CPPUNIT_TEST_SUITE(TestHash); + CPPUNIT_TEST(testMD5); CPPUNIT_TEST(testSHA1); CPPUNIT_TEST(testSHA256); CPPUNIT_TEST(testSHA512); @@ -44,6 +46,16 @@ std::string tostring(const std::vector& a) } +void TestHash::testMD5() +{ + comphelper::Hash aHash(comphelper::HashType::MD5); + const char* const pInput = ""; + aHash.update(reinterpret_cast(pInput), 0); + std::vector calculate_hash = aHash.finalize(); + CPPUNIT_ASSERT_EQUAL(size_t(16), calculate_hash.size()); + CPPUNIT_ASSERT_EQUAL(std::string("d41d8cd98f00b204e9800998ecf8427e"), tostring(calculate_hash)); +} + void TestHash::testSHA1() { comphelper::Hash aHash(comphelper::HashType::SHA1); -- cgit