test: hectic C: fix logger test
This commit is contained in:
@@ -172,7 +172,7 @@ char* raise_message(
|
||||
strftime(timeStr, sizeof(timeStr), "%Y-%m-%d %H:%M:%S", &tm_info);
|
||||
|
||||
// Print timestamp, log level with color, location info
|
||||
fprintf(stderr, "%s %s%s%s [%s:%s:%s%d%s] ",
|
||||
fprintf(stderr, "%s %s%s%s %s:%s:%s%d%s ",
|
||||
timeStr,
|
||||
log_level_to_color(level),
|
||||
log_level_to_string(level),
|
||||
|
||||
@@ -143,6 +143,10 @@ case "$MODE" in
|
||||
env LOG_LEVEL="$LOG_LEVEL" gdb -tui "$exe"
|
||||
fi
|
||||
env LOG_LEVEL="$LOG_LEVEL" "$exe"
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
;;
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
stderr = orig_stderr; \
|
||||
fclose(temp); \
|
||||
char expected_buffer[256]; \
|
||||
sprintf(expected_buffer, "%s " LEVEL_STR " " __FILE__ ":%d message\n", time_str, __LINE__); \
|
||||
printf("DEBUG: [%s] [%s]\n", result_buffer, expected_buffer); \
|
||||
const char* func = __func__; \
|
||||
sprintf(expected_buffer, "%s " LEVEL_STR " " __FILE__ ":%s:%d message\n", time_str, func, __LINE__); \
|
||||
assert(strcmp(result_buffer, expected_buffer) == 0); \
|
||||
} while(0)
|
||||
|
||||
int main(void) {
|
||||
printf("Running %s\n", __FILE__);
|
||||
printf("%sRunning %s%s%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_CYAN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
|
||||
TEST_RAISE_GENERIC(raise_debug, LOG_LEVEL_DEBUG, "DEBUG");
|
||||
TEST_RAISE_GENERIC(raise_log, LOG_LEVEL_LOG, "LOG");
|
||||
@@ -35,6 +35,6 @@ int main(void) {
|
||||
TEST_RAISE_GENERIC(raise_warn, LOG_LEVEL_WARN, "WARN");
|
||||
TEST_RAISE_GENERIC(raise_exception, LOG_LEVEL_EXCEPTION, "EXCEPTION");
|
||||
|
||||
printf("%s%s all tests passed.%s\n", OPTIONAL_COLOR(COLOR_GREEN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
printf("%sall tests passed.%s%s%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_CYAN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -91,6 +91,7 @@ void test_arena_overwrite_detection() {
|
||||
}
|
||||
|
||||
int main() {
|
||||
printf("%sRunning %s%s%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_CYAN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
init_logger();
|
||||
|
||||
test_arena_init();
|
||||
@@ -101,5 +102,7 @@ int main() {
|
||||
test_arena_strdup();
|
||||
test_arena_repstr();
|
||||
test_arena_overwrite_detection();
|
||||
printf("%s%s all tests passed.%s\n", OPTIONAL_COLOR(COLOR_GREEN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
|
||||
printf("%sall tests passed.%s%s%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_CYAN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -124,6 +124,7 @@ static void test_arena_reset_reuse(void) {
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
printf("%sRunning %s%s%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_CYAN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
init_logger();
|
||||
|
||||
test_parse_json_object();
|
||||
@@ -136,6 +137,6 @@ int main(void) {
|
||||
test_nested_json_object();
|
||||
test_arena_reset_reuse();
|
||||
|
||||
printf("%s%s all tests passed.%s\n", OPTIONAL_COLOR(COLOR_GREEN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
printf("%sall tests passed.%s%s%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_CYAN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ void test_slice_string() {
|
||||
}
|
||||
|
||||
int main() {
|
||||
printf("%sRunning %s%s%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_CYAN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
init_logger();
|
||||
|
||||
test_slice_create();
|
||||
@@ -91,6 +92,6 @@ int main() {
|
||||
test_slice_edge_cases();
|
||||
test_slice_string();
|
||||
|
||||
printf("%s%s all tests passed.%s\n", OPTIONAL_COLOR(COLOR_GREEN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
printf("%sall tests passed.%s%s%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_CYAN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
return 0;
|
||||
}
|
||||
@@ -70,6 +70,7 @@ static void test_template_node_to_debug_str(Arena *arena) {
|
||||
//}
|
||||
|
||||
int main(void) {
|
||||
printf("%sRunning %s%s%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_CYAN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
init_logger();
|
||||
|
||||
Arena arena = arena_init(ARENA_SIZE);
|
||||
@@ -87,6 +88,6 @@ int main(void) {
|
||||
//arena_reset(&arena);
|
||||
|
||||
arena_free(&arena);
|
||||
printf("%s%s all tests passed.%s\n", OPTIONAL_COLOR(COLOR_GREEN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
printf("%sall tests passed.%s%s%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_CYAN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user