stack.c
This commit is contained in:
parent
17f4155891
commit
90612e4d04
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
doble_initial.exe
|
||||
BIN
runTests.exe
Normal file
BIN
runTests.exe
Normal file
Binary file not shown.
59
test_stack.c
Normal file
59
test_stack.c
Normal file
@ -0,0 +1,59 @@
|
||||
#include "unity.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "stack.h"
|
||||
|
||||
void test_createNode(void) {
|
||||
|
||||
int testInt = 26;
|
||||
|
||||
StackNode *testNode = createNode(&testInt);
|
||||
|
||||
TEST_ASSERT_NOT_NULL(testNode);
|
||||
|
||||
TEST_ASSERT_EQUAL_PTR(&testInt, testNode->data);
|
||||
|
||||
TEST_ASSERT_NULL(testNode->next);
|
||||
|
||||
free(testNode);
|
||||
}
|
||||
|
||||
void test_pushDataToStack(void) {}
|
||||
|
||||
void test_deleteTopElement(void) {}
|
||||
|
||||
void test_returnData(void) {}
|
||||
|
||||
void test_clearStack(void) {
|
||||
|
||||
int testInts[] = {1, 2, 3, 4, 5};
|
||||
StackNode *testStack = NULL;
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
|
||||
testStack = push(testStack, &testInts[i]);
|
||||
}
|
||||
|
||||
testStack = clearStack(testStack);
|
||||
TEST_ASSERT_NULL(testStack);
|
||||
}
|
||||
|
||||
void setUp(void) {}
|
||||
void tearDown(void) {}
|
||||
|
||||
int main(void) {
|
||||
|
||||
UNITY_BEGIN();
|
||||
|
||||
printf("------------------------stack test------------------------\n");
|
||||
RUN_TEST(test_createNode);
|
||||
RUN_TEST(test_pushDataToStack);
|
||||
RUN_TEST(test_deleteTopElement);
|
||||
RUN_TEST(test_returnData);
|
||||
RUN_TEST(test_clearStack);
|
||||
RUN_TEST(test_clearStack);
|
||||
|
||||
return UNITY_END();
|
||||
}
|
||||
BIN
test_stack.o
Normal file
BIN
test_stack.o
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user