first tests
This commit is contained in:
parent
a027c070d2
commit
82c72eaf81
3
stack.c
3
stack.c
@ -13,7 +13,8 @@ StackNode *push(StackNode *stack, void *data)
|
|||||||
StackNode *tempNode, *newNode;
|
StackNode *tempNode, *newNode;
|
||||||
|
|
||||||
newNode = malloc(sizeof(StackNode));
|
newNode = malloc(sizeof(StackNode));
|
||||||
newNode->value = 3;
|
newNode->value = (intptr_t) data;
|
||||||
|
//newNode->value = 3;
|
||||||
newNode->next = NULL;
|
newNode->next = NULL;
|
||||||
|
|
||||||
if (stack == NULL)
|
if (stack == NULL)
|
||||||
|
|||||||
23
test_stack.c
23
test_stack.c
@ -3,11 +3,31 @@
|
|||||||
#include "stack.h"
|
#include "stack.h"
|
||||||
#include "unity.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)
|
void test_pop(void)
|
||||||
{
|
{
|
||||||
TEST_ASSERT_NULL(pop(NULL));
|
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) {
|
void setUp(void) {
|
||||||
// Falls notwendig, kann hier Vorbereitungsarbeit gemacht werden
|
// Falls notwendig, kann hier Vorbereitungsarbeit gemacht werden
|
||||||
}
|
}
|
||||||
@ -22,7 +42,10 @@ int main()
|
|||||||
|
|
||||||
printf("============================\nStack tests\n============================\n");
|
printf("============================\nStack tests\n============================\n");
|
||||||
|
|
||||||
|
RUN_TEST(test_push);
|
||||||
RUN_TEST(test_pop);
|
RUN_TEST(test_pop);
|
||||||
|
RUN_TEST(test_top);
|
||||||
|
RUN_TEST(test_clear);
|
||||||
|
|
||||||
return UNITY_END();
|
return UNITY_END();
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user