From 0bc9263b60298cba0f41ade9e34cbbf3dac34411 Mon Sep 17 00:00:00 2001 From: Lukas Weber Date: Wed, 3 Dec 2025 12:07:15 +0100 Subject: [PATCH] Started working on tests, added config to makefile --- makefile | 4 +++- test_stack.c | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 test_stack.c diff --git a/makefile b/makefile index 1f15f75..b94e026 100644 --- a/makefile +++ b/makefile @@ -35,7 +35,9 @@ $(program_obj_filesobj_files): %.o: %.c # -------------------------- # Unit Tests # -------------------------- -unitTests: +stackTests: stack.o test_stack.c $(unityfolder)/unity.c + $(CC) $(CFLAGS) -I$(unityfolder) -o runStackTests test_stack.c stack.o $(unityfolder)/unity.c + echo "needs to be implemented" # -------------------------- diff --git a/test_stack.c b/test_stack.c new file mode 100644 index 0000000..c4fe248 --- /dev/null +++ b/test_stack.c @@ -0,0 +1,27 @@ +#include "stack.h" +#include "unity.h" + + +void test_firstNodeAddedCorrectly(void) { + StackNode* modelStack; + int modelData = 5; + modelStack->below = NULL; + modelStack->data = &modelData; + + StackNode* testStack = NULL; + int testData = 5; + testStack = push(testStack, &testData); + TEST_ASSERT_EQUAL_INT(*(modelStack->data), *(testStack->data)); + TEST_ASSERT_NULL(testStack->below); +} + + +int main(void) { + + UNITY_BEGIN(); + + printf("\n----------------------------Stack-Tests----------------------------\n"); + RUN_TEST(test_firstNodeAddedCorrectly); + + return UNITY_END(); +} \ No newline at end of file