Debian Codegraph @

doc/tutorial_src/custom_constraint1.c

raw symbols SCIP
1 #include <cgreen/cgreen.h>
2 #include <cgreen/message_formatting.h>
3 #include "constraint_internal.h"
4
5 Describe(TestConstraint);
6 BeforeEach(TestConstraint) {}
7 AfterEach(TestConstraint) {}
8
9 bool compare_want_greater_than_5(Constraint *constraint, CgreenValue actual) {
10 return actual.value.integer_value > 5;
11 }
12
13 Constraint static_is_bigger_than_5 = {
14 /* .type */ CGREEN_VALUE_COMPARER_CONSTRAINT,
15 /* .name */ "be bigger than 5",
16 /* .destroy */ destroy_static_constraint,
17 /* .compare */ compare_want_greater_than_5,
18 /* .test */ test_want,
19 /* .format_failure_message_for */ failure_message_for,
20 /* .actual_value_message */ "",
21 /* .expected_value_message */ "",
22 /* .expected_value */ {CGREEN_INTEGER, {5}},
23 /* .stored_value_name */ "null",
24 /* .parameter_name */ NULL,
25 /* .size_of_stored_value */ 0
26 };
27
28 Ensure(TestConstraint, custom_constraint_using_static_function) {
29 Constraint * is_bigger_than_5 = &static_is_bigger_than_5;
30 assert_that(10, is_bigger_than_5);
31 }
32
33 int main(int argc, char **argv) {
34 TestSuite *suite = create_test_suite();
35 add_test_with_context(suite, TestConstraint, custom_constraint_using_static_function);
36 run_test_suite(suite, create_text_reporter());
37 }