From bf44088d4373a9520e860152c56a958332819c4b Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 1 May 2023 16:33:51 +0200 Subject: Split nissy in other repos, see README.md --- tests/test.c | 85 ------------------------------------------------------------ 1 file changed, 85 deletions(-) delete mode 100644 tests/test.c (limited to 'tests/test.c') diff --git a/tests/test.c b/tests/test.c deleted file mode 100644 index 8961de1..0000000 --- a/tests/test.c +++ /dev/null @@ -1,85 +0,0 @@ -#include - -#include "alg_tests.h" -#include "coord_tests.h" -#include "fst_tests.h" - -static bool run_test(Test *); -static bool run_suite(TestSuite *); - -static bool -run_test(Test *test) -{ - int i; - - printf("Running test %s...", test->name); - for (i = 0; test->cases[i] != NULL; i++) { - if (!test->t(test->cases[i])) { - printf("FAILED!\n"); - return false; - } - } - - printf("OK\n"); - return true; -} - -static bool -run_suite(TestSuite *suite) -{ - int i; - - if (suite->setup != NULL) - suite->setup(); - for (i = 0; suite->tests[i] != NULL; i++) - if(!run_test(suite->tests[i])) - return false; - if (suite->teardown != NULL) - suite->teardown(); - - return true; -} - -static bool -module_in_args(char *module, int argc, char *argv[]) -{ - for (int i = 0; i < argc; i++) - if (!strcmp(module, argv[i])) - return true; - return false; -} - -int main(int argc, char *argv[]) { - /* TODO: init should be in testsuites */ - init_env(); - init_trans(); - /**************************************/ - - TestModule alg = { .name = "alg", .suites = alg_suites }; - TestModule fst = { .name = "fst", .suites = fst_suites }; - TestModule coord = { .name = "coord", .suites = coord_suites }; - TestModule *modules[999] = { - &alg, - &fst, - &coord, - NULL - }; - - - bool all = argc == 1 || module_in_args("all", argc, argv); - int count = 0; - for (int i = 0; modules[i] != NULL; i++) { - if (all || module_in_args(modules[i]->name, argc, argv)) { - for (int j = 0; modules[i]->suites[j] != NULL; j++) { - if (!run_suite(modules[i]->suites[j])) { - return 1; - } else { - count++; - } - } - } - } - - printf("All tests passed (%d test suites).\n", count); - return 0; -} -- cgit v1.3