| 1 | #include <cgreen/cgreen.h> |
| 2 | |
| 3 | #ifdef __cplusplus |
| 4 | using namespace cgreen; |
| 5 | #endif |
| 6 | |
| 7 | static int counter = 0; |
| 8 | |
| 9 | /* this suite exercises a former crash bug in the reflective runner by not having a teardown */ |
| 10 | Describe(ReflectiveNoTeardownTest); |
| 11 | |
| 12 | BeforeEach(ReflectiveNoTeardownTest) { |
| 13 | counter += 5; |
| 14 | } |
| 15 | |
| 16 | AfterEach(ReflectiveNoTeardownTest) {} |
| 17 | |
| 18 | Ensure(ReflectiveNoTeardownTest, before_called_implicitly_before_each_test) { |
| 19 | assert_that(counter, is_equal_to(5)); |
| 20 | } |
| 21 | |
| 22 | Ensure(ReflectiveNoTeardownTest, second_test_unaffected_by_first) { |
| 23 | assert_that(counter, is_equal_to(5)); |
| 24 | } |
| 25 | |
| 26 | TestSuite *reflective_no_teardown_tests(void) { |
| 27 | TestSuite *suite = create_test_suite(); |
| 28 | |
| 29 | add_test_with_context(suite, ReflectiveNoTeardownTest, before_called_implicitly_before_each_test); |
| 30 | add_test_with_context(suite, ReflectiveNoTeardownTest, second_test_unaffected_by_first); |
| 31 | |
| 32 | return suite; |
| 33 | } |