/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
  
8
  SObject * obj = s_object_new ();
9
  
34 by Gustav Hartvigsson
* Finnished test suite
10
  test_case (s_object_get_refcount (obj) == 1, "Start refcount == 1");
33 by Gustav Hartvigsson
* made test_macros.h a lil' bit more portable
11
  
12
  s_object_ref (obj);
13
  
34 by Gustav Hartvigsson
* Finnished test suite
14
  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
15
  
34 by Gustav Hartvigsson
* Finnished test suite
16
  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
17
  
18
  s_print ("running ref 10 000 times on object\n");
19
  for (size_t i = 0; i < 10000; i++) {
20
    s_object_ref (obj);
21
  }
22
  s_print ("running unref 10 000 times on object\n");
23
  for (size_t i = 0; i < 10000; i++) {
24
    s_object_unref (obj);
25
  }
26
  
34 by Gustav Hartvigsson
* Finnished test suite
27
  test_case (s_object_get_refcount (obj) == 3, "refcount == 3");
33 by Gustav Hartvigsson
* made test_macros.h a lil' bit more portable
28
  
34 by Gustav Hartvigsson
* Finnished test suite
29
  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
30
  
31
  s_print ("Skipping unref test.\n");
32
  s_object_unref (obj);
33
  
34 by Gustav Hartvigsson
* Finnished test suite
34
  test_case (s_object_unref (obj) == 0, "refcount == 0");
32 by Gustav Hartvigsson
* Added some compile options to the root CMakeLists.txt
35
  
34 by Gustav Hartvigsson
* Finnished test suite
36
  end_unit();
4 by Gustav Hartvigsson
Fixed a few problems.
37
}