3 Commits
Author SHA1 Message Date
maysi98860 31a76162ee Merge pull request 'simons_zweig' (#1) from simons_zweig into main
Reviewed-on: #1
2025-11-25 12:55:32 +00:00
Simon 4cfe6d9c50 added test_push and fixed stack cast 2025-11-24 17:53:43 +01:00
Simon 82c72eaf81 first tests 2025-11-24 16:05:31 +01:00
2 changed files with 40 additions and 1 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ StackNode *push(StackNode *stack, void *data)
StackNode *tempNode, *newNode;
newNode = malloc(sizeof(StackNode));
newNode->value = 3;
newNode->value = *(int *)data;
newNode->next = NULL;
if (stack == NULL)
+39
View File
@@ -3,9 +3,45 @@
#include "stack.h"
#include "unity.h"
void test_push(void)
{
StackNode *testNode;
int data = 1;
// Test für leeren Stack
testNode = push(NULL, &data);
TEST_ASSERT_NOT_NULL(&testNode);
TEST_ASSERT_NULL(testNode->next);
TEST_ASSERT_EQUAL_INT(1, testNode->value);
data = 2;
// Test für nicht leeren Stack
testNode = push(testNode, &data);
TEST_ASSERT_NOT_NULL(&testNode);
TEST_ASSERT_NOT_NULL(testNode->next);
TEST_ASSERT_NULL(testNode->next->next);
TEST_ASSERT_EQUAL_INT(1, testNode->value);
TEST_ASSERT_EQUAL_INT(2, testNode->next->value);
}
void test_pop(void)
{
TEST_ASSERT_NULL(pop(NULL));
}
void test_top(void)
{
TEST_ASSERT_NULL(top(NULL));
}
void test_clear(void)
{
// TEST_ASSERT_NULL(clearStack(NULL));
}
void setUp(void) {
@@ -22,7 +58,10 @@ int main()
printf("============================\nStack tests\n============================\n");
RUN_TEST(test_push);
RUN_TEST(test_pop);
RUN_TEST(test_top);
RUN_TEST(test_clear);
return UNITY_END();
}