diff options
| author | nodist <kevin.comas.git@gmail.com> | 2026-09-15 16:38:14 -0400 |
|---|---|---|
| committer | nodist <kevin.comas.git@gmail.com> | 2026-09-15 16:38:14 -0400 |
| commit | b6a923c66b14d3b6fd3cc5f13af04e06807da808 (patch) | |
| tree | 2732dfe99dba62561131d3d8a80a6dee9efd4503 /test/test.c | |
| parent | d30da2d13949caf2509f4b6f319612d08dff1a09 (diff) | |
add color pretty print and a test help
Diffstat (limited to 'test/test.c')
| -rw-r--r-- | test/test.c | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/test/test.c b/test/test.c index f12ee6e..afa8e26 100644 --- a/test/test.c +++ b/test/test.c @@ -1,6 +1,49 @@ #include "kpl_test.h" -int main(void) { - return 2; +static kpl_test *_kpl_test_head = NULL, *_kpl_test_tail = NULL, *_kpl_error_head = NULL, *_kpl_error_tail = NULL; + +void kpl_test_add(kpl_test *_test) { + if (_kpl_test_head) + _kpl_test_tail = _kpl_test_tail->next_test = _test; + else + _kpl_test_head = _kpl_test_tail = _test; +} + +static int32_t kpl_test_help(const char *argv0) { + printf("\nUsage: " KPL_COLOR(BOLD) "%s " KPL_COLOR(RESET) + KPL_COLOR(WHITE) "[OPTIONS] [TEST NAMES]\n\n" KPL_COLOR(RESET), argv0); + printf("Where " KPL_COLOR(WHITE) "[OPTIONS]" KPL_COLOR(RESET) " are:\n"); + printf(KPL_COLOR(LIGHT_YELLOW) "\t-h " KPL_COLOR(RESET) "Show Help\n"); + printf(KPL_COLOR(LIGHT_YELLOW) "\t-l " KPL_COLOR(RESET) "List Test Names\n"); + putchar('\n'); + return KPL_EXIT_CODE_HELP; +} + +static int32_t kpl_test_list(void) { + // TODO + return KPL_EXIT_CODE_HELP; +} + +static int32_t kpl_test_run(int32_t argc, char *argv[], const int32_t named_arg_position) { + // TODO RUN + return _kpl_error_tail ? KPL_EXIT_CODE_ERROR : KPL_EXIT_CODE_SUCCESS; +} + +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]) + break; + switch (argv[arg_position][1]) { + case 'h': + return kpl_test_help(argv[0]); + case 'l': + return kpl_test_list(); + default: + return kpl_test_run(argc, argv, arg_position); + } + arg_position++; + } + return kpl_test_run(argc, argv, arg_position); } |
