Fri, 08 Oct 2021 18:58:49 +0200
move dereference operation into macro
425
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved. |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | */ |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | #include "cx/tree.h" |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
30 | #include "test_config.h" |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
31 | |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
32 | #include <stddef.h> |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
33 | |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
34 | typedef struct TestNode TestNode; |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
35 | |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
36 | struct TestNode { |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
37 | TestNode *parent; |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
38 | TestNode *prev; |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
39 | TestNode *next; |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
40 | |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
41 | TestNode *children_begin; |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
42 | TestNode *children_end; |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
43 | }; |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
44 | |
455 | 45 | void test_tree_add_sibling(void) { |
425
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
46 | // prepare test tree |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
47 | TestNode root; |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
48 | memset(&root, 0, sizeof(TestNode)); |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
49 | |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
50 | TestNode a; |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
51 | memset(&a, 0, sizeof(TestNode)); |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
52 | root.children_begin = &a; |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
53 | root.children_end = &a; |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
54 | a.parent = &root; |
449 | 55 | |
425
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
56 | // new test nodes |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
57 | TestNode b; |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
58 | memset(&b, 0, sizeof(TestNode)); |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
59 | TestNode c; |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
60 | memset(&c, 0, sizeof(TestNode)); |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
61 | |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
62 | // test |
453
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
63 | cx_tree_add_sibling(&a, offsetof(TestNode, prev), offsetof(TestNode, next), offsetof(TestNode, parent), &b); |
449 | 64 | CU_ASSERT_PTR_EQUAL(b.parent, &root) |
65 | CU_ASSERT_PTR_EQUAL(b.prev, &a) | |
66 | CU_ASSERT_PTR_NULL(b.next) | |
67 | CU_ASSERT_PTR_EQUAL(a.next, &b) | |
453
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
68 | |
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
69 | cx_tree_add_sibling(&a, -1, offsetof(TestNode, next), -1, &c); |
449 | 70 | CU_ASSERT_PTR_NULL(c.parent) |
71 | CU_ASSERT_PTR_NULL(c.prev) | |
72 | CU_ASSERT_PTR_NULL(c.next) | |
73 | CU_ASSERT_PTR_EQUAL(b.next, &c) | |
425
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
74 | } |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
75 | |
455 | 76 | void test_tree_add_child(void) { |
430
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
77 | // prepare test tree |
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
78 | TestNode root; |
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
79 | memset(&root, 0, sizeof(TestNode)); |
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
80 | |
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
81 | TestNode a; |
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
82 | memset(&a, 0, sizeof(TestNode)); |
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
83 | TestNode b; |
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
84 | memset(&b, 0, sizeof(TestNode)); |
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
85 | TestNode c; |
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
86 | memset(&c, 0, sizeof(TestNode)); |
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
87 | TestNode a1; |
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
88 | memset(&a1, 0, sizeof(TestNode)); |
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
89 | |
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
90 | // test |
453
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
91 | cx_tree_add_child( |
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
92 | (void **) &root.children_begin, |
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
93 | (void **) &root.children_end, |
430
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
94 | offsetof(TestNode, prev), |
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
95 | offsetof(TestNode, next), |
453
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
96 | &a, |
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
97 | offsetof(TestNode, parent), |
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
98 | &root); |
449 | 99 | CU_ASSERT_PTR_EQUAL(root.children_begin, &a) |
100 | CU_ASSERT_PTR_EQUAL(root.children_end, &a) | |
101 | CU_ASSERT_PTR_EQUAL(a.parent, &root) | |
102 | CU_ASSERT_PTR_NULL(a.prev) | |
103 | CU_ASSERT_PTR_NULL(a.next) | |
104 | ||
453
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
105 | cx_tree_add_child( |
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
106 | (void **) &root.children_begin, |
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
107 | (void **) &root.children_end, |
430
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
108 | offsetof(TestNode, prev), |
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
109 | offsetof(TestNode, next), |
453
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
110 | &b, |
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
111 | offsetof(TestNode, parent), |
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
112 | &root); |
449 | 113 | CU_ASSERT_PTR_NOT_NULL(root.children_begin) |
114 | CU_ASSERT_PTR_EQUAL(root.children_begin->next, &b) | |
115 | CU_ASSERT_PTR_EQUAL(root.children_end, &b) | |
116 | CU_ASSERT_PTR_EQUAL(b.parent, &root) | |
117 | CU_ASSERT_PTR_EQUAL(b.prev, &a) | |
453
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
118 | |
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
119 | cx_tree_add_child( |
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
120 | (void **) &root.children_begin, |
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
121 | NULL, |
430
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
122 | -1, |
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
123 | offsetof(TestNode, next), |
453
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
124 | &c, |
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
125 | -1, |
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
126 | &root); |
449 | 127 | CU_ASSERT_PTR_EQUAL(root.children_end, &b) // children_end unchanged |
128 | CU_ASSERT_PTR_EQUAL(b.next, &c) | |
129 | CU_ASSERT_PTR_NULL(c.prev) | |
130 | CU_ASSERT_PTR_NULL(c.next) | |
131 | CU_ASSERT_PTR_NULL(c.parent) | |
453
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
132 | |
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
133 | cx_tree_add_child( |
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
134 | (void **) &a.children_begin, |
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
135 | (void **) &a.children_end, |
430
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
136 | offsetof(TestNode, prev), |
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
137 | offsetof(TestNode, next), |
453
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
138 | &a1, |
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
139 | offsetof(TestNode, parent), |
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
140 | &a); |
430
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
141 | CU_ASSERT_PTR_EQUAL(a.children_begin, &a1); |
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
142 | CU_ASSERT_PTR_EQUAL(a1.parent, &a); |
449 | 143 | CU_ASSERT_PTR_NOT_NULL(root.children_begin) |
144 | CU_ASSERT_PTR_EQUAL(root.children_begin->children_begin, &a1) | |
430
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
145 | } |
d4d643def2ac
add cx_tree_add_child_node tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
425
diff
changeset
|
146 | |
425
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
147 | int main() { |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
148 | CU_pSuite suite = NULL; |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
149 | |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
150 | if (CUE_SUCCESS != CU_initialize_registry()) { |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
151 | return CU_get_error(); |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
152 | } |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
153 | |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
154 | suite = CU_add_suite("tree suite", NULL, NULL); |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
155 | |
455 | 156 | cu_add_test(suite, test_tree_add_sibling); |
157 | cu_add_test(suite, test_tree_add_child); | |
158 | ||
425
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
159 | CU_basic_set_mode(UCX_CU_BRM); |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
160 | |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
161 | int exitcode; |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
162 | if (CU_basic_run_tests()) { |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
163 | exitcode = CU_get_error(); |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
164 | } else { |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
165 | exitcode = CU_get_number_of_failures() == 0 ? 0 : 1; |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
166 | } |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
167 | CU_cleanup_registry(); |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
168 | return exitcode; |
a75b808d653b
add cx_tree_add_node test
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
169 | } |