/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk

« back to all changes in this revision

Viewing changes to tests/refcount.c

  • Committer: Gustav Hartvigsson
  • Date: 2015-04-07 19:55:55 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20150407195555-i1x12gy9rsks60a9
* Finnished test suite

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include "SimpleTypeSystem.h"
2
 
#include "../test_macros.h"
3
 
 
4
 
 
5
 
int main (char ** argc, int argv) {
6
 
  
7
 
  int retval = 0;
 
2
#include "test_macros.h"
 
3
 
 
4
 
 
5
int test_refcount (void) {
 
6
  setup_unit();
8
7
  
9
8
  SObject * obj = s_object_new ();
10
9
  
11
 
  test_case (s_object_get_refcount (obj) == 1, "Start refcount == 1", retval);
 
10
  test_case (s_object_get_refcount (obj) == 1, "Start refcount == 1");
12
11
  
13
12
  s_object_ref (obj);
14
13
  
15
 
  test_case (s_object_get_refcount (obj) == 2, "Manual get of refcount. == 2", retval);
 
14
  test_case (s_object_get_refcount (obj) == 2, "Manual get of refcount. == 2");
16
15
  
17
 
  test_case (s_object_ref (obj) == 3, "Get refcount from ref function. == 3", retval);
 
16
  test_case (s_object_ref (obj) == 3, "Get refcount from ref function. == 3");
18
17
  
19
18
  s_print ("running ref 10 000 times on object\n");
20
19
  for (size_t i = 0; i < 10000; i++) {
25
24
    s_object_unref (obj);
26
25
  }
27
26
  
28
 
  test_case (s_object_get_refcount (obj) == 3, "refcount == 3", retval);
 
27
  test_case (s_object_get_refcount (obj) == 3, "refcount == 3");
29
28
  
30
 
  test_case (s_object_unref (obj) == 2, "Get refcount from unref function. == 2", retval);
 
29
  test_case (s_object_unref (obj) == 2, "Get refcount from unref function. == 2");
31
30
  
32
31
  s_print ("Skipping unref test.\n");
33
32
  s_object_unref (obj);
34
33
  
35
 
  test_case (s_object_unref (obj) == 0, "refcount == 0", retval);
 
34
  test_case (s_object_unref (obj) == 0, "refcount == 0");
36
35
  
37
 
  return 0;
 
36
  end_unit();
38
37
}