#ifndef SK_TEST_PARSER_H #define SK_TEST_PARSER_H #include #include "node.h" #include static void test_parser(char const* oracle, char const* source) { struct parser parser; parser_init(&parser, source); struct node* node = parser_try_parse(&parser); CU_ASSERT_FATAL(node != NULL); struct str str; str_init(&str); node_str(node, &str); CU_ASSERT_STRING_EQUAL(oracle, str.value); str_free(&str); node_free(node); free(node); parser_free(&parser); } static void test_parser_int() { test_parser("ROOT(INT[32])", " 32 "); test_parser("ROOT(INT[32],INT[-2],INT[24])", " 32 -2 24"); } void register_parser() { CU_pSuite suite = CU_add_suite("Parser", 0, 0); CU_add_test(suite, "Integers", test_parser_int); } #endif