Line |
Branch |
Exec |
Source |
1 |
|
|
/* |
2 |
|
|
* Filename: /workspaces/our_rpg/tests/library/ECS/world_system_tests.c |
3 |
|
|
* Path: /workspaces/our_rpg/tests/library/ECS |
4 |
|
|
* Created Date: Sunday, January 15th 2023, 3:59:16 pm |
5 |
|
|
* Author: osvegn |
6 |
|
|
* |
7 |
|
|
* Copyright (c) 2023 our_rpg |
8 |
|
|
*/ |
9 |
|
|
|
10 |
|
|
#include <criterion/criterion.h> |
11 |
|
|
#include "world.h" |
12 |
|
|
#include "world_system.h" |
13 |
|
|
|
14 |
|
✗ |
Test(world_add_system, world_add_system) |
15 |
|
|
{ |
16 |
|
|
world_t world; |
17 |
|
|
system_t system; |
18 |
|
|
|
19 |
|
✗ |
system.type = 0; |
20 |
|
✗ |
vector_constructor(&world.system_list, sizeof(int), 0); |
21 |
|
✗ |
cr_assert_eq(world_add_system(&world, &system), 0); |
22 |
|
✗ |
cr_assert_eq(world.system_list.size(&world.system_list), 1); |
23 |
|
|
} |
24 |
|
|
|
25 |
|
✗ |
Test(world_add_system, world_add_system_failure) |
26 |
|
|
{ |
27 |
|
|
world_t world; |
28 |
|
|
system_t system; |
29 |
|
|
|
30 |
|
✗ |
system.type = 0; |
31 |
|
✗ |
vector_constructor(&world.system_list, sizeof(int), 0); |
32 |
|
✗ |
world_add_system(&world, &system); |
33 |
|
✗ |
cr_assert_eq(world_add_system(&world, &system), -1); |
34 |
|
✗ |
cr_assert_eq(world.system_list.size(&world.system_list), 1); |
35 |
|
|
} |
36 |
|
|
|
37 |
|
✗ |
Test(world_add_system, world_add_system_success_with_two_elements) |
38 |
|
|
{ |
39 |
|
|
world_t world; |
40 |
|
|
system_t system; |
41 |
|
|
|
42 |
|
✗ |
system.type = 0; |
43 |
|
✗ |
vector_constructor(&world.system_list, sizeof(int), 0); |
44 |
|
✗ |
world_add_system(&world, &system); |
45 |
|
✗ |
system.type = 1; |
46 |
|
✗ |
cr_assert_eq(world_add_system(&world, &system), 0); |
47 |
|
✗ |
cr_assert_eq(world.system_list.size(&world.system_list), 2); |
48 |
|
|
} |
49 |
|
|
|
50 |
|
✗ |
Test(world_remove_system, world_remove_system) |
51 |
|
|
{ |
52 |
|
|
world_t world; |
53 |
|
|
system_t system; |
54 |
|
|
|
55 |
|
✗ |
system.type = 0; |
56 |
|
✗ |
vector_constructor(&world.system_list, sizeof(int), 0); |
57 |
|
✗ |
world_add_system(&world, &system); |
58 |
|
✗ |
system.type = 1; |
59 |
|
✗ |
world_add_system(&world, &system); |
60 |
|
✗ |
cr_assert_eq(world_remove_system(&world, &system), 0); |
61 |
|
✗ |
cr_assert_eq(world.system_list.size(&world.system_list), 1); |
62 |
|
|
} |
63 |
|
|
|
64 |
|
✗ |
Test(world_remove_system, world_remove_system_failure) |
65 |
|
|
{ |
66 |
|
|
world_t world; |
67 |
|
|
system_t system; |
68 |
|
|
|
69 |
|
✗ |
system.type = 0; |
70 |
|
✗ |
vector_constructor(&world.system_list, sizeof(int), 0); |
71 |
|
✗ |
world_add_system(&world, &system); |
72 |
|
✗ |
system.type = 1; |
73 |
|
✗ |
world_add_system(&world, &system); |
74 |
|
✗ |
world_remove_system(&world, &system); |
75 |
|
✗ |
cr_assert_eq(world_remove_system(&world, &system), -1); |
76 |
|
✗ |
cr_assert_eq(world.system_list.size(&world.system_list), 1); |
77 |
|
|
} |
78 |
|
|
|
79 |
|
✗ |
Test(world_remove_system, world_remove_system_by_type) |
80 |
|
|
{ |
81 |
|
|
world_t world; |
82 |
|
|
system_t system; |
83 |
|
|
|
84 |
|
✗ |
system.type = 0; |
85 |
|
✗ |
vector_constructor(&world.system_list, sizeof(int), 0); |
86 |
|
✗ |
world_add_system(&world, &system); |
87 |
|
✗ |
system.type = 1; |
88 |
|
✗ |
world_add_system(&world, &system); |
89 |
|
✗ |
cr_assert_eq(world_remove_system_by_type(&world, 0), 0); |
90 |
|
✗ |
cr_assert_eq(world.system_list.size(&world.system_list), 1); |
91 |
|
|
} |
92 |
|
|
|
93 |
|
✗ |
Test(world_remove_system, world_remove_system_by_type_failure) |
94 |
|
|
{ |
95 |
|
|
world_t world; |
96 |
|
|
system_t system; |
97 |
|
|
|
98 |
|
✗ |
system.type = 0; |
99 |
|
✗ |
vector_constructor(&world.system_list, sizeof(int), 0); |
100 |
|
✗ |
world_add_system(&world, &system); |
101 |
|
✗ |
system.type = 1; |
102 |
|
✗ |
world_add_system(&world, &system); |
103 |
|
✗ |
world_remove_system_by_type(&world, 0); |
104 |
|
✗ |
cr_assert_eq(world_remove_system_by_type(&world, 0), -1); |
105 |
|
✗ |
cr_assert_eq(world.system_list.size(&world.system_list), 1); |
106 |
|
|
} |
107 |
|
|
|
108 |
|
✗ |
Test(world_contains_system, world_contains_system_success) |
109 |
|
|
{ |
110 |
|
|
world_t world; |
111 |
|
|
system_t system; |
112 |
|
|
|
113 |
|
✗ |
system.type = 0; |
114 |
|
✗ |
world_constructor(&world, stdout); |
115 |
|
✗ |
world_add_system(&world, &system); |
116 |
|
✗ |
cr_assert_eq(world_contains_system(&world, &system), true); |
117 |
|
|
} |
118 |
|
|
|
119 |
|
✗ |
Test(world_contains_system, world_contains_system_failure) |
120 |
|
|
{ |
121 |
|
|
world_t world; |
122 |
|
|
system_t system; |
123 |
|
|
|
124 |
|
✗ |
system.type = 0; |
125 |
|
✗ |
world_constructor(&world, stdout); |
126 |
|
✗ |
cr_assert_eq(world_contains_system(&world, &system), false); |
127 |
|
|
} |
128 |
|
|
|
129 |
|
✗ |
Test(world_contains_system, world_contains_system_by_type_success) |
130 |
|
|
{ |
131 |
|
|
world_t world; |
132 |
|
|
system_t system; |
133 |
|
|
|
134 |
|
✗ |
system.type = 0; |
135 |
|
✗ |
world_constructor(&world, stdout); |
136 |
|
✗ |
world_add_system(&world, &system); |
137 |
|
✗ |
cr_assert_eq(world_contains_system_by_type(&world, 0), true); |
138 |
|
|
} |
139 |
|
|
|
140 |
|
✗ |
Test(world_contains_system, world_contains_system_by_type_failure) |
141 |
|
|
{ |
142 |
|
|
world_t world; |
143 |
|
|
system_t system; |
144 |
|
|
|
145 |
|
✗ |
system.type = 0; |
146 |
|
✗ |
world_constructor(&world, stdout); |
147 |
|
✗ |
world_add_system(&world, &system); |
148 |
|
✗ |
cr_assert_eq(world_contains_system_by_type(&world, 1), false); |
149 |
|
|
} |
150 |
|
|
|
151 |
|
✗ |
Test(wolrd_get_system, world_get_system_success) |
152 |
|
|
{ |
153 |
|
|
world_t world; |
154 |
|
|
system_t system; |
155 |
|
|
|
156 |
|
✗ |
system.type = 0; |
157 |
|
✗ |
world_constructor(&world, stdout); |
158 |
|
✗ |
world_add_system(&world, &system); |
159 |
|
✗ |
cr_assert_neq(world_get_system(&world, &system), 0); |
160 |
|
|
} |
161 |
|
|
|
162 |
|
✗ |
Test(wolrd_get_system, world_get_system_failure) |
163 |
|
|
{ |
164 |
|
|
world_t world; |
165 |
|
|
system_t system; |
166 |
|
|
|
167 |
|
✗ |
system.type = 0; |
168 |
|
✗ |
world_constructor(&world, stdout); |
169 |
|
✗ |
world_add_system(&world, &system); |
170 |
|
✗ |
system.type = 1; |
171 |
|
✗ |
cr_assert_eq(world_get_system(&world, &system), 0); |
172 |
|
|
} |
173 |
|
|
|
174 |
|
✗ |
Test(wolrd_get_system, world_get_system_by_type_success) |
175 |
|
|
{ |
176 |
|
|
world_t world; |
177 |
|
|
system_t system; |
178 |
|
|
|
179 |
|
✗ |
system.type = 0; |
180 |
|
✗ |
world_constructor(&world, stdout); |
181 |
|
✗ |
world_add_system(&world, &system); |
182 |
|
✗ |
cr_assert_neq(world_get_system_by_type(&world, 0), 0); |
183 |
|
|
} |
184 |
|
|
|
185 |
|
✗ |
Test(wolrd_get_system, world_get_system_by_type_failure) |
186 |
|
|
{ |
187 |
|
|
world_t world; |
188 |
|
|
system_t system; |
189 |
|
|
|
190 |
|
✗ |
system.type = 0; |
191 |
|
✗ |
world_constructor(&world, stdout); |
192 |
|
✗ |
world_add_system(&world, &system); |
193 |
|
✗ |
cr_assert_eq(world_get_system_by_type(&world, 1), 0); |
194 |
|
|
} |
195 |
|
|
|