aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/parser.c7
-rw-r--r--test/tree.c34
2 files changed, 38 insertions, 3 deletions
diff --git a/test/parser.c b/test/parser.c
index e1587fb..69e216e 100644
--- a/test/parser.c
+++ b/test/parser.c
@@ -6,6 +6,7 @@
TEST_INIT
+#if 0
void empty() {
/*
Hmm… I feel as though this setup/cleanup process could be wrapped in a
@@ -1048,8 +1049,10 @@ void def_with_arg() {
tree_destroy(tree);
}
+#endif
+
int main() {
- empty();
+ /* empty();
single_lint();
double_lint();
single_lstr();
@@ -1065,7 +1068,7 @@ int main() {
cargumented_call_of_lint();
call_many_arg();
def_bare_lint();
- def_with_arg();
+ def_with_arg();*/
TEST_REPORT;
diff --git a/test/tree.c b/test/tree.c
index 567daae..6ef12dc 100644
--- a/test/tree.c
+++ b/test/tree.c
@@ -9,6 +9,7 @@ TEST_INIT
I wrote these before I started putting tests in their own functions, so
this'll have to do for now.
*/
+#if 0
void test_things() {
tree_t* tree_0;
tree_t* tree_1;
@@ -246,9 +247,40 @@ void test_things() {
/* *Definitely* not cleaning up fully here. Oh, well. */
}
+#endif
+
+void test_tree_cpy() {
+ tree_t* tree_block = tree_init(TREE_TYPE_BLOCK, NULL);
+ tree_t* tree_lstr = tree_block->data.block.val = tree_init(TREE_TYPE_LSTR, tree_block);
+ char* char_lstr = tree_lstr->data.lstr.val = calloc(12, sizeof(char));
+ strcpy(char_lstr, "hello world");
+ tree_lstr->data.lstr.len = 11;
+ tree_t* tree_block2 = tree_block->data.block.nxt = tree_init(TREE_TYPE_BLOCK, tree_block);
+ tree_t* tree_def = tree_block2->data.block.val = tree_init(TREE_TYPE_DEF, tree_block2);
+ tree_t* tree_tag = tree_def->data.def.tag = tree_init(TREE_TYPE_TAG, tree_def);
+ char* char_tag = tree_tag->data.tag.val = calloc(4, sizeof(char));
+ strcpy(char_tag, "int");
+ tree_tag->data.tag.nxt = NULL;
+ tree_t* tree_darg = tree_def->data.def.arg = tree_init(TREE_TYPE_DARG, tree_def);
+ tree_t* tree_tag2 = tree_darg->data.darg.tag = tree_init(TREE_TYPE_TAG, tree_darg);
+ char* char_tag2 = tree_tag2->data.tag.val = calloc(4, sizeof(char));
+ strcpy(char_tag2, "int");
+ tree_tag2->data.tag.nxt = NULL;
+ tree_darg->data.darg.nxt = NULL;
+ tree_t* tree_lint = tree_def->data.def.val = tree_init(TREE_TYPE_LINT, tree_def);
+ tree_lint->data.lint.val = 42;
+ tree_block2->data.block.nxt = NULL;
+
+ tree_t* t2 = malloc(sizeof(tree_t));
+
+ tree_cpy(&t2, tree_block);
+
+ ASSERT(tree_cmp(tree_block, t2));
+ ASSERT(&t2 != &tree_block);
+}
int main() {
- test_things();
+// test_things();
TEST_REPORT
}