]>
Commit | Line | Data |
---|---|---|
9ff46db9 | 1 | |
3fd1520c | 2 | #include "clar_libgit2.h" |
9ff46db9 MS |
3 | |
4 | #include "odb.h" | |
5 | ||
9ff46db9 MS |
6 | void test_object_raw_chars__find_invalid_chars_in_oid(void) |
7 | { | |
8 | git_oid out; | |
9 | unsigned char exp[] = { | |
10 | 0x16, 0xa6, 0x77, 0x70, 0xb7, | |
11 | 0xd8, 0xd7, 0x23, 0x17, 0xc4, | |
12 | 0xb7, 0x75, 0x21, 0x3c, 0x23, | |
13 | 0xa8, 0xbd, 0x74, 0xf5, 0xe0, | |
14 | }; | |
3b2cb2c9 | 15 | char in[] = "16a67770b7d8d72317c4b775213c23a8bd74f5e0"; |
9ff46db9 MS |
16 | unsigned int i; |
17 | ||
18 | for (i = 0; i < 256; i++) { | |
19 | in[38] = (char)i; | |
eb8de747 | 20 | if (git__fromhex(i) >= 0) { |
21 | exp[19] = (unsigned char)(git__fromhex(i) << 4); | |
9ff46db9 MS |
22 | cl_git_pass(git_oid_fromstr(&out, in)); |
23 | cl_assert(memcmp(out.id, exp, sizeof(out.id)) == 0); | |
24 | } else { | |
25 | cl_git_fail(git_oid_fromstr(&out, in)); | |
26 | } | |
27 | } | |
28 | } | |
29 | ||
30 | void test_object_raw_chars__build_valid_oid_from_raw_bytes(void) | |
31 | { | |
32 | git_oid out; | |
33 | unsigned char exp[] = { | |
34 | 0x16, 0xa6, 0x77, 0x70, 0xb7, | |
35 | 0xd8, 0xd7, 0x23, 0x17, 0xc4, | |
36 | 0xb7, 0x75, 0x21, 0x3c, 0x23, | |
37 | 0xa8, 0xbd, 0x74, 0xf5, 0xe0, | |
38 | }; | |
39 | git_oid_fromraw(&out, exp); | |
40 | cl_git_pass(memcmp(out.id, exp, sizeof(out.id))); | |
41 | } |