stacktest überarbeitet
This commit is contained in:
parent
09d7f457dd
commit
57f9914e2b
27
test_stack.c
27
test_stack.c
@ -75,11 +75,12 @@ void test_deleteTopElement(void) {
|
||||
stack = push(stack, &testInts[i]);
|
||||
}
|
||||
|
||||
TEST_ASSERT_EQUAL_PTR(&testInts[2], stack->data);
|
||||
TEST_ASSERT_EQUAL_PTR(&testInts[2], stack->data); // oberstes Element ist 30
|
||||
|
||||
stack = pop(stack);
|
||||
stack = pop(stack); // oberstes Element löschen
|
||||
TEST_ASSERT_EQUAL_PTR(&testInts[1], stack->data);
|
||||
TEST_ASSERT_NULL(stack->prev);
|
||||
TEST_ASSERT_NULL(
|
||||
stack->prev); // pointer zum alten head wurde auf NULL gesetzt
|
||||
|
||||
stack = pop(stack);
|
||||
TEST_ASSERT_EQUAL_PTR(&testInts[0], stack->data);
|
||||
@ -98,20 +99,16 @@ void test_returnData(void) {
|
||||
stack = push(stack, &testInts[i]);
|
||||
}
|
||||
|
||||
TEST_ASSERT_EQUAL_PTR(&testInts[2], top(stack));
|
||||
TEST_ASSERT_EQUAL_PTR(&testInts[2],
|
||||
top(stack)); // top gibt richtige Adresse zurück
|
||||
stack = pop(stack); // oberstes Element löschen
|
||||
TEST_ASSERT_EQUAL_PTR(&testInts[1], top(stack));
|
||||
|
||||
if (stack->next != NULL) {
|
||||
TEST_ASSERT_EQUAL_PTR(&testInts[1], stack->next->data);
|
||||
if (stack->next->next != NULL) {
|
||||
TEST_ASSERT_EQUAL_PTR(&testInts[0], stack->next->next->data);
|
||||
}
|
||||
}
|
||||
stack = pop(stack);
|
||||
TEST_ASSERT_EQUAL_PTR(&testInts[0], top(stack));
|
||||
|
||||
StackNode *last = stack;
|
||||
while (last->next != NULL) {
|
||||
last = last->next;
|
||||
}
|
||||
TEST_ASSERT_NULL(last->next);
|
||||
stack = pop(stack); // bei leerem Stack wird NULL zurückgegeben
|
||||
TEST_ASSERT_NULL(stack);
|
||||
}
|
||||
|
||||
void test_clearStack(void) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user