diff --git a/bintree.o b/bintree.o index 48f3a9c..49eaac0 100644 Binary files a/bintree.o and b/bintree.o differ diff --git a/bintreeTests.c b/bintreeTests.c index c187aaf..495a8fb 100644 --- a/bintreeTests.c +++ b/bintreeTests.c @@ -3,6 +3,7 @@ #include #include "unity.h" #include "bintree.h" +#include "stack.h" #define MAX_TEST_NAME_LEN 10 @@ -89,7 +90,42 @@ void test_addToTreeExpandsTreeCorrectly(void) // needs Stack!!! void test_nextTreeDataReturnsNextDataCorrectly(void) { + TreeNode *testRoot = NULL; + int score1 = 12; + int score2 = 6; + int score3 = 18; + int score4 = 3; + int score5 = 9; + int score6 = 15; + int score7 = 21; + + // Prepare a Tree + testRoot = addToTree(testRoot, &score1, sizeof(int), compareIntEntries, NULL); + testRoot = addToTree(testRoot, &score2, sizeof(int), compareIntEntries, NULL); + testRoot = addToTree(testRoot, &score3, sizeof(int), compareIntEntries, NULL); + testRoot = addToTree(testRoot, &score4, sizeof(int), compareIntEntries, NULL); + testRoot = addToTree(testRoot, &score5, sizeof(int), compareIntEntries, NULL); + testRoot = addToTree(testRoot, &score6, sizeof(int), compareIntEntries, NULL); + testRoot = addToTree(testRoot, &score7, sizeof(int), compareIntEntries, NULL); + + + // Create Stack + StackNode *entry = nextTreeData(testRoot); + + // check if nextTreeData returns Data correctly + TEST_ASSERT_NOT_NULL(entry); + + TEST_ASSERT_EQUAL(score7, *(int *)nextTreeData(NULL)); + TEST_ASSERT_EQUAL(score3, *(int *)nextTreeData(NULL)); + TEST_ASSERT_EQUAL(score6, *(int *)nextTreeData(NULL)); + TEST_ASSERT_EQUAL(score1, *(int *)nextTreeData(NULL)); + TEST_ASSERT_EQUAL(score5, *(int *)nextTreeData(NULL)); + TEST_ASSERT_EQUAL(score2, *(int *)nextTreeData(NULL)); + TEST_ASSERT_EQUAL(score4, *(int *)nextTreeData(NULL)); + + clearStack(entry); + clearTree(testRoot); } diff --git a/runbintreeTests.exe b/runbintreeTests.exe deleted file mode 100644 index 6e09e24..0000000 Binary files a/runbintreeTests.exe and /dev/null differ