Mercurial > molko
changeset 458:02c1481b7dbb
tests: fix
author | David Demelier <markand@malikania.fr> |
---|---|
date | Fri, 24 Feb 2023 22:14:42 +0100 |
parents | 04797b35565c |
children | 541cb950997b |
files | tests/test-action-script.c tests/test-action.c tests/test-drawable.c tests/test-state.c |
diffstat | 4 files changed, 80 insertions(+), 80 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test-action-script.c Sat Feb 18 21:07:02 2023 +0100 +++ b/tests/test-action-script.c Fri Feb 24 22:14:42 2023 +0100 @@ -40,7 +40,7 @@ } static void -my_handle(struct mlk_action *act, const union event *ev) +my_handle(struct mlk_action *act, const union mlk_event *ev) { (void)ev; @@ -142,7 +142,7 @@ DT_ASSERT(script_append(&sc, &table[2].act) == 0); /* [0] */ - script_handle(&sc, &(union event){0}); + script_handle(&sc, &(union mlk_event){0}); DT_EQ_INT(table[0].inv.handle, 1); DT_EQ_INT(table[0].inv.update, 0); DT_EQ_INT(table[0].inv.draw, 0); @@ -161,7 +161,7 @@ /* [0] -> [1] */ DT_ASSERT(!script_update(&sc, 0)); - script_handle(&sc, &(union event){0}); + script_handle(&sc, &(union mlk_event){0}); DT_EQ_INT(table[0].inv.handle, 1); DT_EQ_INT(table[0].inv.update, 1); @@ -181,7 +181,7 @@ /* [2] */ DT_ASSERT(!script_update(&sc, 0)); - script_handle(&sc, &(union event){0}); + script_handle(&sc, &(union mlk_event){0}); DT_EQ_INT(table[0].inv.handle, 1); DT_EQ_INT(table[0].inv.update, 1); @@ -434,7 +434,7 @@ script_action(&sc, &act); /* Draw and input before updating. */ - mlk_action_handle(&act, &(union event){0}); + mlk_action_handle(&act, &(union mlk_event){0}); mlk_action_draw(&act); /* [0] -> [1] */ @@ -455,7 +455,7 @@ DT_EQ_INT(table[2].inv.end, 0); DT_EQ_INT(table[2].inv.finish, 0); - mlk_action_handle(&act, &(union event){0}); + mlk_action_handle(&act, &(union mlk_event){0}); mlk_action_draw(&act); /* [1] -> [2] */ @@ -476,7 +476,7 @@ DT_EQ_INT(table[2].inv.end, 0); DT_EQ_INT(table[2].inv.finish, 0); - mlk_action_handle(&act, &(union event){0}); + mlk_action_handle(&act, &(union mlk_event){0}); mlk_action_draw(&act); /* 2 stays, it never ends. */
--- a/tests/test-action.c Sat Feb 18 21:07:02 2023 +0100 +++ b/tests/test-action.c Fri Feb 24 22:14:42 2023 +0100 @@ -31,7 +31,7 @@ int finish; }; -static union event dummy; +static union mlk_event dummy; #define INIT(dat, up) { \ .data = (dat), \ @@ -43,7 +43,7 @@ } static void -my_handle(struct mlk_action *act, const union event *ev) +my_handle(struct mlk_action *act, const union mlk_event *ev) { (void)ev;
--- a/tests/test-drawable.c Sat Feb 18 21:07:02 2023 +0100 +++ b/tests/test-drawable.c Fri Feb 24 22:14:42 2023 +0100 @@ -39,7 +39,7 @@ } static int -my_update_false(struct drawable *dw, unsigned int ticks) +my_update_false(struct mlk_drawable *dw, unsigned int ticks) { (void)ticks; @@ -49,7 +49,7 @@ } static int -my_update_true(struct drawable *dw, unsigned int ticks) +my_update_true(struct mlk_drawable *dw, unsigned int ticks) { (void)ticks; @@ -59,19 +59,19 @@ } static void -my_draw(struct drawable *dw) +my_draw(struct mlk_drawable *dw) { ((struct invokes *)dw->data)->draw = 1; } static void -my_end(struct drawable *dw) +my_end(struct mlk_drawable *dw) { ((struct invokes *)dw->data)->end = 1; } static void -my_finish(struct drawable *dw) +my_finish(struct mlk_drawable *dw) { ((struct invokes *)dw->data)->finish = 1; } @@ -81,21 +81,21 @@ { struct { struct invokes inv; - struct drawable dw; + struct mlk_drawable dw; } table[] = { { .dw = INIT(&table[0], my_update_true) }, { .dw = INIT(&table[1], my_update_false) } }; /* True version. */ - DT_ASSERT(drawable_update(&table[0].dw, 0)); + DT_ASSERT(mlk_drawable_update(&table[0].dw, 0)); DT_ASSERT(table[0].inv.update); DT_ASSERT(!table[0].inv.draw); DT_ASSERT(!table[0].inv.end); DT_ASSERT(!table[0].inv.finish); /* False version. */ - DT_ASSERT(!drawable_update(&table[1].dw, 0)); + DT_ASSERT(!mlk_drawable_update(&table[1].dw, 0)); DT_ASSERT(table[1].inv.update); DT_ASSERT(!table[1].inv.draw); DT_ASSERT(!table[1].inv.end); @@ -106,9 +106,9 @@ test_basics_draw(void) { struct invokes inv = {0}; - struct drawable dw = INIT(&inv, my_update_true); + struct mlk_drawable dw = INIT(&inv, my_update_true); - drawable_draw(&dw); + mlk_drawable_draw(&dw); DT_ASSERT(!inv.update); DT_ASSERT(inv.draw); @@ -120,9 +120,9 @@ test_basics_end(void) { struct invokes inv = {0}; - struct drawable dw = INIT(&inv, my_update_true); + struct mlk_drawable dw = INIT(&inv, my_update_true); - drawable_end(&dw); + mlk_drawable_end(&dw); DT_ASSERT(!inv.update); DT_ASSERT(!inv.draw); @@ -134,9 +134,9 @@ test_basics_finish(void) { struct invokes inv = {0}; - struct drawable dw = INIT(&inv, my_update_true); + struct mlk_drawable dw = INIT(&inv, my_update_true); - drawable_finish(&dw); + mlk_drawable_finish(&dw); DT_ASSERT(!inv.update); DT_ASSERT(!inv.draw); @@ -147,20 +147,20 @@ static void test_stack_add(void) { - struct drawable *drawables[10]; - struct drawable_stack st = {0}; - struct drawable dw = {0}; + struct mlk_drawable *drawables[10]; + struct mlk_drawable_stack st = {0}; + struct mlk_drawable dw = {0}; - drawable_stack_init(&st, drawables, 10); + mlk_drawable_stack_init(&st, drawables, 10); - DT_EQ_INT(drawable_stack_add(&st, &dw), 0); + DT_EQ_INT(mlk_drawable_stack_add(&st, &dw), 0); /* Now fill up. */ for (int i = 0; i < 9; ++i) - DT_EQ_INT(drawable_stack_add(&st, &dw), 0); + DT_EQ_INT(mlk_drawable_stack_add(&st, &dw), 0); /* This one should not fit in. */ - DT_EQ_INT(drawable_stack_add(&st, &dw), MLK_ERR_NO_MEM); + DT_EQ_INT(mlk_drawable_stack_add(&st, &dw), MLK_ERR_NO_MEM); } static void @@ -168,7 +168,7 @@ { struct { struct invokes inv; - struct drawable dw; + struct mlk_drawable dw; } table[] = { { .dw = INIT(&table[0], my_update_false) }, { .dw = INIT(&table[1], my_update_true) }, @@ -179,19 +179,19 @@ { .dw = INIT(&table[6], my_update_false) }, }; - struct drawable *drawables[10]; - struct drawable_stack st = {0}; + struct mlk_drawable *drawables[10]; + struct mlk_drawable_stack st = {0}; - drawable_stack_init(&st, drawables, 10); - drawable_stack_add(&st, &table[0].dw); - drawable_stack_add(&st, &table[1].dw); - drawable_stack_add(&st, &table[2].dw); - drawable_stack_add(&st, &table[3].dw); - drawable_stack_add(&st, &table[4].dw); - drawable_stack_add(&st, &table[5].dw); - drawable_stack_add(&st, &table[6].dw); + mlk_drawable_stack_init(&st, drawables, 10); + mlk_drawable_stack_add(&st, &table[0].dw); + mlk_drawable_stack_add(&st, &table[1].dw); + mlk_drawable_stack_add(&st, &table[2].dw); + mlk_drawable_stack_add(&st, &table[3].dw); + mlk_drawable_stack_add(&st, &table[4].dw); + mlk_drawable_stack_add(&st, &table[5].dw); + mlk_drawable_stack_add(&st, &table[6].dw); - DT_ASSERT(!drawable_stack_update(&st, 0)); + DT_ASSERT(!mlk_drawable_stack_update(&st, 0)); DT_ASSERT(table[0].inv.update); DT_ASSERT(table[1].inv.update); @@ -244,7 +244,7 @@ table[3].dw.update = table[6].dw.update = my_update_true; - DT_ASSERT(drawable_stack_update(&st, 0)); + DT_ASSERT(mlk_drawable_stack_update(&st, 0)); DT_EQ_PTR(st.objects[0], NULL); DT_EQ_PTR(st.objects[1], NULL); DT_EQ_PTR(st.objects[2], NULL); @@ -259,7 +259,7 @@ { struct { struct invokes inv; - struct drawable dw; + struct mlk_drawable dw; } table[] = { { .dw = INIT(&table[0], my_update_false) }, { .dw = INIT(&table[1], my_update_true) }, @@ -270,18 +270,18 @@ { .dw = INIT(&table[6], my_update_false) }, }; - struct drawable *drawables[10]; - struct drawable_stack st = {0}; + struct mlk_drawable *drawables[10]; + struct mlk_drawable_stack st = {0}; - drawable_stack_init(&st, drawables, 10); - drawable_stack_add(&st, &table[0].dw); - drawable_stack_add(&st, &table[1].dw); - drawable_stack_add(&st, &table[2].dw); - drawable_stack_add(&st, &table[3].dw); - drawable_stack_add(&st, &table[4].dw); - drawable_stack_add(&st, &table[5].dw); - drawable_stack_add(&st, &table[6].dw); - drawable_stack_draw(&st); + mlk_drawable_stack_init(&st, drawables, 10); + mlk_drawable_stack_add(&st, &table[0].dw); + mlk_drawable_stack_add(&st, &table[1].dw); + mlk_drawable_stack_add(&st, &table[2].dw); + mlk_drawable_stack_add(&st, &table[3].dw); + mlk_drawable_stack_add(&st, &table[4].dw); + mlk_drawable_stack_add(&st, &table[5].dw); + mlk_drawable_stack_add(&st, &table[6].dw); + mlk_drawable_stack_draw(&st); DT_ASSERT(!table[0].inv.update); DT_ASSERT(!table[1].inv.update); @@ -321,19 +321,19 @@ { struct { struct invokes inv; - struct drawable dw; + struct mlk_drawable dw; } table[] = { { .dw = INIT(&table[0], my_update_true) }, { .dw = INIT(&table[0], my_update_false) }, }; - struct drawable *drawables[10]; - struct drawable_stack st = {0}; + struct mlk_drawable *drawables[10]; + struct mlk_drawable_stack st = {0}; - drawable_stack_init(&st, drawables, 10); - drawable_stack_add(&st, &table[0].dw); - drawable_stack_add(&st, &table[1].dw); - drawable_stack_finish(&st); + mlk_drawable_stack_init(&st, drawables, 10); + mlk_drawable_stack_add(&st, &table[0].dw); + mlk_drawable_stack_add(&st, &table[1].dw); + mlk_drawable_stack_finish(&st); DT_ASSERT(!table[0].inv.update); DT_ASSERT(!table[0].inv.draw);
--- a/tests/test-state.c Sat Feb 18 21:07:02 2023 +0100 +++ b/tests/test-state.c Fri Feb 24 22:14:42 2023 +0100 @@ -45,7 +45,7 @@ } static void -my_handle(struct state *state, const union event *ev) +my_handle(struct state *state, const union mlk_event *ev) { (void)ev; @@ -123,7 +123,7 @@ struct invokes inv = {0}; struct state state = INIT(&inv); - state_handle(&state, &(const union event){0}); + state_handle(&state, &(const union mlk_event){0}); DT_EQ_UINT(inv.start, 0U); DT_EQ_UINT(inv.handle, 1U); DT_EQ_UINT(inv.update, 0U); @@ -204,8 +204,8 @@ }; /* 0 becomes active and should start. */ - game_init(mainstates, UTIL_SIZE(mainstates)); - game_push(&states[0].state); + mlk_game_init(mainstates, UTIL_SIZE(mainstates)); + mlk_game_push(&states[0].state); DT_EQ_UINT(states[0].inv.start, 1U); DT_EQ_UINT(states[0].inv.handle, 0U); @@ -217,12 +217,12 @@ DT_EQ_UINT(states[0].inv.finish, 0U); /* Put some event, update and drawing. */ - game_handle(&(union event) { .type = EVENT_QUIT }); - game_update(100); - game_update(100); - game_draw(); - game_draw(); - game_draw(); + mlk_game_handle(&(union mlk_event) { .type = MLK_EVENT_QUIT }); + mlk_game_update(100); + mlk_game_update(100); + mlk_game_draw(); + mlk_game_draw(); + mlk_game_draw(); DT_EQ_UINT(states[0].inv.start, 1U); DT_EQ_UINT(states[0].inv.handle, 1U); DT_EQ_UINT(states[0].inv.update, 2U); @@ -233,7 +233,7 @@ DT_EQ_UINT(states[0].inv.finish, 0U); /* Switch to state 1, 0 must be suspended. */ - game_push(&states[1].state); + mlk_game_push(&states[1].state); DT_EQ_UINT(states[0].inv.start, 1U); DT_EQ_UINT(states[0].inv.handle, 1U); DT_EQ_UINT(states[0].inv.update, 2U); @@ -253,10 +253,10 @@ DT_EQ_UINT(states[1].inv.finish, 0U); /* Update a little this state. */ - game_update(10); - game_update(10); - game_update(10); - game_update(10); + mlk_game_update(10); + mlk_game_update(10); + mlk_game_update(10); + mlk_game_update(10); DT_EQ_UINT(states[0].inv.start, 1U); DT_EQ_UINT(states[0].inv.handle, 1U); DT_EQ_UINT(states[0].inv.update, 2U); @@ -276,7 +276,7 @@ DT_EQ_UINT(states[1].inv.finish, 0U); /* Pop it, it should be finalized through end and finish. */ - game_pop(); + mlk_game_pop(); DT_EQ_UINT(states[0].inv.start, 1U); DT_EQ_UINT(states[0].inv.handle, 1U); @@ -297,7 +297,7 @@ DT_EQ_UINT(states[1].inv.finish, 1U); /* Pop this state as well. */ - game_pop(); + mlk_game_pop(); DT_EQ_UINT(states[0].inv.start, 1U); DT_EQ_UINT(states[0].inv.handle, 1U); @@ -317,7 +317,7 @@ DT_EQ_UINT(states[1].inv.end, 1U); DT_EQ_UINT(states[1].inv.finish, 1U); - game_quit(); + mlk_game_quit(); } int