67 lines
1.2 KiB
C
67 lines
1.2 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#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) {
|
|
// Falls notwendig, kann hier Vorbereitungsarbeit gemacht werden
|
|
}
|
|
|
|
void tearDown(void) {
|
|
// Hier kann Bereinigungsarbeit nach jedem Test durchgeführt werden
|
|
}
|
|
|
|
int main()
|
|
{
|
|
UNITY_BEGIN();
|
|
|
|
printf("============================\nStack tests\n============================\n");
|
|
|
|
RUN_TEST(test_push);
|
|
RUN_TEST(test_pop);
|
|
RUN_TEST(test_top);
|
|
RUN_TEST(test_clear);
|
|
|
|
return UNITY_END();
|
|
} |