X-Git-Url: https://git.llucax.com/software/mutest.git/blobdiff_plain/6fa3862da83a93a63c025035d8e614eaac4f5cab..cb606e44a187f9ece06dfd134e9ded8cdcf8f1b8:/sample/sum_test.c?ds=inline diff --git a/sample/sum_test.c b/sample/sum_test.c index 7fea630..505f814 100644 --- a/sample/sum_test.c +++ b/sample/sum_test.c @@ -1,9 +1,38 @@ +/* + * This file is part of mutest, a simple micro unit testing framework for C. + * + * mutest was written by Leandro Lucarella and is released + * under the BOLA license, please see the LICENSE file or visit: + * http://blitiri.com.ar/p/bola/ + * + * This is the sum module test suite. It shows how to have multiple test + * suites, test suite initialization and termination, and a test suite that + * succeed. Each (public) function starting with mu_init will be picked up by + * mkmutest as an initialization function and executed unless one fails + * (returns != 0) Functions starting with mu_term will be used as termination + * functions, called after all test cases were executed. Functions starting + * with mu_test will be used as test cases. + * + * Please, read the README file for more details. + */ -/* see factorial_test.c for more complete examples, this file is mostly to show - * how to have multiple test suites, and a test suite that succeed. */ +#include "sum.h" +#include /* malloc(), free() */ +#ifdef MUTEST_PY +#include "../py/mutest.h" +#else #include "../mutest.h" -#include "sum.h" +#endif + +/* unused, just for ilustrate the test suite initialization/termination */ +static char* global; + +int mu_init_sum() { + global = (char*) malloc(1024); + + return 0; /* initialization OK */ +} void mu_test_sum() { mu_check(sum(4, 5) == 9); @@ -12,3 +41,7 @@ void mu_test_sum() { mu_check(sum(1, -1) == 0); } +void mu_term_sum() { + free(global); +} +