first tests

This commit is contained in:
Simon 2025-11-24 16:05:31 +01:00
parent a027c070d2
commit 82c72eaf81
2 changed files with 25 additions and 1 deletions

View File

@ -13,7 +13,8 @@ StackNode *push(StackNode *stack, void *data)
StackNode *tempNode, *newNode;
newNode = malloc(sizeof(StackNode));
newNode->value = 3;
newNode->value = (intptr_t) data;
//newNode->value = 3;
newNode->next = NULL;
if (stack == NULL)

View File

@ -3,11 +3,31 @@
#include "stack.h"
#include "unity.h"
void test_push(void)
{
int value = 3;
TEST_ASSERT_NOT_NULL(push(NULL, &value));
TEST_ASSERT_EQUAL_INT(value, (intptr_t) push(NULL, &value)->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) {
// Falls notwendig, kann hier Vorbereitungsarbeit gemacht werden
}
@ -22,7 +42,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();
}