| 3 | #include "strbuf.h" |
| 4 | |
| 5 | static void check_hash_data(const void *data, size_t data_length, |
| 6 | const char *expected_hashes[]) |
| 7 | { |
| 8 | cl_assert(data != NULL); |
| 9 | |
| 10 | for (size_t i = 1; i < ARRAY_SIZE(hash_algos); i++) { |
| 11 | struct git_hash_ctx ctx; |
| 12 | unsigned char hash[GIT_MAX_HEXSZ]; |
| 13 | const struct git_hash_algo *algop = &hash_algos[i]; |
| 14 | |
| 15 | algop->init_fn(&ctx); |
| 16 | git_hash_update(&ctx, data, data_length); |
| 17 | git_hash_final(hash, &ctx); |
| 18 | |
| 19 | cl_assert_equal_s(hash_to_hex_algop(hash,algop), expected_hashes[i - 1]); |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | /* Works with a NUL terminated string. Doesn't work if it should contain a NUL character. */ |
| 24 | #define TEST_HASH_STR(data, expected_sha1, expected_sha256) do { \ |
nothing calls this directly
no test coverage detected