diff options
Diffstat (limited to 'llvm/unittests/Support')
-rw-r--r-- | llvm/unittests/Support/MD5Test.cpp | 10 | ||||
-rw-r--r-- | llvm/unittests/Support/raw_sha1_ostream_test.cpp | 7 |
2 files changed, 17 insertions, 0 deletions
diff --git a/llvm/unittests/Support/MD5Test.cpp b/llvm/unittests/Support/MD5Test.cpp index c4fa5cd92c1..4d790254503 100644 --- a/llvm/unittests/Support/MD5Test.cpp +++ b/llvm/unittests/Support/MD5Test.cpp @@ -57,4 +57,14 @@ TEST(MD5Test, MD5) { "81948d1f1554f58cd1a56ebb01f808cb"); TestMD5Sum("abcdefghijklmnopqrstuvwxyz", "c3fcd3d76192e4007dfb496cca67e13b"); } + +TEST(MD5HashTest, MD5) { + ArrayRef<uint8_t> Input((const uint8_t *)"abcdefghijklmnopqrstuvwxyz", 26); + std::array<uint8_t, 16> Vec = MD5::hash(Input); + MD5::MD5Result MD5Res; + SmallString<32> Res; + memcpy(MD5Res, Vec.data(), Vec.size()); + MD5::stringifyResult(MD5Res, Res); + EXPECT_EQ(Res, "c3fcd3d76192e4007dfb496cca67e13b"); +} } diff --git a/llvm/unittests/Support/raw_sha1_ostream_test.cpp b/llvm/unittests/Support/raw_sha1_ostream_test.cpp index db2a3e9ab64..1bb4e2eb1d5 100644 --- a/llvm/unittests/Support/raw_sha1_ostream_test.cpp +++ b/llvm/unittests/Support/raw_sha1_ostream_test.cpp @@ -37,6 +37,13 @@ TEST(raw_sha1_ostreamTest, Basic) { ASSERT_EQ("2EF7BDE608CE5404E97D5F042F95F89F1C232871", Hash); } +TEST(sha1_hash_test, Basic) { + ArrayRef<uint8_t> Input((const uint8_t *)"Hello World!", 12); + std::array<uint8_t, 20> Vec = SHA1::hash(Input); + std::string Hash = toHex({(const char *)Vec.data(), 20}); + ASSERT_EQ("2EF7BDE608CE5404E97D5F042F95F89F1C232871", Hash); +} + // Check that getting the intermediate hash in the middle of the stream does // not invalidate the final result. TEST(raw_sha1_ostreamTest, Intermediate) { |