mirror of https://github.com/dnomd343/md5sum.git
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.
44 lines
1.0 KiB
44 lines
1.0 KiB
8 months ago
|
#include <gtest/gtest.h>
|
||
8 months ago
|
|
||
8 months ago
|
#include "md5.h"
|
||
8 months ago
|
|
||
|
std::string test_data() {
|
||
|
char data[64];
|
||
|
for (char i = 0; i < 64; ++i) {
|
||
|
data[i] = i;
|
||
|
}
|
||
|
return {data, data + 64};
|
||
|
}
|
||
|
|
||
8 months ago
|
void dump_ctx(const md5::MD5::md5_ctx *c) {
|
||
8 months ago
|
std::cout << std::hex << c->A << std::endl;
|
||
|
std::cout << std::hex << c->B << std::endl;
|
||
|
std::cout << std::hex << c->C << std::endl;
|
||
|
std::cout << std::hex << c->D << std::endl;
|
||
|
std::cout << std::dec << c->size << std::endl;
|
||
|
}
|
||
|
|
||
8 months ago
|
TEST(md5sum, main) {
|
||
8 months ago
|
auto data = test_data() + test_data() + test_data() + test_data();
|
||
|
|
||
8 months ago
|
md5::MD5::md5_ctx c;
|
||
8 months ago
|
dump_ctx(&c);
|
||
|
|
||
8 months ago
|
// md5::md5_update(&c, data.c_str(), data.size());
|
||
|
// md5::md5_update(&c, data.c_str(), data.size());
|
||
|
// dump_ctx(&c);
|
||
|
|
||
|
// md5::md5_reset(&c);
|
||
|
// md5::md5_update(&c, data.c_str(), data.size());
|
||
|
// md5::md5_update(&c, data.c_str(), data.size());
|
||
|
// dump_ctx(&c);
|
||
|
|
||
8 months ago
|
md5::MD5::md5_final(&c, data.c_str(), 0);
|
||
8 months ago
|
dump_ctx(&c);
|
||
|
|
||
8 months ago
|
md5::MD5::md5_reset(&c);
|
||
|
md5::MD5::md5_final(&c, data.c_str(), data.size());
|
||
8 months ago
|
dump_ctx(&c);
|
||
8 months ago
|
|
||
8 months ago
|
}
|