File: reflective_tests.c

package info (click to toggle)
cgreen 1.6.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,588 kB
  • sloc: ansic: 12,276; sh: 558; makefile: 474; cpp: 403; python: 181; xml: 33; sed: 13
file content (33 lines) | stat: -rw-r--r-- 741 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <cgreen/cgreen.h>
#ifdef __cplusplus
using namespace cgreen;
#endif

static int counter = 0;

Describe(ReflectiveRunner);

BeforeEach(ReflectiveRunner) {
    counter += 5;
}

AfterEach(ReflectiveRunner) {
    counter += 1;
}

Ensure(ReflectiveRunner, calls_setup_before_each_test) {
    assert_that(counter, is_equal_to(5));
}

Ensure(ReflectiveRunner, running_first_test_does_not_affect_second_test) {
    assert_that(counter, is_equal_to(5));
}

TestSuite *reflective_tests(void) {
    TestSuite *suite = create_test_suite();

    add_test_with_context(suite, ReflectiveRunner, calls_setup_before_each_test);
    add_test_with_context(suite, ReflectiveRunner, running_first_test_does_not_affect_second_test);

    return suite;
}