2024-03-15 22:24:19 +01:00
|
|
|
#include "test.h"
|
|
|
|
|
|
|
|
#include "mrk/lexer.h"
|
2024-03-16 14:07:47 +01:00
|
|
|
#include "mrk/parser.h"
|
2024-03-15 22:24:19 +01:00
|
|
|
|
|
|
|
#define LEXER_INIT() \
|
|
|
|
mrk_lexer *lxr; \
|
|
|
|
TEST_CHECK(mrk_lexer_init(&lxr) == mrk_err_ok)
|
|
|
|
|
|
|
|
#define PARSER_INIT() \
|
|
|
|
mrk_parser *parser; \
|
|
|
|
TEST_CHECK(mrk_parser_init(&parser) == mrk_err_ok)
|
|
|
|
|
|
|
|
#define PARSER_OPEN(buf) \
|
|
|
|
mrk_lexer *lxr; \
|
|
|
|
TEST_CHECK(mrk_lexer_init(&lxr) == mrk_err_ok); \
|
|
|
|
mrk_parser *parser; \
|
|
|
|
TEST_CHECK(mrk_parser_init(&parser) == mrk_err_ok); \
|
|
|
|
mrk_lexer_open(lxr, buf, 0); \
|
|
|
|
mrk_parser_open(parser, lxr)
|
|
|
|
|
|
|
|
void test_parse_simple_header_paragraph() {
|
|
|
|
const char *buf = "# this is a header\n\nthis is a paragraph with a [link](https://example.com)";
|
|
|
|
PARSER_OPEN(buf);
|
|
|
|
|
|
|
|
mrk_ast_node *root;
|
|
|
|
TEST_CHECK(mrk_parser_parse(&root, parser) == mrk_err_ok);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_LIST = {
|
|
|
|
{ "parser simple header and paragraph", test_parse_simple_header_paragraph },
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|