generated from freudenreichan/info2Praktikum-DobleSpiel
38 lines
857 B
C
38 lines
857 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include "unity/unity.h"
|
|
#include "stack.h"
|
|
|
|
void test_stackOrderIsCorrect()
|
|
{
|
|
int expectedValues[] = {1, 2, 3, 4};
|
|
const unsigned int exprectedLen = sizeof(expectedValues) / sizeof(expectedValues[0]);
|
|
unsigned int observedLen = 0;
|
|
StackNode *stack = NULL;
|
|
|
|
for(int i = 0; i < exprectedLen; i++)
|
|
{
|
|
stack = push(stack, &expectedValues[i]);
|
|
}
|
|
|
|
for(int i = exprectedLen-1; i >= 0 && stack != NULL; i--)
|
|
{
|
|
TEST_ASSERT_EQUAL(expectedValues[i], *(int *)top(stack));
|
|
observedLen++;
|
|
stack = pop(stack);
|
|
}
|
|
TEST_ASSERT_EQUAL_UINT32(exprectedLen, observedLen);
|
|
|
|
clearStack(stack);
|
|
}
|
|
|
|
void setUp(void) {}
|
|
void tearDown(void) {}
|
|
|
|
int main(void)
|
|
{
|
|
UNITY_BEGIN();
|
|
RUN_TEST(test_stackOrderIsCorrect);
|
|
return UNITY_END();
|
|
} |