55 lines
1.5 KiB
C
55 lines
1.5 KiB
C
#include "testparser.h"
|
|
#include <assert.h>
|
|
#include <string.h>
|
|
#include "testutils.h"
|
|
|
|
int main()
|
|
{
|
|
char const * input = "b";
|
|
p_context_t * context;
|
|
context = p_context_new((uint8_t const *)input, strlen(input));
|
|
assert(p_parse(context) == P_SUCCESS);
|
|
Start * start = p_result(context);
|
|
assert(start->a == NULL);
|
|
assert(start->pToken2 != NULL);
|
|
assert_eq(TOKEN_b, start->pToken2->token);
|
|
assert(start->pR3 == NULL);
|
|
assert(start->pR == NULL);
|
|
assert(start->r == NULL);
|
|
|
|
p_tree_delete(start);
|
|
p_context_delete(context);
|
|
|
|
input = "abcd";
|
|
context = p_context_new((uint8_t const *)input, strlen(input));
|
|
assert(p_parse(context) == P_SUCCESS);
|
|
start = p_result(context);
|
|
assert(start->a != NULL);
|
|
assert_eq(TOKEN_a, start->pToken1->token);
|
|
assert(start->pToken2 != NULL);
|
|
assert(start->pR3 != NULL);
|
|
assert(start->pR != NULL);
|
|
assert(start->r != NULL);
|
|
assert(start->pR == start->pR3);
|
|
assert(start->pR == start->r);
|
|
assert_eq(TOKEN_c, start->pR->pToken1->token);
|
|
|
|
p_tree_delete(start);
|
|
p_context_delete(context);
|
|
|
|
input = "bdc";
|
|
context = p_context_new((uint8_t const *)input, strlen(input));
|
|
assert(p_parse(context) == P_SUCCESS);
|
|
start = p_result(context);
|
|
assert(start->a == NULL);
|
|
assert(start->pToken2 != NULL);
|
|
assert(start->r != NULL);
|
|
assert_eq(TOKEN_d, start->pR->pToken1->token);
|
|
|
|
p_tree_delete(start);
|
|
p_context_delete(context);
|
|
|
|
return 0;
|
|
}
|
|
|