comparison tests/test-save-quest.c @ 410:1bf7d6669f0a

tests: switch to libdt
author David Demelier <markand@malikania.fr>
date Fri, 09 Sep 2022 13:30:34 +0200
parents 0ea90751a62d
children 8f59201dc76b
comparison
equal deleted inserted replaced
409:6011ad866e99 410:1bf7d6669f0a
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */ 17 */
18 18
19 #include <stdio.h> 19 #include <stdio.h>
20 20
21 #include <core/util.h>
22
21 #include <rpg/quest.h> 23 #include <rpg/quest.h>
22 #include <rpg/save.h> 24 #include <rpg/save.h>
23 25
24 #include "test.h" 26 #include <dt.h>
25 27
26 RX_SET_UP(basics_set_up) 28 static void
27 { 29 test_basics_load(struct save *save)
28 if (save_open_path(RX_DATA, "quest.db", SAVE_MODE_WRITE) < 0)
29 return RX_ERROR;
30
31 return RX_SUCCESS;
32 }
33
34 RX_TEAR_DOWN(basics_tear_down)
35 {
36 save_finish(RX_DATA);
37 remove("quest.db");
38 }
39
40 RX_TEST_CASE(basics, load)
41 { 30 {
42 struct quest_step steps[] = { 31 struct quest_step steps[] = {
43 { 32 {
44 .name = "0001.01-kill-ten-moko", 33 .name = "0001.01-kill-ten-moko",
45 .description = "Kill 10 mokos de las llanuras.", 34 .description = "Kill 10 mokos de las llanuras.",
55 .name = "0001-getting-started", 44 .name = "0001-getting-started",
56 .description = "Initial quest for adventurer.", 45 .description = "Initial quest for adventurer.",
57 .steps = steps, 46 .steps = steps,
58 .stepsz = UTIL_SIZE(steps) 47 .stepsz = UTIL_SIZE(steps)
59 }; 48 };
60 struct save *save = RX_DATA;
61 49
62 RX_INT_REQUIRE_EQUAL(quest_save(&quest, save), 0); 50 DT_EQ_INT(quest_save(&quest, save), 0);
63 51
64 /* Reset to inspect. */ 52 /* Reset to inspect. */
65 steps[0].percent = steps[1].percent = 0; 53 steps[0].percent = steps[1].percent = 0;
66 RX_INT_REQUIRE_EQUAL(quest_load(&quest, save), 0); 54 DT_EQ_INT(quest_load(&quest, save), 0);
67 RX_INT_REQUIRE_EQUAL(steps[0].percent, 100); 55 DT_EQ_INT(steps[0].percent, 100);
68 RX_INT_REQUIRE_EQUAL(steps[1].percent, 50); 56 DT_EQ_INT(steps[1].percent, 50);
69 } 57 }
70 58
71 static const struct rx_test_case tests[] = { 59 int
72 TEST_FIXTURE(basics, load, struct save) 60 main(void)
73 }; 61 {
62 struct save save;
74 63
75 int 64 if (save_open_path(&save, "quest.db", SAVE_MODE_WRITE) < 0)
76 main(int argc, char **argv) 65 return 1;
77 { 66
78 return TEST_RUN_ALL(tests, argc, argv); 67 DT_RUN(test_basics_load, &save);
68 DT_SUMMARY();
69
70 save_finish(&save);
71 remove("quest.db");
79 } 72 }