generated from freudenreichan/info2Praktikum-DobleSpiel
Compare commits
No commits in common. "288385a2200343e38d90e1a25197000cce82ff12" and "c663833b6e6f0c9448a3a5378aefc74e52f12807" have entirely different histories.
288385a220
...
c663833b6e
50
test_stack.c
50
test_stack.c
@ -22,57 +22,14 @@ void test_topReturnsCorrectValues(void) {
|
||||
printf("Starting second test...\n");
|
||||
StackNode* testStack = NULL;
|
||||
int data1 = 1;
|
||||
testStack = push(testStack, &data1);
|
||||
int* returnData1 = (int*) top(testStack);
|
||||
int data2 = 0;
|
||||
testStack = push(testStack, &data2);
|
||||
int* returnData2 = (int*) top(testStack);
|
||||
int data3 = 3;
|
||||
testStack = push(testStack, &data3);
|
||||
int* returnData3 = (int*) top(testStack);
|
||||
|
||||
size_t counter = 0;
|
||||
if(*returnData1 == 1)
|
||||
counter++;
|
||||
if(*returnData2 == 0)
|
||||
counter++;
|
||||
if(*returnData3 == 3)
|
||||
counter++;
|
||||
TEST_ASSERT_EQUAL_INT(3, counter);
|
||||
clearStack(testStack);
|
||||
}
|
||||
|
||||
void test_popRemovesCorrectly(void) {
|
||||
printf("Starting third test...\n");
|
||||
StackNode* testStack = NULL;
|
||||
int data1 = 1;
|
||||
testStack = push(testStack, &data1);
|
||||
int data2 = 0;
|
||||
testStack = push(testStack, &data2);
|
||||
int data3 = 3;
|
||||
testStack = push(testStack, &data3);
|
||||
int data4 = 9;
|
||||
testStack = push(testStack, &data4);
|
||||
|
||||
int* returnData1 = (int*) top(testStack);
|
||||
testStack = pop(testStack);
|
||||
int* returnData2 = (int*) top(testStack);
|
||||
testStack = pop(testStack);
|
||||
int* returnData3 = (int*) top(testStack);
|
||||
testStack = pop(testStack);
|
||||
int* returnData4 = (int*) top(testStack);
|
||||
testStack = pop(testStack);
|
||||
|
||||
size_t counter = 0;
|
||||
if(*returnData1 == 9)
|
||||
counter++;
|
||||
if(*returnData2 == 3)
|
||||
counter++;
|
||||
if(*returnData3 == 0)
|
||||
counter++;
|
||||
if(*returnData4 == 1)
|
||||
counter++;
|
||||
TEST_ASSERT_EQUAL_INT(4, counter);
|
||||
TEST_ASSERT_EQUAL_INT(1, *(int*)testStack->stackData);
|
||||
TEST_ASSERT_EQUAL_INT(0, *(int*)testStack->stackData);
|
||||
TEST_ASSERT_EQUAL_INT(3, *(int*)testStack->stackData);
|
||||
clearStack(testStack);
|
||||
}
|
||||
|
||||
@ -91,7 +48,6 @@ int main(void) {
|
||||
printf("\n----------------------------Stack-Tests----------------------------\n");
|
||||
RUN_TEST(test_firstNodeAddedCorrectly);
|
||||
RUN_TEST(test_topReturnsCorrectValues);
|
||||
RUN_TEST(test_popRemovesCorrectly);
|
||||
|
||||
return UNITY_END();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user