6
const schar * testdata = "Hello World!";
6
const schar * testdata1 = "Hello World!";
7
const schar * testdata2 = "Hello World";
9
10
test_base_n (void) {
12
size_t testdata_size = strlen (testdata),
13
size_t testdata_size = strlen (testdata1),
17
schar * hex = s_base_16_enc ((sbyte *) testdata, testdata_size, &out_size);
18
schar * hex = s_base_16_enc ((sbyte *) testdata1, testdata_size, &out_size);
19
20
s_print ("HEX: %s\n", hex);
21
test_case (s_string_is_equal ("48656C6C6F20576F726C642100", hex), "The Base16 data has the expected value.");
22
test_case (s_string_is_equal ("48656C6C6F20576F726C6421", hex), "The Base16 data has the expected value.");
23
24
hex_size = strlen (hex);
26
test_case (out_size == hex_size, "The outputed string has the same length as what the function reports.");
25
28
schar * ret = (schar *) s_base_16_dec (hex, hex_size, &out2_size);
27
s_print ("Test data: %s, The output from the decoding: %s\n", testdata, ret);
29
test_case (s_string_is_equal (testdata, ret), "The string has the expected value");
30
s_print ("Test data: %s, The output from the decoding: %s\n", testdata1, ret);
32
test_case (s_string_is_equal (testdata1, ret), "The string has the expected value");
37
testdata_size = strlen (testdata2);
39
hex = s_base_16_enc ((sbyte *) testdata2, testdata_size, &out_size);
41
test_case (s_string_is_equal ("48656C6C6F20576F726C64", hex), "The Base16 data has the expected value.");
43
s_print ("HEX: %s\n", hex);
45
hex_size = strlen (hex);
47
test_case (out_size == hex_size, "The outputed string has the same length as what the function reports.");