Kaydet (Commit) 5bd7713a authored tarafından Markus Mohrhard's avatar Markus Mohrhard

add test for MD5 hashing

Change-Id: If13f6d800b857cc6d581ef7800beb0f25b3f5a37
Reviewed-on: https://gerrit.libreoffice.org/36793Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst cf45dda9
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment