/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk
4 by Gustav Hartvigsson
Fixed a few problems.
1
#include "SimpleTypeSystem.h"
34 by Gustav Hartvigsson
* Finnished test suite
2
#include "test_macros.h"
3
4
5
int test_refcount (void) {
6
  setup_unit();
32 by Gustav Hartvigsson
* Added some compile options to the root CMakeLists.txt
7
  
39 by Gustav Hartvigsson
* Added "check" target for testing.
8
  SObject * obj = NULL;
9
  
10
  obj = s_object_new ();
11
  
12
  test_case (obj != NULL, "Object is not NULL.");
32 by Gustav Hartvigsson
* Added some compile options to the root CMakeLists.txt
13
  
34 by Gustav Hartvigsson
* Finnished test suite
14
  test_case (s_object_get_refcount (obj) == 1, "Start refcount == 1");
33 by Gustav Hartvigsson
* made test_macros.h a lil' bit more portable
15
  
16
  s_object_ref (obj);
17
  
34 by Gustav Hartvigsson
* Finnished test suite
18
  test_case (s_object_get_refcount (obj) == 2, "Manual get of refcount. == 2");
33 by Gustav Hartvigsson
* made test_macros.h a lil' bit more portable
19
  
34 by Gustav Hartvigsson
* Finnished test suite
20
  test_case (s_object_ref (obj) == 3, "Get refcount from ref function. == 3");
33 by Gustav Hartvigsson
* made test_macros.h a lil' bit more portable
21
  
22
  s_print ("running ref 10 000 times on object\n");
23
  for (size_t i = 0; i < 10000; i++) {
24
    s_object_ref (obj);
25
  }
26
  s_print ("running unref 10 000 times on object\n");
27
  for (size_t i = 0; i < 10000; i++) {
28
    s_object_unref (obj);
29
  }
30
  
34 by Gustav Hartvigsson
* Finnished test suite
31
  test_case (s_object_get_refcount (obj) == 3, "refcount == 3");
33 by Gustav Hartvigsson
* made test_macros.h a lil' bit more portable
32
  
34 by Gustav Hartvigsson
* Finnished test suite
33
  test_case (s_object_unref (obj) == 2, "Get refcount from unref function. == 2");
33 by Gustav Hartvigsson
* made test_macros.h a lil' bit more portable
34
  
35
  s_print ("Skipping unref test.\n");
36
  s_object_unref (obj);
37
  
34 by Gustav Hartvigsson
* Finnished test suite
38
  test_case (s_object_unref (obj) == 0, "refcount == 0");
32 by Gustav Hartvigsson
* Added some compile options to the root CMakeLists.txt
39
  
34 by Gustav Hartvigsson
* Finnished test suite
40
  end_unit();
4 by Gustav Hartvigsson
Fixed a few problems.
41
}