/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk
138 by Gustav Hartvigsson
* Fixed s_base_16_enc
1
#include "../libssts/SimpleTypeSystem.h"
2
#include "test_macros.h"
3
#include "base_n.h"
4
5
6
const schar * testdata = "Hello World!";
7
8
int
9
test_base_n (void) {
10
  setup_unit ();
11
  
12
  size_t testdata_size = strlen (testdata),
13
         out_size = 0,
14
         hex_size = 0,
15
         out2_size = 0,
16
         ret_size = 0;
17
  
18
  schar * hex = s_base_16_enc ((sbyte *) testdata, testdata_size, &out_size);
19
  
20
  test_case (s_string_is_equal ("48656C6C6F20576F726C642100", hex), "The Base16 data has the expected value.");
21
  
22
  hex_size = strlen (hex);
23
  
24
  schar * ret = s_base_16_dec (hex, hex_size, &out2_size);
25
  
26
  s_print ("Test data: %s, The output from the decoding: %s\n", testdata, ret);
27
  
28
  test_case (s_string_is_equal (testdata, ret), "The string has the expected value");
29
  
30
  
31
  s_free (hex);
32
  s_free (ret);
33
  
34
  end_unit ();
35
}