diff options
| author | nodist <kevin.comas.git@gmail.com> | 2026-09-20 13:22:50 -0400 |
|---|---|---|
| committer | nodist <kevin.comas.git@gmail.com> | 2026-09-20 13:22:50 -0400 |
| commit | 4e19e6ab1bd24466d9dcb0d8eea54a7e3d84d576 (patch) | |
| tree | c0c581d72a122c146d6308a16e0a7269d38ed984 /test | |
| parent | 87dfa262eb6d6b816351c03a01cc837a32b91ab4 (diff) | |
kpl config set module extension
Diffstat (limited to 'test')
| -rw-r--r-- | test/config.c | 21 | ||||
| -rw-r--r-- | test/test.c | 26 |
2 files changed, 34 insertions, 13 deletions
diff --git a/test/config.c b/test/config.c new file mode 100644 index 0000000..8a1dc64 --- /dev/null +++ b/test/config.c @@ -0,0 +1,21 @@ + +#include "kpl_test.h" + +KPL_TEST(config_show_help) { + kpl_config config; + const int32_t argc = 2; + const char *argv[] = { "./kpl", "--help", "not_used" }; + kpl_config_init(&config); + int32_t code = kpl_config_parse_args(&config, argc, argv); + KPL_ASSERT(code == KPL_EXIT_CODE_HELP, "Invalid help exit code"); +} + +KPL_TEST(config_change_module_extension) { + kpl_config config; + const int32_t argc = 3; + const char *argv[] = { "./kpl", "--module-extension=.l", "./file.l" }; + kpl_config_init(&config); + int32_t code = kpl_config_parse_args(&config, argc, argv); + KPL_ASSERT(code == KPL_EXIT_CODE_SUCCESS, "Invalid exit code"); + KPL_ASSERT(strcmp(config.module_extension, ".l") == 0, "Invalid new module extension"); +} diff --git a/test/test.c b/test/test.c index 97af6a4..a4a6281 100644 --- a/test/test.c +++ b/test/test.c @@ -99,16 +99,16 @@ static int32_t kpl_test_list(void) { return KPL_EXIT_CODE_HELP; } -static int32_t kpl_test_run_by_name(int32_t argc, char *argv[], const int32_t named_arg_position) { - if (named_arg_position == argc) { +static int32_t kpl_test_run_by_name(const int32_t argc, const char *argv[], const int32_t named_arg_index) { + if (named_arg_index == argc) { printf(KPL_COLOR(LIGHT_RED) "\nNo Tests Specified\n" KPL_COLOR(RESET)); return kpl_test_help(argv[0]); } int32_t tests_ran = 0; kpl_test *_test = NULL; while ((_test = kpl_test_next())) - for (int32_t test_name_position = named_arg_position; test_name_position < argc; test_name_position++) - if (strcmp(argv[test_name_position], _test->test_name) == 0) { + for (int32_t test_name_index = named_arg_index; test_name_index < argc; test_name_index++) + if (strcmp(argv[test_name_index], _test->test_name) == 0) { kpl_test_run(_test); tests_ran++; } @@ -120,12 +120,12 @@ static int32_t kpl_test_run_by_name(int32_t argc, char *argv[], const int32_t na return kpl_test_error_list(); } -int32_t main(int32_t argc, char *argv[]) { - int32_t arg_position = 1; - while (arg_position < argc) { - if (argv[arg_position][0] != '-' || !argv[arg_position][1] || argv[arg_position][2]) +int32_t main(const int32_t argc, const char *argv[]) { + int32_t arg_index = 1; + while (arg_index < argc) { + if (argv[arg_index][0] != '-' || !argv[arg_index][1] || argv[arg_index][2]) break; - switch (argv[arg_position][1]) { + switch (argv[arg_index][1]) { case 'a': return kpl_test_run_all(); case 'h': @@ -133,17 +133,17 @@ int32_t main(int32_t argc, char *argv[]) { case 'l': return kpl_test_list(); default: - return kpl_test_run_by_name(argc, argv, arg_position); + return kpl_test_run_by_name(argc, argv, arg_index); } - arg_position++; + arg_index++; } - return kpl_test_run_by_name(argc, argv, arg_position); + return kpl_test_run_by_name(argc, argv, arg_index); } KPL_TEST(test_pass_by_default) { // Pass by default // Uncomment below to f ail - // KPL_FAIL("Failure Message"); + // KPL_FAIL("Failure message"); } KPL_TEST(test_counting) { |
