generated from freudenreichan/info2Praktikum-DobleSpiel
Third test working now, everything should be ready for merge to main
This commit is contained in:
parent
bf4c41b897
commit
288385a220
35
test_stack.c
35
test_stack.c
@ -42,6 +42,40 @@ void test_topReturnsCorrectValues(void) {
|
||||
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);
|
||||
clearStack(testStack);
|
||||
}
|
||||
|
||||
void setUp(void) {
|
||||
|
||||
}
|
||||
@ -57,6 +91,7 @@ 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