X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/784202a271ae7e303aacbe226bb87fed50a16f81..73da43e90be945d3be9b4f3b6e5016fb7bacb59d:/test/hash.cc?ds=inline diff --git a/test/hash.cc b/test/hash.cc index 5c05d9608..88f09fca0 100644 --- a/test/hash.cc +++ b/test/hash.cc @@ -1,14 +1,26 @@ #include #include +#include #include +#include + +using namespace std; template void Test(const char *In,const char *Out) { T Sum; Sum.Add(In); - cout << Sum.Result().Value() << endl; - if (stringcasecmp(Sum.Result().Value(),Out) != 0) + + cout << "expected: '" << Out << "'" << endl; + cout << "got : '" << Sum.Result().Value() << "'" << endl; + cout << "got : '" << Sum.Result().Value() << "'" << endl; + cout << "got : '" << Sum.Result().Value() << "'" << endl; + if (stringcasecmp(Sum.Result().Value(), Out) != 0) { + cout << "FAIL" << endl << endl; abort(); + } else { + cout << "PASS" << endl << endl; + } } template void TestMill(const char *Out) @@ -30,9 +42,8 @@ template void TestMill(const char *Out) Count = 0; } } - - cout << Sum.Result().Value() << endl; - if (stringcasecmp(Sum.Result().Value(),Out) != 0) + + if (stringcasecmp(Sum.Result().Value(), Out) != 0) abort(); } @@ -54,6 +65,17 @@ int main() "d174ab98d277d9f5a5611c2c9f419d9f"); Test("12345678901234567890123456789012345678901234567890123456789012345678901234567890", "57edf4a22be3c955ac49da2e2107b67a"); + + // SHA-256, From FIPS 180-2 + Test("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", + "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"); + + // SHA-512, From + Test( + "abc", + "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a" + "2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"); + return 0; }