File: test_ref.c

package info (click to toggle)
libcleri 1.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 560 kB
  • sloc: ansic: 4,572; makefile: 51; sh: 40
file content (42 lines) | stat: -rw-r--r-- 800 bytes parent folder | download | duplicates (2)
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
    );
}