#include "runner.h" #include "../colla.h" #include UNIT_TEST(highlight_init) { arena_t arena = arena_make(ARENA_MALLOC, KB(4)); // Create a basic configuration hl_config_t config = {0}; // Define custom colors config.colors[HL_COLOR_NORMAL] = strv_init("normal"); config.colors[HL_COLOR_KEYWORDS] = strv_init("keyword"); config.colors[HL_COLOR_STRING] = strv_init("string"); config.colors[HL_COLOR_COMMENT] = strv_init("comment"); // Initialize highlighter hl_ctx_t *ctx = hl_init(&arena, &config); ASSERT(ctx != NULL); arena_cleanup(&arena); } UNIT_TEST(highlight_basic) { arena_t arena = arena_make(ARENA_MALLOC, KB(4)); // Create a configuration hl_config_t config = {0}; // Define custom colors for HTML output config.colors[HL_COLOR_NORMAL] = strv_init("color:black"); config.colors[HL_COLOR_KEYWORDS] = strv_init("color:blue"); config.colors[HL_COLOR_STRING] = strv_init("color:green"); config.colors[HL_COLOR_COMMENT] = strv_init("color:gray"); config.colors[HL_COLOR_NUMBER] = strv_init("color:purple"); // Set HTML output flag config.flags = HL_FLAG_HTML; // Initialize highlighter hl_ctx_t *ctx = hl_init(&arena, &config); ASSERT(ctx != NULL); // Sample C code to highlight strview_t code = strv_init( "// This is a comment\n" "int main() {\n" " printf(\"Hello, World!\\n\");\n" " return 0;\n" "}\n" ); // Highlight the code str_t highlighted = hl_highlight(&arena, ctx, code); // Verify the output ASSERT(!str_is_empty(highlighted)); // We can't easily test the exact output without parsing HTML, // but we can check that key strings are present const char *html_start = "