## page was renamed from cunit = cunit = http://cunit.sourceforge.net/ A Unit Testing Framework for C == SlackBuild == {{{#!highlight sh cd /tmp wget http://slackbuilds.org/slackbuilds/14.1/development/cunit.tar.gz tar xvzf cunit.tar.gz cd cunit wget http://sourceforge.net/projects/cunit/files/CUnit/2.1-3/CUnit-2.1-3.tar.bz2 ./cunit.SlackBuild installpkg /tmp/cunit-2.1_3-i486-1_SBo.tgz }}} == Sample test == {{{#!highlight sh man CUnit }}} Compile cc {{{#!highlight sh cunitSample.c -o cunitSample -lcunit }}} === cunitSample.c === {{{#!highlight c /* * cc cunitSample.c -o cunitSample -lcunit * ./cunitSample */ #include int sum(int a,int b){ return a+b+1; } void testSum(void){ CU_ASSERT(5 == sum(2,3) ); } int init_suite(void){ return 0; } int clean_suite(void){ return 0; } int main() { CU_pSuite pSuite = NULL; /* initialize the CUnit test registry */ if (CUE_SUCCESS != CU_initialize_registry()) return CU_get_error(); /* add a suite to the registry */ pSuite = CU_add_suite("Suite", init_suite, clean_suite); if (NULL == pSuite) { CU_cleanup_registry(); return CU_get_error(); } /* add the tests to the suite */ if (NULL == CU_add_test(pSuite, "test of sum()", testSum)) { CU_cleanup_registry(); return CU_get_error(); } /* Run all tests using the CUnit Basic interface */ CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); CU_cleanup_registry(); return CU_get_error(); } }}}