comparison tests/test-action-script.c @ 298:196264679079

misc: remove usage of bool
author David Demelier <markand@malikania.fr>
date Wed, 10 Mar 2021 18:49:08 +0100
parents 30b68089ae70
children d01e83210ca2
comparison
equal deleted inserted replaced
297:6151152d009c 298:196264679079
46 (void)ev; 46 (void)ev;
47 47
48 ((struct invokes *)act->data)->handle++; 48 ((struct invokes *)act->data)->handle++;
49 } 49 }
50 50
51 static bool 51 static int
52 my_update_false(struct action *act, unsigned int ticks) 52 my_update_false(struct action *act, unsigned int ticks)
53 { 53 {
54 (void)ticks; 54 (void)ticks;
55 55
56 ((struct invokes *)act->data)->update++; 56 ((struct invokes *)act->data)->update++;
57 57
58 return false; 58 return 0;
59 } 59 }
60 60
61 static bool 61 static int
62 my_update_true(struct action *act, unsigned int ticks) 62 my_update_true(struct action *act, unsigned int ticks)
63 { 63 {
64 (void)ticks; 64 (void)ticks;
65 65
66 ((struct invokes *)act->data)->update++; 66 ((struct invokes *)act->data)->update++;
67 67
68 return true; 68 return 1;
69 } 69 }
70 70
71 static void 71 static void
72 my_draw(struct action *act) 72 my_draw(struct action *act)
73 { 73 {
103 basics_append(void) 103 basics_append(void)
104 { 104 {
105 struct action act[3] = {0}; 105 struct action act[3] = {0};
106 struct script sc = {0}; 106 struct script sc = {0};
107 107
108 GREATEST_ASSERT(script_append(&sc, &act[0])); 108 GREATEST_ASSERT(script_append(&sc, &act[0]) == 0);
109 GREATEST_ASSERT_EQ(sc.cur, 0U); 109 GREATEST_ASSERT_EQ(sc.cur, 0U);
110 GREATEST_ASSERT_EQ(sc.actionsz, 1U); 110 GREATEST_ASSERT_EQ(sc.actionsz, 1U);
111 GREATEST_ASSERT_EQ(sc.actions[0], &act[0]); 111 GREATEST_ASSERT_EQ(sc.actions[0], &act[0]);
112 112
113 GREATEST_ASSERT(script_append(&sc, &act[1])); 113 GREATEST_ASSERT(script_append(&sc, &act[1]) == 0);
114 GREATEST_ASSERT_EQ(sc.cur, 0U); 114 GREATEST_ASSERT_EQ(sc.cur, 0U);
115 GREATEST_ASSERT_EQ(sc.actionsz, 2U); 115 GREATEST_ASSERT_EQ(sc.actionsz, 2U);
116 GREATEST_ASSERT_EQ(sc.actions[0], &act[0]); 116 GREATEST_ASSERT_EQ(sc.actions[0], &act[0]);
117 GREATEST_ASSERT_EQ(sc.actions[1], &act[1]); 117 GREATEST_ASSERT_EQ(sc.actions[1], &act[1]);
118 118
119 GREATEST_ASSERT(script_append(&sc, &act[2])); 119 GREATEST_ASSERT(script_append(&sc, &act[2]) == 0);
120 GREATEST_ASSERT_EQ(sc.cur, 0U); 120 GREATEST_ASSERT_EQ(sc.cur, 0U);
121 GREATEST_ASSERT_EQ(sc.actionsz, 3U); 121 GREATEST_ASSERT_EQ(sc.actionsz, 3U);
122 GREATEST_ASSERT_EQ(sc.actions[0], &act[0]); 122 GREATEST_ASSERT_EQ(sc.actions[0], &act[0]);
123 GREATEST_ASSERT_EQ(sc.actions[1], &act[1]); 123 GREATEST_ASSERT_EQ(sc.actions[1], &act[1]);
124 GREATEST_ASSERT_EQ(sc.actions[2], &act[2]); 124 GREATEST_ASSERT_EQ(sc.actions[2], &act[2]);
140 { .act = INIT(&table[2].inv, my_update_false) } 140 { .act = INIT(&table[2].inv, my_update_false) }
141 }; 141 };
142 142
143 struct script sc = {0}; 143 struct script sc = {0};
144 144
145 GREATEST_ASSERT(script_append(&sc, &table[0].act)); 145 GREATEST_ASSERT(script_append(&sc, &table[0].act) == 0);
146 GREATEST_ASSERT(script_append(&sc, &table[1].act)); 146 GREATEST_ASSERT(script_append(&sc, &table[1].act) == 0);
147 GREATEST_ASSERT(script_append(&sc, &table[2].act)); 147 GREATEST_ASSERT(script_append(&sc, &table[2].act) == 0);
148 148
149 /* [0] */ 149 /* [0] */
150 script_handle(&sc, &(union event){0}); 150 script_handle(&sc, &(union event){0});
151 GREATEST_ASSERT_EQ(table[0].inv.handle, 1); 151 GREATEST_ASSERT_EQ(table[0].inv.handle, 1);
152 GREATEST_ASSERT_EQ(table[0].inv.update, 0); 152 GREATEST_ASSERT_EQ(table[0].inv.update, 0);
219 { .act = INIT(&table[2].inv, my_update_false) } 219 { .act = INIT(&table[2].inv, my_update_false) }
220 }; 220 };
221 221
222 struct script sc = {0}; 222 struct script sc = {0};
223 223
224 GREATEST_ASSERT(script_append(&sc, &table[0].act)); 224 GREATEST_ASSERT(script_append(&sc, &table[0].act) == 0);
225 GREATEST_ASSERT(script_append(&sc, &table[1].act)); 225 GREATEST_ASSERT(script_append(&sc, &table[1].act) == 0);
226 GREATEST_ASSERT(script_append(&sc, &table[2].act)); 226 GREATEST_ASSERT(script_append(&sc, &table[2].act) == 0);
227 227
228 /* 0 -> 1 */ 228 /* 0 -> 1 */
229 GREATEST_ASSERT(!script_update(&sc, 0)); 229 GREATEST_ASSERT(!script_update(&sc, 0));
230 GREATEST_ASSERT_EQ(table[0].inv.handle, 0); 230 GREATEST_ASSERT_EQ(table[0].inv.handle, 0);
231 GREATEST_ASSERT_EQ(table[0].inv.update, 1); 231 GREATEST_ASSERT_EQ(table[0].inv.update, 1);
315 { .act = INIT(&table[2].inv, my_update_false) } 315 { .act = INIT(&table[2].inv, my_update_false) }
316 }; 316 };
317 317
318 struct script sc = {0}; 318 struct script sc = {0};
319 319
320 GREATEST_ASSERT(script_append(&sc, &table[0].act)); 320 GREATEST_ASSERT(script_append(&sc, &table[0].act) == 0);
321 GREATEST_ASSERT(script_append(&sc, &table[1].act)); 321 GREATEST_ASSERT(script_append(&sc, &table[1].act) == 0);
322 GREATEST_ASSERT(script_append(&sc, &table[2].act)); 322 GREATEST_ASSERT(script_append(&sc, &table[2].act) == 0);
323 323
324 /* [0] */ 324 /* [0] */
325 script_draw(&sc); 325 script_draw(&sc);
326 GREATEST_ASSERT_EQ(table[0].inv.handle, 0); 326 GREATEST_ASSERT_EQ(table[0].inv.handle, 0);
327 GREATEST_ASSERT_EQ(table[0].inv.update, 0); 327 GREATEST_ASSERT_EQ(table[0].inv.update, 0);
394 { .act = INIT(&table[2].inv, my_update_false) } 394 { .act = INIT(&table[2].inv, my_update_false) }
395 }; 395 };
396 396
397 struct script sc = {0}; 397 struct script sc = {0};
398 398
399 GREATEST_ASSERT(script_append(&sc, &table[0].act)); 399 GREATEST_ASSERT(script_append(&sc, &table[0].act) == 0);
400 GREATEST_ASSERT(script_append(&sc, &table[1].act)); 400 GREATEST_ASSERT(script_append(&sc, &table[1].act) == 0);
401 GREATEST_ASSERT(script_append(&sc, &table[2].act)); 401 GREATEST_ASSERT(script_append(&sc, &table[2].act) == 0);
402 402
403 /* Update once so that the current action goes to 1. */ 403 /* Update once so that the current action goes to 1. */
404 GREATEST_ASSERT(!script_update(&sc, 0)); 404 GREATEST_ASSERT(!script_update(&sc, 0));
405 405
406 script_finish(&sc); 406 script_finish(&sc);
447 }; 447 };
448 448
449 struct script sc = {0}; 449 struct script sc = {0};
450 struct action act; 450 struct action act;
451 451
452 GREATEST_ASSERT(script_append(&sc, &table[0].act)); 452 GREATEST_ASSERT(script_append(&sc, &table[0].act) == 0);
453 GREATEST_ASSERT(script_append(&sc, &table[1].act)); 453 GREATEST_ASSERT(script_append(&sc, &table[1].act) == 0);
454 GREATEST_ASSERT(script_append(&sc, &table[2].act)); 454 GREATEST_ASSERT(script_append(&sc, &table[2].act) == 0);
455 455
456 /* Now convert this script into an action itself. */ 456 /* Now convert this script into an action itself. */
457 script_action(&sc, &act); 457 script_action(&sc, &act);
458 458
459 /* Draw and input before updating. */ 459 /* Draw and input before updating. */