/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk
5.2.5 by Gustav Hartvigsson
Woops, foregot the test of the Error Objects...
1
#include "SimpleTypeSystem.h"
39 by Gustav Hartvigsson
* Added "check" target for testing.
2
#include "error.h"
3
#include "test_macros.h"
4
5
int test_error () {
6
  setup_unit ();
7
  
8
  SError * e = NULL;
9
  char * s = NULL;
10
  
11
  char * expected_string = NULL;
12
  
13
  e = s_error_new (S_ERROR_NONE, "Nothing at all...");
14
  
15
  test_case (e != NULL, "SError object is not NULL.");
16
  
17
  expected_string = s_string_new ("Error: NONE, Message: Nothing at all...");
18
  
19
  s = s_object_to_string (S_OBJECT(e));
20
  
21
  test_case (strcmp (expected_string, s) == 0, "Expected string matches the result.")
22
  
23
  s_print ("%s\n", s);
24
  
5.2.5 by Gustav Hartvigsson
Woops, foregot the test of the Error Objects...
25
  free (s);
39 by Gustav Hartvigsson
* Added "check" target for testing.
26
  free (expected_string);
27
  
28
  test_case (s_object_unref (S_OBJECT(e)) == 0,
29
             "SError's refcount is 0 on unref.");
5.2.5 by Gustav Hartvigsson
Woops, foregot the test of the Error Objects...
30
  
31
  e = s_error_new (S_ERROR_INPUT_OUTPUT, "Generic I/O Error...");
39 by Gustav Hartvigsson
* Added "check" target for testing.
32
  s = s_object_to_string (S_OBJECT(e));
5.2.5 by Gustav Hartvigsson
Woops, foregot the test of the Error Objects...
33
  
39 by Gustav Hartvigsson
* Added "check" target for testing.
34
  s_print ("%s\n", s);
5.2.5 by Gustav Hartvigsson
Woops, foregot the test of the Error Objects...
35
  
36
  free (s);
37
  
39 by Gustav Hartvigsson
* Added "check" target for testing.
38
  s_object_unref (S_OBJECT(e));
5.2.5 by Gustav Hartvigsson
Woops, foregot the test of the Error Objects...
39
  
40
  e = s_error_new (S_ERROR_OVERFLOW, "A Generic overflow error...");
39 by Gustav Hartvigsson
* Added "check" target for testing.
41
  s = s_object_to_string (S_OBJECT(e));
5.2.5 by Gustav Hartvigsson
Woops, foregot the test of the Error Objects...
42
  
39 by Gustav Hartvigsson
* Added "check" target for testing.
43
  s_print ("%s\n", s);
5.2.5 by Gustav Hartvigsson
Woops, foregot the test of the Error Objects...
44
  
45
  free (s);
46
  
39 by Gustav Hartvigsson
* Added "check" target for testing.
47
  s_object_unref (S_OBJECT(e));
5.2.5 by Gustav Hartvigsson
Woops, foregot the test of the Error Objects...
48
  
49
  e = s_error_new (S_ERROR_OTHER, "Some unknowned error type...");
39 by Gustav Hartvigsson
* Added "check" target for testing.
50
  s = s_object_to_string (S_OBJECT(e));
5.2.5 by Gustav Hartvigsson
Woops, foregot the test of the Error Objects...
51
  
39 by Gustav Hartvigsson
* Added "check" target for testing.
52
  s_print ("%s\n", s);
5.2.5 by Gustav Hartvigsson
Woops, foregot the test of the Error Objects...
53
  
54
  free (s);
55
  
39 by Gustav Hartvigsson
* Added "check" target for testing.
56
  s_object_unref (S_OBJECT(e));
5.2.5 by Gustav Hartvigsson
Woops, foregot the test of the Error Objects...
57
  
58
  
59
  e = s_error_new (S_ERROR_NULL, "A NULL error...");
39 by Gustav Hartvigsson
* Added "check" target for testing.
60
  s = s_object_to_string (S_OBJECT(e));
5.2.5 by Gustav Hartvigsson
Woops, foregot the test of the Error Objects...
61
  
39 by Gustav Hartvigsson
* Added "check" target for testing.
62
  s_print ("%s\n", s);
5.2.5 by Gustav Hartvigsson
Woops, foregot the test of the Error Objects...
63
  
64
  free (s);
65
  
39 by Gustav Hartvigsson
* Added "check" target for testing.
66
  s_object_unref (S_OBJECT(e));
67
  end_unit ();
5.2.5 by Gustav Hartvigsson
Woops, foregot the test of the Error Objects...
68
}