MCPcopy Create free account
hub / github.com/git/git / check_hash_data

Function check_hash_data

t/unit-tests/u-hash.c:5–21  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#include "strbuf.h"
4
5static 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 { \

Callers

nothing calls this directly

Calls 3

git_hash_updateFunction · 0.85
git_hash_finalFunction · 0.85
hash_to_hex_algopFunction · 0.85

Tested by

no test coverage detected