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_sequence(void)
{
test_start("sequence");
cleri_grammar_t * grammar;
cleri_t * k_hi, * k_iris, * seq;
k_hi = cleri_keyword(0, "hi", false);
k_iris = cleri_keyword(0, "iris", false);
seq = cleri_sequence(0, 2, k_hi, k_iris);
grammar = cleri_grammar(seq, NULL);
_assert_is_valid (grammar, "hi iris");
_assert_is_not_valid (grammar, "hi sasha");
_assert_parse_str (
grammar,
"hi sasha",
"error at line 1, position 3, "
"unexpected `sasha`, expecting: iris",
NULL);
_assert_parse_str2 (
grammar,
"hi sasha",
"error at line 1, position 3, "
"unexpected `sasha`",
NULL);
cleri_grammar_free(grammar);
return test_end();
}
int main()
{
return (
test_sequence() ||
0
);
}
|