38 lines
1.1 KiB
C
38 lines
1.1 KiB
C
#include "testparser.h"
|
|
#include <assert.h>
|
|
#include <string.h>
|
|
#include "testutils.h"
|
|
|
|
int main()
|
|
{
|
|
char const * input = "bbbb";
|
|
p_context_t context;
|
|
p_context_init(&context, (uint8_t const *)input, strlen(input));
|
|
assert(p_parse(&context) == P_SUCCESS);
|
|
Start * start = p_result(&context);
|
|
assert_not_null(start->bs);
|
|
assert_not_null(start->bs->b);
|
|
assert_not_null(start->bs->bs->b);
|
|
assert_not_null(start->bs->bs->bs->b);
|
|
assert_not_null(start->bs->bs->bs->bs->b);
|
|
p_free_ast(start);
|
|
|
|
p_context_init(&context, (uint8_t const *)input, strlen(input));
|
|
assert(p_parse_Bs(&context) == P_SUCCESS);
|
|
Bs * bs = p_result_Bs(&context);
|
|
assert_not_null(bs->b);
|
|
assert_not_null(bs->bs->b);
|
|
assert_not_null(bs->bs->bs->b);
|
|
assert_not_null(bs->bs->bs->bs->b);
|
|
p_free_ast_Bs(bs);
|
|
|
|
input = "c";
|
|
p_context_init(&context, (uint8_t const *)input, strlen(input));
|
|
assert(p_parse_R(&context) == P_SUCCESS);
|
|
R * r = p_result_R(&context);
|
|
assert_not_null(r->c);
|
|
p_free_ast_R(r);
|
|
|
|
return 0;
|
|
}
|