/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "../libssts/SimpleTypeSystem.h"
#include "error.h"
#include "test_macros.h"

void
_internal_print_error (SDynamicArray * arr, schar * str, spointer data) {
  s_print ("YO!");
  s_print ("(Error Test): %s\n", str);
  s_print ("YO!");
}

int test_error () {
  setup_unit ();

  SDynamicArray * arr = NULL;

  SError * e = NULL;

  test_case (s_error_has_error (e) == FALSE, "The error is not set. (NULL)");


  e = s_error_new ();
  test_case (e != NULL, "Error is not NULL");
  test_case (s_error_has_error (e) == FALSE, "The error is not set.");

  s_error_append (e, S_ERROR_NONE, "Nothing!", S_ERROR_GET_DEFAULT_DOMAIN);

  test_case (s_error_has_error (e) == TRUE, "The error is set.");

  arr = s_error_to_string_array (e);

  s_dynamic_array_for_each (arr, FOREACHFUNC(_internal_print_error), NULL);

  s_dynamic_array_free (arr, TRUE);

  s_print ("Hello!");

  s_error_free (e);

  s_error_teardown ();
  end_unit ();
}