/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk

« back to all changes in this revision

Viewing changes to tests/base_n.c

  • Committer: Gustav Hartvigsson
  • Date: 2016-08-07 21:08:54 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20160807210854-esvxch63s29kr2kw
* Fixed s_base_16_enc
* started work on s_base_16_dec (have not figured out how why id is not working)
* fixed reverse table size issue (127 -> 128 elements)
* Added tests for Base 16 stuffs
* added s_string_len
* fixed? s_ustring_to_string
* added (do not know if it is working?) s_string_to_ustring
* commented out strdup
* removed mainloop tests from the standard test suite, sholud be run seperatly anyway.
* use libc for memory managment in the tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}