diff options
Diffstat (limited to 'tests/test.c')
| -rw-r--r-- | tests/test.c | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/tests/test.c b/tests/test.c index 2055c78..cc14456 100644 --- a/tests/test.c +++ b/tests/test.c | |||
| @@ -1,4 +1,6 @@ | |||
| 1 | #include "test.h" | 1 | #include <stdio.h> |
| 2 | |||
| 3 | #include "fst_tests.h" | ||
| 2 | 4 | ||
| 3 | static bool run_test(Test *); | 5 | static bool run_test(Test *); |
| 4 | static bool run_suite(TestSuite *); | 6 | static bool run_suite(TestSuite *); |
| @@ -36,15 +38,42 @@ run_suite(TestSuite *suite) | |||
| 36 | return true; | 38 | return true; |
| 37 | } | 39 | } |
| 38 | 40 | ||
| 39 | int main() { | 41 | static bool |
| 42 | module_in_args(char *module, int argc, char *argv[]) | ||
| 43 | { | ||
| 44 | for (int i = 0; i < argc; i++) | ||
| 45 | if (!strcmp(module, argv[i])) | ||
| 46 | return true; | ||
| 47 | return false; | ||
| 48 | } | ||
| 49 | |||
| 50 | int main(int argc, char *argv[]) { | ||
| 51 | /* TODO: init should be in testsuites */ | ||
| 40 | init_env(); | 52 | init_env(); |
| 41 | init_trans(); | 53 | init_trans(); |
| 54 | /**************************************/ | ||
| 42 | 55 | ||
| 43 | if (!run_suite(&fst_pre_init_suite)) | 56 | TestModule fst = { .name = "fst", .suites = fst_testsuites }; |
| 44 | return 1; | 57 | TestModule *modules[999] = { |
| 45 | if (!run_suite(&fst_post_init_suite)) | 58 | &fst, |
| 46 | return 1; | 59 | NULL |
| 60 | }; | ||
| 61 | |||
| 62 | |||
| 63 | bool all = argc == 1 || module_in_args("all", argc, argv); | ||
| 64 | int count = 0; | ||
| 65 | for (int i = 0; modules[i] != NULL; i++) { | ||
| 66 | if (all || module_in_args(modules[i]->name, argc, argv)) { | ||
| 67 | for (int j = 0; modules[i]->suites[j] != NULL; j++) { | ||
| 68 | if (!run_suite(modules[i]->suites[j])) { | ||
| 69 | return 1; | ||
| 70 | } else { | ||
| 71 | count++; | ||
| 72 | } | ||
| 73 | } | ||
| 74 | } | ||
| 75 | } | ||
| 47 | 76 | ||
| 48 | printf("All tests passed.\n"); | 77 | printf("All tests passed (%d test suites).\n", count); |
| 49 | return 0; | 78 | return 0; |
| 50 | } | 79 | } |
