From 88d97f3b6750c8ebf5b6f76a7c34150b2c766724 Mon Sep 17 00:00:00 2001 From: Tobias Linz Date: Thu, 19 Nov 2026 09:48:57 +0100 Subject: [PATCH] Fix bintreeTests --- Startcode/makefile | 2 +- Startcode/test_bintree.c | 38 +++++++++++++++++++------------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Startcode/makefile b/Startcode/makefile index dbf3277..3d06b7e 100644 --- a/Startcode/makefile +++ b/Startcode/makefile @@ -42,7 +42,7 @@ stackTests: test_stack.c stack.o $(unityfolder)/unity.c $(CC) $(FLAGS) -I$(unityfolder) $^ -o stackTests bintreeTests: bintree.o test_bintree.c stack.o $(unityfolder)/unity.c - $(CC) $(CFLAGS) -I$(unityfolder) -o runBintreeTests test_bintree.c bintree.o stack.o $(unityfolder)/unity.c + $(CC) $(CFLAGS) -I$(unityfolder) -o bintreeTests test_bintree.c bintree.o stack.o $(unityfolder)/unity.c # -------------------------- # compile_commands.json für clangd erzeugen (benötigt bear) diff --git a/Startcode/test_bintree.c b/Startcode/test_bintree.c index 6ff2277..5fabcbd 100644 --- a/Startcode/test_bintree.c +++ b/Startcode/test_bintree.c @@ -33,14 +33,14 @@ static void test_addToTreeBuildsTreeInOrder(void) { const TreeNode *const tree = buildTree(); - TEST_ASSERT_EQUAL(1, *(int *)tree->data); - TEST_ASSERT_EQUAL(NULL, tree->left); + TEST_ASSERT_EQUAL_INT(1, *(int *)tree->data); + TEST_ASSERT_NULL(tree->left); TEST_ASSERT_NOT_NULL(tree->right); - TEST_ASSERT_EQUAL(3, *(int *)tree->right->data); + TEST_ASSERT_EQUAL_INT(3, *(int *)tree->right->data); TEST_ASSERT_NOT_NULL(tree->right->right); - TEST_ASSERT_EQUAL(4, *(int *)tree->right->right->data); + TEST_ASSERT_EQUAL_INT(4, *(int *)tree->right->right->data); TEST_ASSERT_NOT_NULL(tree->right->left); - TEST_ASSERT_EQUAL(2, *(int *)tree->right->left->data); + TEST_ASSERT_EQUAL_INT(2, *(int *)tree->right->left->data); } static void test_addToTreeReportsNoDuplicates(void) @@ -51,7 +51,7 @@ static void test_addToTreeReportsNoDuplicates(void) const int data = -1; tree = addToTree(tree, &data, sizeof(int), compare_ints, &duplicates); - TEST_ASSERT_EQUAL(0, duplicates); + TEST_ASSERT_EQUAL_INT(0, duplicates); } static void test_addToTreeReportsDuplicates(void) @@ -62,7 +62,7 @@ static void test_addToTreeReportsDuplicates(void) const int data = 1; tree = addToTree(tree, &data, sizeof(int), compare_ints, &duplicates); - TEST_ASSERT_EQUAL(1, duplicates); + TEST_ASSERT_EQUAL_INT(1, duplicates); } static void test_clearTree(void) @@ -81,16 +81,16 @@ static void test_nextTreeDataTraversesTree(void) const int *const value1 = nextTreeData(buildTree()); TEST_ASSERT_NOT_NULL(value1); - TEST_ASSERT_EQUAL(1, *value1); + TEST_ASSERT_EQUAL_INT(1, *value1); const int *const value2 = nextTreeData(NULL); TEST_ASSERT_NOT_NULL(value2); - TEST_ASSERT_EQUAL(2, *value2); + TEST_ASSERT_EQUAL_INT(2, *value2); const int *const value3 = nextTreeData(NULL); TEST_ASSERT_NOT_NULL(value3); - TEST_ASSERT_EQUAL(3, *value3); + TEST_ASSERT_EQUAL_INT(3, *value3); const int *const value4 = nextTreeData(NULL); TEST_ASSERT_NOT_NULL(value4); - TEST_ASSERT_EQUAL(4, *value4); + TEST_ASSERT_EQUAL_INT(4, *value4); TEST_ASSERT_NULL(nextTreeData(NULL)); } @@ -98,33 +98,33 @@ static void test_nextTreeDataTraversesTwoTrees(void) { const int *const value1a = nextTreeData(buildTree()); TEST_ASSERT_NOT_NULL(value1a); - TEST_ASSERT_EQUAL(1, *value1a); + TEST_ASSERT_EQUAL_INT(1, *value1a); const int *const value2a = nextTreeData(NULL); TEST_ASSERT_NOT_NULL(value2a); - TEST_ASSERT_EQUAL(2, *value2a); + TEST_ASSERT_EQUAL_INT(2, *value2a); const int *const value1b = nextTreeData(buildTree()); TEST_ASSERT_NOT_NULL(value1b); - TEST_ASSERT_EQUAL(1, *value1b); + TEST_ASSERT_EQUAL_INT(1, *value1b); const int *const value2b = nextTreeData(NULL); TEST_ASSERT_NOT_NULL(value2b); - TEST_ASSERT_EQUAL(2, *value2b); + TEST_ASSERT_EQUAL_INT(2, *value2b); const int *const value3b = nextTreeData(NULL); TEST_ASSERT_NOT_NULL(value3b); - TEST_ASSERT_EQUAL(3, *value3b); + TEST_ASSERT_EQUAL_INT(3, *value3b); const int *const value4b = nextTreeData(NULL); TEST_ASSERT_NOT_NULL(value4b); - TEST_ASSERT_EQUAL(4, *value4b); + TEST_ASSERT_EQUAL_INT(4, *value4b); TEST_ASSERT_NULL(nextTreeData(NULL)); } static void test_treeSizeIsZeroForNULLTree(void) { - TEST_ASSERT_EQUAL(0, treeSize(NULL)); + TEST_ASSERT_EQUAL_INT(0, treeSize(NULL)); } static void test_treeSizeIsCorrectForTestTree(void) { - TEST_ASSERT_EQUAL(4, treeSize(buildTree())); + TEST_ASSERT_EQUAL_INT(4, treeSize(buildTree())); } void setUp(void)