Started working on tests, added config to makefile

This commit is contained in:
Lukas Weber 2025-12-03 12:07:15 +01:00
parent 94e489cfae
commit 0bc9263b60
2 changed files with 30 additions and 1 deletions

View File

@ -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"
# --------------------------

27
test_stack.c Normal file
View File

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