28 lines
551 B
C
28 lines
551 B
C
|
#include "test.h"
|
||
|
|
||
|
#include "mrk/lexer.h"
|
||
|
|
||
|
#define LEXER_INIT() \
|
||
|
mrk_lexer *lxr; \
|
||
|
TEST_CHECK(mrk_lexer_init(&lxr) == mrk_err_ok)
|
||
|
|
||
|
void test_lexer_header() {
|
||
|
LEXER_INIT();
|
||
|
|
||
|
const char *buf = "#### hallo";
|
||
|
mrk_lexer_open(lxr, buf, 0);
|
||
|
|
||
|
mrk_token t;
|
||
|
TEST_CHECK(mrk_lexer_next(&t, lxr) == mrk_lexer_err_ok);
|
||
|
TEST_CHECK(t.type == mrk_token_type_header);
|
||
|
TEST_CHECK_(t.start == 0, "t.start == %lu", t.start);
|
||
|
TEST_CHECK(t.end == 4);
|
||
|
|
||
|
mrk_lexer_free(lxr);
|
||
|
}
|
||
|
|
||
|
TEST_LIST = {
|
||
|
{ "lexer header", test_lexer_header },
|
||
|
{ NULL, NULL }
|
||
|
};
|