diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2022-01-22 23:10:03 -0500 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2022-06-14 22:29:57 -0400 |
| commit | dbc4ac1c76827e954e0aa27afe8bb7e0b8993a93 (patch) | |
| tree | 56f18a11bca8d17490a176cddf9e3756c2cebe91 /tests/libgit2/object | |
| parent | f98dd5438f8d7bfd557b612fdf1605b1c3fb8eaf (diff) | |
| download | libgit2-dbc4ac1c76827e954e0aa27afe8bb7e0b8993a93.tar.gz | |
oid: `GIT_OID_*SZ` is now `GIT_OID_SHA1_*SIZE`
In preparation for SHA256 support, `GIT_OID_RAWSZ` and `GIT_OID_HEXSZ`
need to indicate that they're the size of _SHA1_ OIDs.
Diffstat (limited to 'tests/libgit2/object')
| -rw-r--r-- | tests/libgit2/object/raw/compare.c | 16 | ||||
| -rw-r--r-- | tests/libgit2/object/raw/convert.c | 36 | ||||
| -rw-r--r-- | tests/libgit2/object/raw/short.c | 6 | ||||
| -rw-r--r-- | tests/libgit2/object/raw/size.c | 8 |
4 files changed, 33 insertions, 33 deletions
diff --git a/tests/libgit2/object/raw/compare.c b/tests/libgit2/object/raw/compare.c index 56c016b72..9369bc21f 100644 --- a/tests/libgit2/object/raw/compare.c +++ b/tests/libgit2/object/raw/compare.c @@ -76,17 +76,17 @@ void test_object_raw_compare__compare_fmt_oids(void) { const char *exp = "16a0123456789abcdef4b775213c23a8bd74f5e0"; git_oid in; - char out[GIT_OID_HEXSZ + 1]; + char out[GIT_OID_SHA1_HEXSIZE + 1]; cl_git_pass(git_oid_fromstr(&in, exp)); /* Format doesn't touch the last byte */ - out[GIT_OID_HEXSZ] = 'Z'; + out[GIT_OID_SHA1_HEXSIZE] = 'Z'; git_oid_fmt(out, &in); - cl_assert(out[GIT_OID_HEXSZ] == 'Z'); + cl_assert(out[GIT_OID_SHA1_HEXSIZE] == 'Z'); /* Format produced the right result */ - out[GIT_OID_HEXSZ] = '\0'; + out[GIT_OID_SHA1_HEXSIZE] = '\0'; cl_assert_equal_s(exp, out); } @@ -108,16 +108,16 @@ void test_object_raw_compare__compare_pathfmt_oids(void) const char *exp1 = "16a0123456789abcdef4b775213c23a8bd74f5e0"; const char *exp2 = "16/a0123456789abcdef4b775213c23a8bd74f5e0"; git_oid in; - char out[GIT_OID_HEXSZ + 2]; + char out[GIT_OID_SHA1_HEXSIZE + 2]; cl_git_pass(git_oid_fromstr(&in, exp1)); /* Format doesn't touch the last byte */ - out[GIT_OID_HEXSZ + 1] = 'Z'; + out[GIT_OID_SHA1_HEXSIZE + 1] = 'Z'; git_oid_pathfmt(out, &in); - cl_assert(out[GIT_OID_HEXSZ + 1] == 'Z'); + cl_assert(out[GIT_OID_SHA1_HEXSIZE + 1] == 'Z'); /* Format produced the right result */ - out[GIT_OID_HEXSZ + 1] = '\0'; + out[GIT_OID_SHA1_HEXSIZE + 1] = '\0'; cl_assert_equal_s(exp2, out); } diff --git a/tests/libgit2/object/raw/convert.c b/tests/libgit2/object/raw/convert.c index 40a01ae09..ebf2bb8e4 100644 --- a/tests/libgit2/object/raw/convert.c +++ b/tests/libgit2/object/raw/convert.c @@ -7,7 +7,7 @@ void test_object_raw_convert__succeed_on_oid_to_string_conversion(void) { const char *exp = "16a0123456789abcdef4b775213c23a8bd74f5e0"; git_oid in; - char out[GIT_OID_HEXSZ + 1]; + char out[GIT_OID_SHA1_HEXSIZE + 1]; char *str; int i; @@ -29,7 +29,7 @@ void test_object_raw_convert__succeed_on_oid_to_string_conversion(void) str = git_oid_tostr(out, 1, &in); cl_assert(str && *str == '\0' && str == out); - for (i = 1; i < GIT_OID_HEXSZ; i++) { + for (i = 1; i < GIT_OID_SHA1_HEXSIZE; i++) { out[i+1] = 'Z'; str = git_oid_tostr(out, i+1, &in); /* returns out containing c-string */ @@ -44,7 +44,7 @@ void test_object_raw_convert__succeed_on_oid_to_string_conversion(void) /* returns out as hex formatted c-string */ str = git_oid_tostr(out, sizeof(out), &in); - cl_assert(str && str == out && *(str+GIT_OID_HEXSZ) == '\0'); + cl_assert(str && str == out && *(str+GIT_OID_SHA1_HEXSIZE) == '\0'); cl_assert_equal_s(exp, out); } @@ -52,26 +52,26 @@ void test_object_raw_convert__succeed_on_oid_to_string_conversion_big(void) { const char *exp = "16a0123456789abcdef4b775213c23a8bd74f5e0"; git_oid in; - char big[GIT_OID_HEXSZ + 1 + 3]; /* note + 4 => big buffer */ + char big[GIT_OID_SHA1_HEXSIZE + 1 + 3]; /* note + 4 => big buffer */ char *str; cl_git_pass(git_oid_fromstr(&in, exp)); /* place some tail material */ - big[GIT_OID_HEXSZ+0] = 'W'; /* should be '\0' afterwards */ - big[GIT_OID_HEXSZ+1] = 'X'; /* should remain untouched */ - big[GIT_OID_HEXSZ+2] = 'Y'; /* ditto */ - big[GIT_OID_HEXSZ+3] = 'Z'; /* ditto */ + big[GIT_OID_SHA1_HEXSIZE+0] = 'W'; /* should be '\0' afterwards */ + big[GIT_OID_SHA1_HEXSIZE+1] = 'X'; /* should remain untouched */ + big[GIT_OID_SHA1_HEXSIZE+2] = 'Y'; /* ditto */ + big[GIT_OID_SHA1_HEXSIZE+3] = 'Z'; /* ditto */ /* returns big as hex formatted c-string */ str = git_oid_tostr(big, sizeof(big), &in); - cl_assert(str && str == big && *(str+GIT_OID_HEXSZ) == '\0'); + cl_assert(str && str == big && *(str+GIT_OID_SHA1_HEXSIZE) == '\0'); cl_assert_equal_s(exp, big); /* check tail material is untouched */ - cl_assert(str && str == big && *(str+GIT_OID_HEXSZ+1) == 'X'); - cl_assert(str && str == big && *(str+GIT_OID_HEXSZ+2) == 'Y'); - cl_assert(str && str == big && *(str+GIT_OID_HEXSZ+3) == 'Z'); + cl_assert(str && str == big && *(str+GIT_OID_SHA1_HEXSIZE+1) == 'X'); + cl_assert(str && str == big && *(str+GIT_OID_SHA1_HEXSIZE+2) == 'Y'); + cl_assert(str && str == big && *(str+GIT_OID_SHA1_HEXSIZE+3) == 'Z'); } static void check_partial_oid( @@ -86,14 +86,14 @@ void test_object_raw_convert__convert_oid_partially(void) { const char *exp = "16a0123456789abcdef4b775213c23a8bd74f5e0"; git_oid in; - char big[GIT_OID_HEXSZ + 1 + 3]; /* note + 4 => big buffer */ + char big[GIT_OID_SHA1_HEXSIZE + 1 + 3]; /* note + 4 => big buffer */ cl_git_pass(git_oid_fromstr(&in, exp)); git_oid_nfmt(big, sizeof(big), &in); cl_assert_equal_s(exp, big); - git_oid_nfmt(big, GIT_OID_HEXSZ + 1, &in); + git_oid_nfmt(big, GIT_OID_SHA1_HEXSIZE + 1, &in); cl_assert_equal_s(exp, big); check_partial_oid(big, 1, &in, "1"); @@ -102,11 +102,11 @@ void test_object_raw_convert__convert_oid_partially(void) check_partial_oid(big, 4, &in, "16a0"); check_partial_oid(big, 5, &in, "16a01"); - check_partial_oid(big, GIT_OID_HEXSZ, &in, exp); + check_partial_oid(big, GIT_OID_SHA1_HEXSIZE, &in, exp); check_partial_oid( - big, GIT_OID_HEXSZ - 1, &in, "16a0123456789abcdef4b775213c23a8bd74f5e"); + big, GIT_OID_SHA1_HEXSIZE - 1, &in, "16a0123456789abcdef4b775213c23a8bd74f5e"); check_partial_oid( - big, GIT_OID_HEXSZ - 2, &in, "16a0123456789abcdef4b775213c23a8bd74f5"); + big, GIT_OID_SHA1_HEXSIZE - 2, &in, "16a0123456789abcdef4b775213c23a8bd74f5"); check_partial_oid( - big, GIT_OID_HEXSZ - 3, &in, "16a0123456789abcdef4b775213c23a8bd74f"); + big, GIT_OID_SHA1_HEXSIZE - 3, &in, "16a0123456789abcdef4b775213c23a8bd74f"); } diff --git a/tests/libgit2/object/raw/short.c b/tests/libgit2/object/raw/short.c index cc2b5f62a..102526844 100644 --- a/tests/libgit2/object/raw/short.c +++ b/tests/libgit2/object/raw/short.c @@ -17,7 +17,7 @@ void test_object_raw_short__oid_shortener_no_duplicates(void) git_oid_shorten_add(os, "16a0123456789abcdef4b775213c23a8bd74f5e0"); min_len = git_oid_shorten_add(os, "ce08fe4884650f067bd5703b6a59a8b3b3c99a09"); - cl_assert(min_len == GIT_OID_HEXSZ + 1); + cl_assert(min_len == GIT_OID_SHA1_HEXSIZE + 1); git_oid_shorten_free(os); } @@ -38,9 +38,9 @@ static int insert_sequential_oids( git_oid_fromraw(&oid, hashbuf); - oids[i] = git__malloc(GIT_OID_HEXSZ + 1); + oids[i] = git__malloc(GIT_OID_SHA1_HEXSIZE + 1); cl_assert(oids[i]); - git_oid_nfmt(oids[i], GIT_OID_HEXSZ + 1, &oid); + git_oid_nfmt(oids[i], GIT_OID_SHA1_HEXSIZE + 1, &oid); min_len = git_oid_shorten_add(os, oids[i]); diff --git a/tests/libgit2/object/raw/size.c b/tests/libgit2/object/raw/size.c index 930c6de23..ab6b1ffdf 100644 --- a/tests/libgit2/object/raw/size.c +++ b/tests/libgit2/object/raw/size.c @@ -6,8 +6,8 @@ void test_object_raw_size__validate_oid_size(void) { git_oid out; - cl_assert(20 == GIT_OID_RAWSZ); - cl_assert(40 == GIT_OID_HEXSZ); - cl_assert(sizeof(out) == GIT_OID_RAWSZ); - cl_assert(sizeof(out.id) == GIT_OID_RAWSZ); + + cl_assert(20 == GIT_OID_SHA1_SIZE); + cl_assert(40 == GIT_OID_SHA1_HEXSIZE); + cl_assert(sizeof(out.id) == GIT_OID_SHA1_SIZE); } |
