From 217eac8cb389e3d279e74e9119d7c1ae03144e6f Mon Sep 17 00:00:00 2001 From: welcor <357770+welcor@users.noreply.github.com> Date: Sat, 18 May 2024 23:32:46 +0200 Subject: [PATCH] Renamed test files to match pattern from src Also, started setup for testing do_remove and introduced a bit of shorthand macros. --- src/test/test.act.item.c | 15 +++++++++++++++ src/test/test.act.item.h | 10 ++++++++++ src/test/{test_handler.c => test.handler.c} | 11 ++--------- src/test/{test_handler.h => test.handler.h} | 0 src/test/testrunner.c | 4 +++- src/test/testrunner.h | 9 ++++++++- 6 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 src/test/test.act.item.c create mode 100644 src/test/test.act.item.h rename src/test/{test_handler.c => test.handler.c} (84%) rename src/test/{test_handler.h => test.handler.h} (100%) diff --git a/src/test/test.act.item.c b/src/test/test.act.item.c new file mode 100644 index 0000000..92ac591 --- /dev/null +++ b/src/test/test.act.item.c @@ -0,0 +1,15 @@ +#include "test.act.item.h" + +UNIT_TEST(test_do_remove) { + + + + return MUNIT_OK; +} + +MunitTest act_item_c_tests[] = { + STD_TEST("/do_remove", test_do_remove), + + // end of array marker + { NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL } +}; \ No newline at end of file diff --git a/src/test/test.act.item.h b/src/test/test.act.item.h new file mode 100644 index 0000000..92eed39 --- /dev/null +++ b/src/test/test.act.item.h @@ -0,0 +1,10 @@ +#include "testrunner.h" + +#ifndef TEST_ACT_ITEM_H +#define TEST_ACT_ITEM_H + +extern MunitTest act_item_c_tests[]; + +UNIT_TEST(test_do_remove); + +#endif \ No newline at end of file diff --git a/src/test/test_handler.c b/src/test/test.handler.c similarity index 84% rename from src/test/test_handler.c rename to src/test/test.handler.c index 85f4815..f13cb34 100644 --- a/src/test/test_handler.c +++ b/src/test/test.handler.c @@ -1,4 +1,4 @@ -#include "test_handler.h" +#include "test.handler.h" static void run_single_get_number_test(const char* input_param, const char *name_result, int number_result); @@ -28,13 +28,6 @@ static void run_single_get_number_test(const char* input_param, const char *name /* Creating a test suite is pretty simple. First, you'll need an * array of tests: */ MunitTest handler_c_tests[] = { - { - (char*) "/get_number", - test_get_number, - NULL, // setup callback - NULL, // cleanup callback - MUNIT_TEST_OPTION_NONE, - NULL - }, + STD_TEST("/get_number", test_get_number), { NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL } }; diff --git a/src/test/test_handler.h b/src/test/test.handler.h similarity index 100% rename from src/test/test_handler.h rename to src/test/test.handler.h diff --git a/src/test/testrunner.c b/src/test/testrunner.c index ce07680..6049cc3 100644 --- a/src/test/testrunner.c +++ b/src/test/testrunner.c @@ -1,8 +1,10 @@ #include "testrunner.h" -#include "test_handler.h" +#include "test.handler.h" +#include "test.act.item.h" static MunitSuite suites[] = { { "/handler.c", handler_c_tests, NULL, 1, MUNIT_SUITE_OPTION_NONE }, + { "/act.item.c", act_item_c_tests, NULL, 1, MUNIT_SUITE_OPTION_NONE }, { NULL, NULL, NULL, 0, MUNIT_SUITE_OPTION_NONE } }; diff --git a/src/test/testrunner.h b/src/test/testrunner.h index 603a405..2969ad7 100644 --- a/src/test/testrunner.h +++ b/src/test/testrunner.h @@ -19,8 +19,15 @@ #include "../mud_event.h" #include "../munit/munit.h" - +/** + * Utility macro for defining tests. +*/ #define UNIT_TEST(test_name) MunitResult (test_name)(const MunitParameter params[], void* data) +/* + * A "standard test" needs no setup or teardown and doesn't take any parameters. + * This is a utility macro for the test suite listing. +*/ +#define STD_TEST(test_name, test_fun) { (char *)(test_name), (test_fun), NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL } #endif \ No newline at end of file