#include "unity.h" #include "stack.h" int data1 = 10; int data2 = 20; int data3 = 30; StackNode *stack = NULL; void setUp(void) { // set stuff up here } void tearDown(void) { clearStack(stack); } void test_push_and_pop(void) { stack = push(stack, &data1); stack = push(stack, &data2); stack = push(stack, &data3); TEST_ASSERT_EQUAL_PTR(top(stack), &data3); stack = pop(stack); TEST_ASSERT_EQUAL_PTR(top(stack), &data2); stack = pop(stack); TEST_ASSERT_EQUAL_PTR(top(stack), &data1); stack = pop(stack); } void test_handle_NULL(void) { TEST_ASSERT_NULL(pop(stack)); TEST_ASSERT_NULL(top(stack)); } int main(void) { printf("============================\nStack tests\n============================\n"); UNITY_BEGIN(); RUN_TEST(test_push_and_pop); RUN_TEST(test_handle_NULL); return UNITY_END(); }