wrote test_clearTreeworksLikeExpected()
This commit is contained in:
parent
1ead9595ce
commit
4042a7d979
@ -43,31 +43,31 @@ void test_addToTreeExpandsTreeCorrectly(void)
|
||||
|
||||
// Checking the Tree without Doubles
|
||||
TEST_ASSERT_NOT_NULL(testRoot);
|
||||
TEST_ASSERT_EQUAL_UINT16(score1, testRoot);
|
||||
TEST_ASSERT_EQUAL(score1, testRoot);
|
||||
TEST_ASSERT_NOT_NULL(testRoot->left);
|
||||
TEST_ASSERT_EQUAL_UINT16(score2, testRoot->left);
|
||||
TEST_ASSERT_EQUAL(score2, testRoot->left);
|
||||
TEST_ASSERT_NOT_NULL(testRoot->right);
|
||||
TEST_ASSERT_EQUAL_UINT16(score3, testRoot->right);
|
||||
TEST_ASSERT_EQUAL(score3, testRoot->right);
|
||||
TEST_ASSERT_NOT_NULL(testRoot->left->left);
|
||||
TEST_ASSERT_EQUAL_UINT16(score4, testRoot->left->left);
|
||||
TEST_ASSERT_EQUAL(score4, testRoot->left->left);
|
||||
TEST_ASSERT_NOT_NULL(testRoot->left->right);
|
||||
TEST_ASSERT_EQUAL_UINT16(score5, testRoot->left->right);
|
||||
TEST_ASSERT_EQUAL(score5, testRoot->left->right);
|
||||
TEST_ASSERT_NOT_NULL(testRoot->right->left);
|
||||
TEST_ASSERT_EQUAL_UINT16(score6, testRoot->right->left);
|
||||
TEST_ASSERT_EQUAL(score6, testRoot->right->left);
|
||||
TEST_ASSERT_NOT_NULL(testRoot->right->right);
|
||||
TEST_ASSERT_EQUAL_UINT16(score7, testRoot->right->right);
|
||||
TEST_ASSERT_EQUAL(score7, testRoot->right->right);
|
||||
|
||||
// Adding Double
|
||||
testRoot = addToTree(testRoot, &score4, sizeof(int), compareIntEntries, NULL);
|
||||
|
||||
TEST_ASSERT_NOT_NULL(testRoot->left->left->left);
|
||||
TEST_ASSERT_EQUAL_UINT16(score4, testRoot->left->left->left);
|
||||
TEST_ASSERT_EQUAL(score4, testRoot->left->left->left);
|
||||
|
||||
// Trying to add Double while Doubles not Permitted
|
||||
testRoot = addToTree(testRoot, &score7, sizeof(int), compareIntEntries, testIsDouble);
|
||||
|
||||
TEST_ASSERT_NULL(testRoot->right->right->left);
|
||||
TEST_ASSERT_EQUAL_UINT16(1, testIsDouble);
|
||||
TEST_ASSERT_EQUAL(1, testIsDouble);
|
||||
|
||||
|
||||
clearTree(testRoot);
|
||||
@ -82,7 +82,46 @@ void test_addToTreeExpandsTreeCorrectly(void)
|
||||
// aditionally tests if the memoryspaces have been cleared
|
||||
void test_clearTreeworksLikeExpected(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;
|
||||
|
||||
|
||||
// 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);
|
||||
|
||||
// Save all Adresses
|
||||
TreeNode *node1 = testRoot->left;
|
||||
TreeNode *node2 = testRoot->left->left;
|
||||
TreeNode *node3 = testRoot->left->right;
|
||||
TreeNode *node4 = testRoot->right;
|
||||
TreeNode *node5 = testRoot->right->left;
|
||||
TreeNode *node6 = testRoot->right->right;
|
||||
TreeNode *node7 = testRoot->left->left->left;
|
||||
|
||||
clearTree(testRoot);
|
||||
|
||||
// Check if everything has been set to NULL
|
||||
TEST_ASSERT_NULL(testRoot);
|
||||
TEST_ASSERT_NULL(node1);
|
||||
TEST_ASSERT_NULL(node2);
|
||||
TEST_ASSERT_NULL(node3);
|
||||
TEST_ASSERT_NULL(node4);
|
||||
TEST_ASSERT_NULL(node5);
|
||||
TEST_ASSERT_NULL(node6);
|
||||
TEST_ASSERT_NULL(node7);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user