Fix bintreeTests

This commit is contained in:
Tobias Linz committed 2026-11-19 09:48:57 +01:00
1 parent 85823eee27
commit 88d97f3b67
2 files changed
+20 -20

No files matched your search

+1 -1
View File
@@ -42,7 +42,7 @@ stackTests: test_stack.c stack.o $(unityfolder)/unity.c
$(CC) $(FLAGS) -I$(unityfolder) $^ -o stackTests $(CC) $(FLAGS) -I$(unityfolder) $^ -o stackTests
bintreeTests: bintree.o test_bintree.c stack.o $(unityfolder)/unity.c 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) # compile_commands.json für clangd erzeugen (benötigt bear)
+19 -19
View File
@@ -33,14 +33,14 @@ static void test_addToTreeBuildsTreeInOrder(void)
{ {
const TreeNode *const tree = buildTree(); const TreeNode *const tree = buildTree();
TEST_ASSERT_EQUAL(1, *(int *)tree->data); TEST_ASSERT_EQUAL_INT(1, *(int *)tree->data);
TEST_ASSERT_EQUAL(NULL, tree->left); TEST_ASSERT_NULL(tree->left);
TEST_ASSERT_NOT_NULL(tree->right); 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_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_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) static void test_addToTreeReportsNoDuplicates(void)
@@ -51,7 +51,7 @@ static void test_addToTreeReportsNoDuplicates(void)
const int data = -1; const int data = -1;
tree = addToTree(tree, &data, sizeof(int), compare_ints, &duplicates); 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) static void test_addToTreeReportsDuplicates(void)
@@ -62,7 +62,7 @@ static void test_addToTreeReportsDuplicates(void)
const int data = 1; const int data = 1;
tree = addToTree(tree, &data, sizeof(int), compare_ints, &duplicates); 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) static void test_clearTree(void)
@@ -81,16 +81,16 @@ static void test_nextTreeDataTraversesTree(void)
const int *const value1 = nextTreeData(buildTree()); const int *const value1 = nextTreeData(buildTree());
TEST_ASSERT_NOT_NULL(value1); TEST_ASSERT_NOT_NULL(value1);
TEST_ASSERT_EQUAL(1, *value1); TEST_ASSERT_EQUAL_INT(1, *value1);
const int *const value2 = nextTreeData(NULL); const int *const value2 = nextTreeData(NULL);
TEST_ASSERT_NOT_NULL(value2); TEST_ASSERT_NOT_NULL(value2);
TEST_ASSERT_EQUAL(2, *value2); TEST_ASSERT_EQUAL_INT(2, *value2);
const int *const value3 = nextTreeData(NULL); const int *const value3 = nextTreeData(NULL);
TEST_ASSERT_NOT_NULL(value3); TEST_ASSERT_NOT_NULL(value3);
TEST_ASSERT_EQUAL(3, *value3); TEST_ASSERT_EQUAL_INT(3, *value3);
const int *const value4 = nextTreeData(NULL); const int *const value4 = nextTreeData(NULL);
TEST_ASSERT_NOT_NULL(value4); TEST_ASSERT_NOT_NULL(value4);
TEST_ASSERT_EQUAL(4, *value4); TEST_ASSERT_EQUAL_INT(4, *value4);
TEST_ASSERT_NULL(nextTreeData(NULL)); TEST_ASSERT_NULL(nextTreeData(NULL));
} }
@@ -98,33 +98,33 @@ static void test_nextTreeDataTraversesTwoTrees(void)
{ {
const int *const value1a = nextTreeData(buildTree()); const int *const value1a = nextTreeData(buildTree());
TEST_ASSERT_NOT_NULL(value1a); TEST_ASSERT_NOT_NULL(value1a);
TEST_ASSERT_EQUAL(1, *value1a); TEST_ASSERT_EQUAL_INT(1, *value1a);
const int *const value2a = nextTreeData(NULL); const int *const value2a = nextTreeData(NULL);
TEST_ASSERT_NOT_NULL(value2a); TEST_ASSERT_NOT_NULL(value2a);
TEST_ASSERT_EQUAL(2, *value2a); TEST_ASSERT_EQUAL_INT(2, *value2a);
const int *const value1b = nextTreeData(buildTree()); const int *const value1b = nextTreeData(buildTree());
TEST_ASSERT_NOT_NULL(value1b); TEST_ASSERT_NOT_NULL(value1b);
TEST_ASSERT_EQUAL(1, *value1b); TEST_ASSERT_EQUAL_INT(1, *value1b);
const int *const value2b = nextTreeData(NULL); const int *const value2b = nextTreeData(NULL);
TEST_ASSERT_NOT_NULL(value2b); TEST_ASSERT_NOT_NULL(value2b);
TEST_ASSERT_EQUAL(2, *value2b); TEST_ASSERT_EQUAL_INT(2, *value2b);
const int *const value3b = nextTreeData(NULL); const int *const value3b = nextTreeData(NULL);
TEST_ASSERT_NOT_NULL(value3b); TEST_ASSERT_NOT_NULL(value3b);
TEST_ASSERT_EQUAL(3, *value3b); TEST_ASSERT_EQUAL_INT(3, *value3b);
const int *const value4b = nextTreeData(NULL); const int *const value4b = nextTreeData(NULL);
TEST_ASSERT_NOT_NULL(value4b); TEST_ASSERT_NOT_NULL(value4b);
TEST_ASSERT_EQUAL(4, *value4b); TEST_ASSERT_EQUAL_INT(4, *value4b);
TEST_ASSERT_NULL(nextTreeData(NULL)); TEST_ASSERT_NULL(nextTreeData(NULL));
} }
static void test_treeSizeIsZeroForNULLTree(void) static void test_treeSizeIsZeroForNULLTree(void)
{ {
TEST_ASSERT_EQUAL(0, treeSize(NULL)); TEST_ASSERT_EQUAL_INT(0, treeSize(NULL));
} }
static void test_treeSizeIsCorrectForTestTree(void) static void test_treeSizeIsCorrectForTestTree(void)
{ {
TEST_ASSERT_EQUAL(4, treeSize(buildTree())); TEST_ASSERT_EQUAL_INT(4, treeSize(buildTree()));
} }
void setUp(void) void setUp(void)