wrote test_nextTreeDataReturnsNextDataCorrectly()
This commit is contained in:
parent
9d08970513
commit
e4a8afabdd
@ -3,6 +3,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "unity.h"
|
#include "unity.h"
|
||||||
#include "bintree.h"
|
#include "bintree.h"
|
||||||
|
#include "stack.h"
|
||||||
|
|
||||||
#define MAX_TEST_NAME_LEN 10
|
#define MAX_TEST_NAME_LEN 10
|
||||||
|
|
||||||
@ -89,7 +90,42 @@ void test_addToTreeExpandsTreeCorrectly(void)
|
|||||||
// needs Stack!!!
|
// needs Stack!!!
|
||||||
void test_nextTreeDataReturnsNextDataCorrectly(void)
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user