18
18
schar * hex = s_base_16_enc ((sbyte *) testdata1, testdata_size, &out_size);
20
s_print ("HEX: %s\n", hex);
20
//s_print ("HEX: %s\n", hex);
22
22
test_case (s_string_is_equal ("48656C6C6F20576F726C6421", hex), "The Base16 data has the expected value.");
28
28
schar * ret = (schar *) s_base_16_dec (hex, hex_size, &out2_size);
30
s_print ("Test data: %s, The output from the decoding: %s\n", testdata1, ret);
30
//s_print ("Test data: %s, The output from the decoding: %s\n", testdata1, ret);
32
32
test_case (s_string_is_equal (testdata1, ret), "The string has the expected value");
37
//////////////////////////////////////////////////////////////////////////////
37
39
testdata_size = strlen (testdata2);
39
41
hex = s_base_16_enc ((sbyte *) testdata2, testdata_size, &out_size);
41
43
test_case (s_string_is_equal ("48656C6C6F20576F726C64", hex), "The Base16 data has the expected value.");
43
s_print ("HEX: %s\n", hex);
45
//s_print ("HEX: %s\n", hex);
45
47
hex_size = strlen (hex);
47
49
test_case (out_size == hex_size, "The outputed string has the same length as what the function reports.");
51
ret = (schar *) s_base_16_dec (hex, hex_size, &out2_size);
53
test_case (s_string_is_equal (testdata2, ret), "The string has the expected value");
60
typedef struct TestBase16Struct {
62
slong some_other_value;
66
test_base_16_object (void) {
69
TestBase16Struct * t1 = s_malloc (sizeof (TestBase16Struct));
70
t1->some_value = 1337;
71
t1->some_other_value = 7331;
73
size_t testdata_size = sizeof (TestBase16Struct),
77
schar * t_hex = s_base_16_enc ((sbyte *) t1, testdata_size, &out_size);
79
s_print ("%s\n", t_hex);
81
TestBase16Struct * t2 = (TestBase16Struct *) s_base_16_dec (t_hex, out_size, &out2_size);
83
s_print ("TestBase16Struct: some_value: %i, some_other_value: %li\n", t2->some_value, t2->some_other_value);
85
test_case (t2->some_value == t1->some_value, "some_value are equal.");
86
test_case (t2->some_other_value == t1->some_other_value, "some_other_value are equal");