diff options
Diffstat (limited to 'src/test/check_grammar.c')
-rw-r--r-- | src/test/check_grammar.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/test/check_grammar.c b/src/test/check_grammar.c new file mode 100644 index 0000000..1fe27dd --- /dev/null +++ b/src/test/check_grammar.c @@ -0,0 +1,35 @@ +#include <stdio.h> +#include <stdlib.h> +#include "../grammar.h" + +int main(U_ATTR int argc, U_ATTR char **argv) +{ + /* check new_tnt and print it */ + TNT *tnt = new_tnt(1, 12); + + printf("Print a TNT value of type NT: "); + print_tnt(tnt); + printf("\n"); + + free(tnt); + + /* check new_tnt_string */ + + List *tnt_string = new_tnt_string("tntnt", 5, + (T) 1, (NT) 2, (T) 3, (NT) 4, (T) 15); + + if (!tnt_string) { + eprintf("error!\n"); + return 1; + } + + /* check new_rule, print_rule, and destroy_rule. */ + + Rule *rule = new_rule(1, tnt_string); + + print_rule(rule); + + destroy_rule(rule); + + return 0; +} |