summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2011-12-28 20:24:58 +0100
committernulltoken <emeric.fermas@gmail.com>2011-12-28 20:25:29 +0100
commiteb8de7476b4d3caeac518ff9af459c49cfd78e35 (patch)
treef77a41b173b4b504591f230f287a0066a1c28ac2 /tests
parent06fcf057b6da37ffd388e4a31c2671b20d0dd21e (diff)
downloadlibgit2-eb8de7476b4d3caeac518ff9af459c49cfd78e35.tar.gz
util: add git__fromhex()
Diffstat (limited to 'tests')
-rw-r--r--tests/t01-rawobj.c15
1 files changed, 2 insertions, 13 deletions
diff --git a/tests/t01-rawobj.c b/tests/t01-rawobj.c
index 8b05f3394..7b9ca1ee1 100644
--- a/tests/t01-rawobj.c
+++ b/tests/t01-rawobj.c
@@ -52,17 +52,6 @@ BEGIN_TEST(oid2, "fail when parsing an invalid string as oid")
must_fail(git_oid_fromstr(&out, "moo"));
END_TEST
-static int from_hex(unsigned int i)
-{
- if (i >= '0' && i <= '9')
- return i - '0';
- if (i >= 'a' && i <= 'f')
- return 10 + (i - 'a');
- if (i >= 'A' && i <= 'F')
- return 10 + (i - 'A');
- return -1;
-}
-
BEGIN_TEST(oid3, "find all invalid characters when parsing an oid")
git_oid out;
unsigned char exp[] = {
@@ -77,8 +66,8 @@ BEGIN_TEST(oid3, "find all invalid characters when parsing an oid")
for (i = 0; i < 256; i++) {
in[38] = (char)i;
- if (from_hex(i) >= 0) {
- exp[19] = (unsigned char)(from_hex(i) << 4);
+ if (git__fromhex(i) >= 0) {
+ exp[19] = (unsigned char)(git__fromhex(i) << 4);
must_pass(git_oid_fromstr(&out, in));
must_be_true(memcmp(out.id, exp, sizeof(out.id)) == 0);
} else {