MCPcopy Create free account
hub / github.com/ddnet/ddnet / TEST

Function TEST

src/test/hash_test.cpp:14–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12}
13
14TEST(Hash, Sha256)
15{
16 // https://en.wikipedia.org/w/index.php?title=SHA-2&oldid=840187620#Test_vectors
17 ExpectSha256(sha256("", 0), "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
18 SHA256_CTX ctxt;
19
20 sha256_init(&ctxt);
21 ExpectSha256(sha256_finish(&ctxt), "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
22
23 // printf 'The quick brown fox jumps over the lazy dog.' | sha256sum
24 char QUICK_BROWN_FOX[] = "The quick brown fox jumps over the lazy dog.";
25 ExpectSha256(sha256(QUICK_BROWN_FOX, str_length(QUICK_BROWN_FOX)), "ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c");
26
27 sha256_init(&ctxt);
28 sha256_update(&ctxt, "The ", 4);
29 sha256_update(&ctxt, "quick ", 6);
30 sha256_update(&ctxt, "brown ", 6);
31 sha256_update(&ctxt, "fox ", 4);
32 sha256_update(&ctxt, "jumps ", 6);
33 sha256_update(&ctxt, "over ", 5);
34 sha256_update(&ctxt, "the ", 4);
35 sha256_update(&ctxt, "lazy ", 5);
36 sha256_update(&ctxt, "dog.", 4);
37 ExpectSha256(sha256_finish(&ctxt), "ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c");
38}
39
40TEST(Hash, Sha256ToStringSmallBuffer)
41{

Callers

nothing calls this directly

Calls 15

ExpectSha256Function · 0.85
sha256Function · 0.85
str_lengthFunction · 0.85
sha256_compFunction · 0.85
sha256_from_strFunction · 0.85
ExpectMd5Function · 0.85
md5Function · 0.85
md5_compFunction · 0.85
md5_from_strFunction · 0.85
sha256_initFunction · 0.50
sha256_finishFunction · 0.50
sha256_updateFunction · 0.50

Tested by

no test coverage detected