[Libreoffice-commits] core.git: comphelper/qa
Markus Mohrhard
markus.mohrhard at googlemail.com
Sat Apr 29 05:56:25 UTC 2017
comphelper/qa/unit/test_hash.cxx | 12 ++++++++++++
1 file changed, 12 insertions(+)
New commits:
commit 5bd7713a6b7aa3ad0eaa7f535cd932c2a316acb5
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Apr 21 05:51:46 2017 +0200
add test for MD5 hashing
Change-Id: If13f6d800b857cc6d581ef7800beb0f25b3f5a37
Reviewed-on: https://gerrit.libreoffice.org/36793
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
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);
More information about the Libreoffice-commits
mailing list