Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
update the double extern declaration bis
[simgrid.git] / src / swag_unit.c
1 /*******************************/
2 /* GENERATED FILE, DO NOT EDIT */
3 /*******************************/
4
5 #include "xbt.h"
6 /*******************************/
7 /* GENERATED FILE, DO NOT EDIT */
8 /*******************************/
9
10 # 236 "xbt/swag.c" 
11
12
13 typedef struct {
14   s_xbt_swag_hookup_t setA;
15   s_xbt_swag_hookup_t setB;
16   const char *name;
17 } shmurtz, s_shmurtz_t, *shmurtz_t;
18
19
20 XBT_TEST_UNIT("basic",test_swag_basic,"Basic usage") {
21   shmurtz_t obj1, obj2, obj;
22   xbt_swag_t setA,setB;
23
24   obj1 = calloc(1,sizeof(s_shmurtz_t));
25   obj2 = calloc(1,sizeof(s_shmurtz_t));
26
27   obj1->name="Obj 1";
28   obj2->name="Obj 2";
29
30   xbt_test_add0("Basic usage");
31   xbt_test_log3("%p %p %ld\n",obj1,&(obj1->setB),
32                 (long)((char *)&(obj1->setB) - (char *)obj1));
33
34   setA = xbt_swag_new(xbt_swag_offset(*obj1,setA));
35   setB = xbt_swag_new(xbt_swag_offset(*obj1,setB));
36
37   xbt_swag_insert(obj1, setA);
38   xbt_swag_insert(obj1, setB);
39   xbt_swag_insert(obj2, setA);
40   xbt_swag_insert(obj2, setB);
41
42   xbt_swag_remove(obj1, setB);
43   /*  xbt_swag_remove(obj2, setB);*/
44
45   xbt_test_add0("Traverse set A");
46   xbt_swag_foreach(obj,setA) {
47     xbt_test_log1("Saw: %s",obj->name);
48   }
49
50   xbt_test_add0("Traverse set B");
51   xbt_swag_foreach(obj,setB) {
52     xbt_test_log1("Saw: %s",obj->name);
53   }
54
55   xbt_test_add0("Ensure set content and length");
56   xbt_test_assert(  xbt_swag_belongs(obj1,setA));
57   xbt_test_assert(  xbt_swag_belongs(obj2,setA));
58
59   xbt_test_assert(! xbt_swag_belongs(obj1,setB));
60   xbt_test_assert(  xbt_swag_belongs(obj2,setB));
61
62   xbt_test_assert(xbt_swag_size(setA) == 2);
63   xbt_test_assert(xbt_swag_size(setB) == 1);
64    
65   xbt_swag_free(setA);
66   xbt_swag_free(setB);
67 }
68
69 /*******************************/
70 /* GENERATED FILE, DO NOT EDIT */
71 /*******************************/
72