summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-04-21 05:51:46 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-04-29 07:55:48 +0200
commit5bd7713a6b7aa3ad0eaa7f535cd932c2a316acb5 (patch)
tree0ce830181a1ea6d2debee78c31f6fda9844392b3 /comphelper
parentcf45dda9a515e92d97dc6202b78f0dd1a41781a2 (diff)
add test for MD5 hashing
Change-Id: If13f6d800b857cc6d581ef7800beb0f25b3f5a37 Reviewed-on: https://gerrit.libreoffice.org/36793 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/qa/unit/test_hash.cxx12
1 files changed, 12 insertions, 0 deletions
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<unsigned char>& a)
}
+void TestHash::testMD5()
+{
+ comphelper::Hash aHash(comphelper::HashType::MD5);
+ const char* const pInput = "";
+ aHash.update(reinterpret_cast<const unsigned char*>(pInput), 0);
+ std::vector<unsigned char> 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);