colla/tests/pretty_print_tests.c
2025-09-28 16:31:22 +02:00

33 lines
938 B
C

#include "runner.h"
#include "../colla.h"
#include <stdio.h>
UNIT_TEST(pretty_print_basic) {
arena_t arena = arena_make(ARENA_MALLOC, KB(4));
// The pretty_print function outputs to console, so we can't easily verify its exact output
// Instead, we'll just verify it doesn't crash
pretty_print(arena, "Hello, <red>World!</>");
// Test with formatting
pretty_print(arena, "Value: <blue>%d</>, String: <green>%s</>", 42, "test");
arena_cleanup(&arena);
}
// Helper function to test variadic function
void test_pretty_printv(arena_t arena, const char *fmt, ...) {
va_list args;
va_start(args, fmt);
pretty_printv(arena, fmt, args);
va_end(args);
}
UNIT_TEST(pretty_printv) {
arena_t arena = arena_make(ARENA_MALLOC, KB(4));
// Test the helper function
test_pretty_printv(arena, "Test <yellow>%d</> <cyan>%s</>", 42, "variadic");
arena_cleanup(&arena);
}