#include #include #include #include static void test_define_pos(void) { int ret = 0; scc_sstream_t mem_stream; const char *input = "#define OBJ 1\nOBJ"; ret = scc_sstream_init_by_buffer(&mem_stream, input, strlen(input), false, 16); Assert(ret == 0); scc_lexer_t lexer; scc_lexer_init(&lexer, scc_sstream_to_ring(&mem_stream)); scc_pproc_t pp; scc_pproc_init(&pp, scc_lexer_to_ring(&lexer, 8, true)); scc_lexer_tok_ring_t *tok_ring = scc_pproc_to_ring(&pp, 8, true, true); scc_lexer_tok_t tok = {0}; scc_ring_next_consume(*tok_ring, tok, ret); Assert(ret == true); TEST_CHECK(tok.loc.line == 2 && tok.loc.col == 1 && scc_strcmp(tok.lexeme.data, "1") == 0); TEST_MSG("Expected: %d:%d:%s", 2, 1, "1"); TEST_MSG("Produced: %zu:%zu:%s", tok.loc.line, tok.loc.col, tok.lexeme.data); scc_ring_free(*tok_ring); scc_pproc_drop(&pp); scc_lexer_drop(&lexer); scc_sstream_drop(&mem_stream); } #define TEST_LIST_CASE(func_name) {#func_name, func_name} TEST_LIST = { TEST_LIST_CASE(test_define_pos), {NULL, NULL}, };