setup first test for bintree.c
This commit is contained in:
parent
fd51eef1fe
commit
ab71a3dd74
5
makefile
5
makefile
@ -36,11 +36,16 @@ $(program_obj_filesobj_files): %.o: %.c
|
||||
# Unit Tests
|
||||
# --------------------------
|
||||
TEST_STACK_SOURCES = stack.c test_stack.c $(unityfolder)/unity.c
|
||||
TEST_BINTREE_SOURCES = bintree.c test_bintree.c stack.c $(unityfolder)/unity.c
|
||||
|
||||
stackTests: $(TEST_STACK_SOURCES) stack.h
|
||||
$(CC) $(FLAGS) -I$(unityfolder) $(TEST_STACK_SOURCES) -o runStackTests
|
||||
./runStackTests
|
||||
|
||||
bintreeTests: $(TEST_BINTREE_SOURCES) stack.h bintree.h
|
||||
$(CC) $(FLAGS) -I$(unityfolder) $(TEST_BINTREE_SOURCES) -o runBintreeTests
|
||||
./runBintreeTests
|
||||
|
||||
# --------------------------
|
||||
# Clean
|
||||
# --------------------------
|
||||
|
||||
39
test_bintree.c
Normal file
39
test_bintree.c
Normal file
@ -0,0 +1,39 @@
|
||||
#include "unity.h"
|
||||
#include "bintree.h"
|
||||
#include "string.h"
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
// set stuff up here
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
// set stuff up here
|
||||
}
|
||||
|
||||
// this adds some strings and checks if they are returned in the right order
|
||||
void test_insert_and_retrieve(void)
|
||||
{
|
||||
char *data1 = "a_this";
|
||||
char *data2 = "b_is";
|
||||
char *data3 = "c_testdata";
|
||||
|
||||
TreeNode *root = addToTree(NULL, data1, strlen(data1) + 1, (CompareFctType)&strcmp, NULL);
|
||||
addToTree(root, data2, strlen(data2) + 1, (CompareFctType)&strcmp, NULL);
|
||||
addToTree(root, data3, strlen(data3) + 1, (CompareFctType)&strcmp, NULL);
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING(data1, (char *)nextTreeData(root));
|
||||
TEST_ASSERT_EQUAL_STRING(data2, (char *)nextTreeData(NULL));
|
||||
TEST_ASSERT_EQUAL_STRING(data3, (char *)nextTreeData(NULL));
|
||||
|
||||
clearTree(root);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("============================\nBintree tests\n============================\n");
|
||||
UNITY_BEGIN();
|
||||
RUN_TEST(test_insert_and_retrieve);
|
||||
return UNITY_END();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user