diff --git a/bintreeTests.c b/bintreeTests.c index 68dc28a..ef35bef 100644 --- a/bintreeTests.c +++ b/bintreeTests.c @@ -126,8 +126,38 @@ void test_clearTreeworksLikeExpected(void) // tests if treeSize returns correct amount of nodes in Tree -// by using addNode a given number of times and testing to see if +// by using addToTree a given number of times and testing to see if // the treeSize matches the number of nodes added +void test_treeSizeWorkingLikeExpected(void) +{ + TreeNode *testRoot = NULL; + int nodeCount = 7; + unsigned int testTreeSize = 0; + int score1 = 12; + int score2 = 6; + int score3 = 18; + int score4 = 3; + int score5 = 9; + int score6 = 15; + int score7 = 21; + + + // Fill 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); + testRoot = addToTree(testRoot, &score4, sizeof(int), compareIntEntries, NULL); + + testTreeSize = treeSize(testRoot); + + TEST_ASSERT_EQUAL(nodeCount, testTreeSize); + + clearTree(testRoot); +} // main, strings together all tests