Reformat tester
This commit is contained in:
@@ -11,45 +11,45 @@
|
|||||||
wapp_intern void handle_test_result(TestFuncResult result);
|
wapp_intern void handle_test_result(TestFuncResult result);
|
||||||
|
|
||||||
void run_tests(TestFunc *func1, ...) {
|
void run_tests(TestFunc *func1, ...) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
handle_test_result(func1());
|
handle_test_result(func1());
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, func1);
|
va_start(args, func1);
|
||||||
|
|
||||||
TestFunc *func = va_arg(args, TestFunc *);
|
TestFunc *func = va_arg(args, TestFunc *);
|
||||||
|
|
||||||
while (func) {
|
while (func) {
|
||||||
TestFuncResult result = func();
|
TestFuncResult result = func();
|
||||||
handle_test_result(result);
|
handle_test_result(result);
|
||||||
|
|
||||||
func = va_arg(args, TestFunc *);
|
func = va_arg(args, TestFunc *);
|
||||||
}
|
}
|
||||||
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
wapp_intern void handle_test_result(TestFuncResult result) {
|
wapp_intern void handle_test_result(TestFuncResult result) {
|
||||||
TerminalColour colour;
|
TerminalColour colour;
|
||||||
Str8 result_text = wapp_str8_buf(64);
|
Str8 result_text = wapp_str8_buf(64);
|
||||||
|
|
||||||
if (result.passed) {
|
if (result.passed) {
|
||||||
colour = WAPP_TERM_COLOUR_FG_BR_GREEN;
|
colour = WAPP_TERM_COLOUR_FG_BR_GREEN;
|
||||||
wapp_str8_copy_cstr_capped(&result_text, "PASSED");
|
wapp_str8_copy_cstr_capped(&result_text, "PASSED");
|
||||||
} else {
|
} else {
|
||||||
colour = WAPP_TERM_COLOUR_FG_BR_RED;
|
colour = WAPP_TERM_COLOUR_FG_BR_RED;
|
||||||
wapp_str8_copy_cstr_capped(&result_text, "FAILED");
|
wapp_str8_copy_cstr_capped(&result_text, "FAILED");
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("[");
|
printf("[");
|
||||||
wapp_shell_termcolour_print_text(&result_text, colour);
|
wapp_shell_termcolour_print_text(&result_text, colour);
|
||||||
wapp_shell_termcolour_clear_colour();
|
wapp_shell_termcolour_clear_colour();
|
||||||
printf("] " WAPP_STR8_SPEC "\n", wapp_str8_varg(result.name));
|
printf("] " WAPP_STR8_SPEC "\n", wapp_str8_varg(result.name));
|
||||||
|
|
||||||
if (!result.passed) {
|
if (!result.passed) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ BEGIN_C_LINKAGE
|
|||||||
|
|
||||||
typedef struct test_func_result TestFuncResult;
|
typedef struct test_func_result TestFuncResult;
|
||||||
struct test_func_result {
|
struct test_func_result {
|
||||||
Str8 name;
|
Str8 name;
|
||||||
b8 passed;
|
b8 passed;
|
||||||
|
|
||||||
#ifdef WAPP_PLATFORM_WINDOWS
|
#ifdef WAPP_PLATFORM_WINDOWS
|
||||||
wapp_misc_utils_padding_size(sizeof(Str8RO) + sizeof(b8));
|
wapp_misc_utils_padding_size(sizeof(Str8RO) + sizeof(b8));
|
||||||
#endif // WAPP_PLATFORM_WINDOWS
|
#endif // WAPP_PLATFORM_WINDOWS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user