Debian Codegraph @

tests/api/core_api.c

raw symbols SCIP
1 #include <cgreen/cgreen.h>
2 #include <cgreen/mocks.h>
3
4 /*
5 These tests are only an attempt to exercise the whole public API of
6 Cgreen to ensure that it compiles. Attempting to run them will
7 surely result in crashes, plagues and pestilence. For unit tests
8 see other tests. */
9
10 #ifdef __cplusplus
11 using namespace cgreen;
12 #endif
13
14 // ASSERT
15 Ensure(assert_that_compiles) {
16 assert_that(1 == 1);
17 assert_that(1 == 1, is_true);
18 assert_that_double(1, is_equal_to(1));
19 significant_figures_for_assert_double_are(3);
20 }
21
22 // CONSTRAINTS
23 Ensure(constraints_compiles) {
24 char array[5];
25 char *string = (char *)"some string";
26
27 assert_that(1, is_equal_to(1));
28 assert_that(1, is_not_equal_to(1));
29 assert_that(1, is_greater_than(1));
30 assert_that(1, is_less_than(1));
31
32 assert_that(array, is_equal_to_contents_of(array, 5));
33 assert_that(array, is_not_equal_to_contents_of(array, 3));
34
35 assert_that(string, is_equal_to_string(string));
36 assert_that(string, is_not_equal_to_string(string));
37 assert_that(string, contains_string(string));
38 assert_that(string, does_not_contain_string(string));
39 assert_that(string, begins_with_string(string));
40 }
41
42 static int int_stub(int parameter) {
43 return mock(parameter);
44 }
45
46 // Mocks
47 Ensure(mocks_compiles) {
48 always_expect(int_stub, will_return(1));
49 always_expect(int_stub, will_set_contents_of_output_parameter(parameter, 1, sizeof(int)));
50 never_expect(int_stub);
51 expect(int_stub, when(parameter, is_equal_to(1)));
52 int_stub(1);
53 }