#include #include #include #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(); }