#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(); }