Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CPPFLAGS += -I$(CPPUTEST_HOME)/include
- CXXFLAGS += -include $(CPPUTEST_HOME)/include/CppUTest/MemoryLeakDetectorNewMacros.h
- CFLAGS += -include $(CPPUTEST_HOME)/include/CppUTest/MemoryLeakDetectorMallocMacros.h
- LD_LIBRARIES = -L$(CPPUTEST_HOME)/lib -lCppUTest -lCppUTestExt
- all:
- c++ -g -Wall $(CPPFLAGS) $(CXXFLAGS) $(CFLAGS) commonTest.cpp -o commonTest $(LD_LIBRARIES)
- clean:
- rm -rf *.dSYM commonTest
- Undefined symbols for architecture x86_64:
- "_test_common_algos_commonCalloc_wrapper_c", referenced from:
- TEST_common_algos_commonCalloc_Test::testBody() in commonTest-992552.o
- "_test_common_algos_commonMalloc_wrapper_c", referenced from:
- TEST_common_algos_commonMalloc_Test::testBody() in commonTest-992552.o
- "_test_common_algos_commonRealloc_wrapper_c", referenced from:
- TEST_common_algos_commonRealloc_Test::testBody() in commonTest-992552.o
- ld: symbol(s) not found for architecture x86_64
- clang: error: linker command failed with exit code 1 (use -v to see invocation)
- make: *** [all] Error 1
- #include "../common.h"
- #include "CppUTest/TestHarness_c.h"
- void *ptr = NULL;
- int list[10] = {1, 2, 32, 33, 2, 5, 7, 3, 9, 34};
- TEST_GROUP_C_WRAPPER(common_algos)
- {
- };
- TEST_C(common_algos, commonMalloc)
- {
- ptr = malloc_c(6);
- CHECK_EQUAL_C_INT(algos_error, ALGOS_OK);
- strncpy(ptr, "Hello", 5);
- CHECK_EQUAL_C_STRING("Hello", ptr);
- free_c(ptr);
- }
- TEST_C(common_algos, commonCalloc)
- {
- ptr = calloc_c(sizeof(int), 10);
- CHECK_EQUAL_C_INT(algos_error, ALGOS_OK);
- memcpy(ptr, list, sizeof(int)*10);
- for (int i = 0; i < 10; i++)
- CHECK_EQUAL_C_INT(list[i], ptr[i]);
- free_c(ptr);
- }
- TEST_C(common_algos, commonRealloc)
- {
- ptr = malloc_c(10);
- CHECK_EQUAL_C_INT(ALGOS_OK, algos_error);
- memcpy(ptr, list, sizeof(int)*10);
- ptr = realloc_c(ptr, 20);
- CHECK_EQUAL_C_INT(ALGOS_OK, algos_error);
- memcpy(ptr + 10, list, sizeof(int)*10);
- for (int i = 9; i < 19; i++)
- CHECK_EQUAL_C_INT(list[i-9], ptr[i]);
- free_c(ptr);
- }
- #include "CppUTest/CommandLineTestRunner.h"
- #include "CppUTest/TestHarness_c.h"
- TEST_GROUP_C_WRAPPER(common_algos)
- {
- };
- TEST_C_WRAPPER(common_algos, commonMalloc);
- TEST_C_WRAPPER(common_algos, commonCalloc);
- TEST_C_WRAPPER(common_algos, commonRealloc);
- int main(int ac, char **av)
- {
- return RUN_ALL_TESTS(ac, av);
- }
- common
- |______ common.c
- |
- |______ common.h
- |
- |______ test
- |
- |____commonTest.c
- |
- |____commonTest.cpp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement