You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

30 lines
895 B

#include "md5.h"
#include "helper.h"
#include "gtest/gtest.h"
using md5::MD5;
TEST(md5sum, empty) {
auto expect = "d41d8cd98f00b204e9800998ecf8427e";
EXPECT_EQ(MD5::Hash(""), expect);
EXPECT_EQ(MD5::HashCE(""), expect);
EXPECT_EQ(MD5().Final().Digest(), expect);
MD5 md5;
EXPECT_EQ(md5.Reset().Final().Digest(), expect);
EXPECT_EQ(md5.Reset().Final().Digest(), expect);
EXPECT_EQ(md5.Reset().Update("").Final().Digest(), expect);
}
TEST(md5sum, simple) {
auto expect = "5227827849ea5e9d942ff40dbbfaffd6";
EXPECT_EQ(MD5::Hash("dnomd343"), expect);
EXPECT_EQ(MD5::HashCE("dnomd343"), expect);
MD5 md5;
EXPECT_EQ(md5.Reset().Update("").Update("dnomd343").Final().Digest(), expect);
EXPECT_EQ(md5.Reset().Update("dnomd").Update("343").Final().Digest(), expect);
EXPECT_EQ(md5.Reset().Update("dnomd343").Final().Digest(), expect);
}