File: hex.c

package info (click to toggle)
libgit2 0.27.7%2Bdfsg.1-0.2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 31,400 kB
  • sloc: ansic: 157,824; sh: 406; python: 182; php: 65; makefile: 61
file content (22 lines) | stat: -rw-r--r-- 617 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "clar_libgit2.h"
#include "util.h"

void test_core_hex__fromhex(void)
{
	/* Passing cases */
	cl_assert(git__fromhex('0') == 0x0);
	cl_assert(git__fromhex('1') == 0x1);
	cl_assert(git__fromhex('3') == 0x3);
	cl_assert(git__fromhex('9') == 0x9);
	cl_assert(git__fromhex('A') == 0xa);
	cl_assert(git__fromhex('C') == 0xc);
	cl_assert(git__fromhex('F') == 0xf);
	cl_assert(git__fromhex('a') == 0xa);
	cl_assert(git__fromhex('c') == 0xc);
	cl_assert(git__fromhex('f') == 0xf);

	/* Failing cases */
	cl_assert(git__fromhex('g') == -1);
	cl_assert(git__fromhex('z') == -1);
	cl_assert(git__fromhex('X') == -1);
}