1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#include "../test.h"
#include "../helpers.h"
static int test_ref(void)
{
test_start("ref");
cleri_grammar_t * grammar;
cleri_t * k_hi, * ref;
k_hi = cleri_keyword(0, "hi", false);
ref = cleri_ref();
grammar = cleri_grammar(ref, NULL);
/* now set the reference */
cleri_ref_set(ref, k_hi);
_assert_is_valid (grammar, "hi");
_assert_is_not_valid (grammar, "");
_assert_parse_str (
grammar,
"ha",
"error at line 1, position 0, unexpected `ha`, expecting: hi",
NULL);
_assert_parse_str2 (
grammar,
"ha",
"error at line 1, position 0, unexpected `ha`",
NULL);
cleri_grammar_free(grammar);
return test_end();
}
int main()
{
return (
test_ref() ||
0
);
}
|