| 1 | #include <cgreen/cgreen.h> |
| 2 | |
| 3 | #ifdef __cplusplus |
| 4 | using namespace cgreen; |
| 5 | #endif |
| 6 | |
| 7 | // This funciton exemplifies infrastructure common between multiple suits |
| 8 | static int common_func_btw_SUTs(void) { |
| 9 | return 0; |
| 10 | } |
| 11 | |
| 12 | // Suite A and its unit test |
| 13 | Describe(SuiteA); |
| 14 | BeforeEach(SuiteA) {} |
| 15 | AfterEach(SuiteA) {} |
| 16 | |
| 17 | Ensure(SuiteA, ut_a) { |
| 18 | int num = common_func_btw_SUTs(); |
| 19 | assert_that(num, is_equal_to(0)); |
| 20 | } |
| 21 | |
| 22 | // Suite B and its unit test |
| 23 | Describe(SuiteB); |
| 24 | BeforeEach(SuiteB) {} |
| 25 | AfterEach(SuiteB) {} |
| 26 | |
| 27 | Ensure(SuiteB, ut_b) { |
| 28 | int num = common_func_btw_SUTs(); |
| 29 | assert_that(num, is_equal_to(0)); |
| 30 | } |
| 31 | |
| 32 | TestSuite *test_suite_a(void) { |
| 33 | TestSuite *suite = create_test_suite(); |
| 34 | add_test_with_context(suite, SuiteA, ut_a); |
| 35 | run_test_suite(suite, create_text_reporter()); |
| 36 | return suite; |
| 37 | } |
| 38 | |
| 39 | TestSuite *test_suite_b(void) { |
| 40 | TestSuite *suite = create_test_suite(); |
| 41 | add_test_with_context(suite, SuiteB, ut_b); |
| 42 | run_test_suite(suite, create_text_reporter()); |
| 43 | return suite; |
| 44 | } |