diff options
author | c | 2023-12-26 18:41:52 -0500 |
---|---|---|
committer | c | 2023-12-26 18:41:52 -0500 |
commit | c71b98b5b4d14cf30602064d7041828ba8244372 (patch) | |
tree | ad431e75d502d1bb4f344ced8d5142491057dfc5 /test | |
parent | e39267c83a8af189a624891813ebd6014543b01a (diff) |
Filled in tests for tree_cmp.
Diffstat (limited to 'test')
-rw-r--r-- | test/parser.c | 11 | ||||
-rw-r--r-- | test/tree.c | 28 |
2 files changed, 35 insertions, 4 deletions
diff --git a/test/parser.c b/test/parser.c index fb1c0b2..06a305e 100644 --- a/test/parser.c +++ b/test/parser.c @@ -45,10 +45,17 @@ int main(int argc, char** argv) { treep_11->data.block.nxt = NULL; tree_0->data.block.nxt = NULL; + /* + + [block] + + + */ + char src_0[] = "" \ ":int:f = {" \ - " a.b;" \ - " c.d;" \ + "a.b;" \ + "c.d" "}"; pp = pp_init(src_0); diff --git a/test/tree.c b/test/tree.c index 4c32746..b4c6ed8 100644 --- a/test/tree.c +++ b/test/tree.c @@ -29,8 +29,6 @@ int main(int argc, char** argv) { tree_lstr_1 = tree_init(TREE_TYPE_LSTR); tree_tag_0 = tree_init(TREE_TYPE_TAG); tree_tag_1 = tree_init(TREE_TYPE_TAG); - tree_def_0 = tree_init(TREE_TYPE_DEF); - tree_def_1 = tree_init(TREE_TYPE_DEF); tree_call_0 = tree_init(TREE_TYPE_CALL); tree_call_1 = tree_init(TREE_TYPE_CALL); @@ -49,6 +47,32 @@ int main(int argc, char** argv) { ASSERT(tree_cmp(tree_lint_0, tree_lint_0) == 1); ASSERT(tree_cmp(tree_lint_0, tree_lint_1) == 0); + /* Test lstrs. */ + tree_lstr_0->data.lstr.val = "foo"; + tree_lstr_0->data.lstr.len = 3; + tree_lstr_1->data.lstr.val = "bar"; + tree_lstr_1->data.lstr.len = 3; + ASSERT(tree_cmp(tree_lstr_0, tree_lstr_0) == 1); + ASSERT(tree_cmp(tree_lstr_0, tree_lstr_1) == 0); + + /* Test tags. */ + tree_tag_0->data.tag.val = "int"; + tree_tag_0->data.tag.nxt = NULL; + tree_tag_1->data.tag.val = "str"; + tree_tag_1->data.tag.nxt = NULL; + ASSERT(tree_cmp(tree_tag_0, tree_tag_0) == 1); + ASSERT(tree_cmp(tree_tag_0, tree_tag_1) == 0); + tree_tag_1->data.tag.nxt = tree_tag_0; + ASSERT(tree_cmp(tree_tag_0, tree_tag_1) == 0); + + /* Test calls. */ + tree_call_0->data.call.arg = NULL; + tree_call_0->data.call.target = "foo"; + tree_call_1->data.call.arg = NULL; + tree_call_1->data.call.target = "bar"; + ASSERT(tree_cmp(tree_call_0, tree_call_0) == 1); + ASSERT(tree_cmp(tree_call_0, tree_call_1) == 0); + TEST_REPORT; return 0; } |