X-Git-Url: https://git.llucax.com/software/mutest.git/blobdiff_plain/78b63d329c2e3bb185c0b78119ccb5fc5c0781b9..d5be024b1cc1a456cd9726d85a7e108e1818ae7f:/sample/sum_test.c diff --git a/sample/sum_test.c b/sample/sum_test.c index 398ca08..505f814 100644 --- a/sample/sum_test.c +++ b/sample/sum_test.c @@ -1,8 +1,23 @@ - -/* 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. */ +/* + * 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. + */ #include "sum.h" +#include /* malloc(), free() */ #ifdef MUTEST_PY #include "../py/mutest.h" @@ -10,6 +25,15 @@ #include "../mutest.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); mu_check(sum(-4, -5) == -9); @@ -17,3 +41,7 @@ void mu_test_sum() { mu_check(sum(1, -1) == 0); } +void mu_term_sum() { + free(global); +} +