#include "include/test.h" #include "../../src/include/herb.h" #include "../../src/include/lexer/lex_helpers.h" #include "../../src/include/lib/hb_allocator.h" TEST(herb_lex_to_buffer_empty_file) char* html = ""; hb_allocator_T allocator = hb_allocator_with_malloc(); hb_buffer_T output; hb_buffer_init(&output, 1024, &allocator); herb_lex_to_buffer(html, &output, &allocator); ck_assert_str_eq(output.value, "#\" range=[0, 0] start=(1:0) end=(1:0)>\n"); hb_buffer_free(&output); END TEST(herb_lex_to_buffer_basic_tag) char* html = ""; hb_allocator_T allocator = hb_allocator_with_malloc(); hb_buffer_T output; hb_buffer_init(&output, 1024, &allocator); herb_lex_to_buffer(html, &output, &allocator); ck_assert_str_eq( output.value, "#\n" "#\n" "#\" range=[5, 6] start=(1:5) end=(1:6)>\n" "#\n" "#\n" "#\" range=[12, 13] start=(1:12) end=(1:13)>\n" "#\" range=[13, 13] start=(1:13) end=(1:13)>\n" ); hb_buffer_free(&output); END TCase *lex_tests(void) { TCase *tags = tcase_create("Lex"); tcase_add_test(tags, herb_lex_to_buffer_empty_file); tcase_add_test(tags, herb_lex_to_buffer_basic_tag); return tags; }