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
|
#include "SimpleTypeSystem.h"
#include "../test_macros.h"
int main (char ** argc, int argv) {
int retval = 0;
SObject * obj = s_object_new ();
test_case (s_object_get_refcount (obj) == 1, "Start refcount == 1", retval);
s_object_ref (obj);
test_case (s_object_get_refcount (obj) == 2, "Manual get of refcount. == 2", retval);
test_case (s_object_ref (obj) == 3, "Get refcount from ref function. == 3", retval);
s_print ("running ref 10 000 times on object\n");
for (size_t i = 0; i < 10000; i++) {
s_object_ref (obj);
}
s_print ("running unref 10 000 times on object\n");
for (size_t i = 0; i < 10000; i++) {
s_object_unref (obj);
}
test_case (s_object_get_refcount (obj) == 3, "refcount == 3", retval);
test_case (s_object_unref (obj) == 2, "Get refcount from unref function. == 2", retval);
s_print ("Skipping unref test.\n");
s_object_unref (obj);
test_case (s_object_unref (obj) == 0, "refcount == 0", retval);
return 0;
}
|