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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#include "SimpleTypeSystem.h"
#include "error.h"
#include "test_macros.h"
int test_error () {
setup_unit ();
SError * e = NULL;
char * s = NULL;
char * expected_string = NULL;
e = s_error_new (S_ERROR_NONE, "Nothing at all...");
test_case (e != NULL, "SError object is not NULL.");
expected_string = s_string_new ("Error: NONE, Message: Nothing at all...");
s = s_object_to_string (S_OBJECT(e));
test_case (strcmp (expected_string, s) == 0, "Expected string matches the result.")
s_print ("%s\n", s);
free (s);
free (expected_string);
test_case (s_object_unref (S_OBJECT(e)) == 0,
"SError's refcount is 0 on unref.");
e = s_error_new (S_ERROR_INPUT_OUTPUT, "Generic I/O Error...");
s = s_object_to_string (S_OBJECT(e));
s_print ("%s\n", s);
free (s);
s_object_unref (S_OBJECT(e));
e = s_error_new (S_ERROR_OVERFLOW, "A Generic overflow error...");
s = s_object_to_string (S_OBJECT(e));
s_print ("%s\n", s);
free (s);
s_object_unref (S_OBJECT(e));
e = s_error_new (S_ERROR_OTHER, "Some unknowned error type...");
s = s_object_to_string (S_OBJECT(e));
s_print ("%s\n", s);
free (s);
s_object_unref (S_OBJECT(e));
e = s_error_new (S_ERROR_NULL, "A NULL error...");
s = s_object_to_string (S_OBJECT(e));
s_print ("%s\n", s);
free (s);
s_object_unref (S_OBJECT(e));
end_unit ();
}
|