91 For parameterized testing you can define and call test subroutines. |
91 For parameterized testing you can define and call test subroutines. |
92 It is _not_ possible to call arbitrary functions and use the `CX_TEST_ASSERT` macro. |
92 It is _not_ possible to call arbitrary functions and use the `CX_TEST_ASSERT` macro. |
93 Instead, you define a callable test subroutine with `CX_TEST_SUBROUTINE` and call it with `CX_TEST_CALL_SUBROUTINE`. |
93 Instead, you define a callable test subroutine with `CX_TEST_SUBROUTINE` and call it with `CX_TEST_CALL_SUBROUTINE`. |
94 The following example illustrates this with an adaption of the above test case. |
94 The following example illustrates this with an adaption of the above test case. |
95 |
95 |
96 <code-block lang="C"><![CDATA[ |
96 ```c |
97 CX_TEST_SUBROUTINE(test_foo_params, struct mystruct *x, int d) { |
97 CX_TEST_SUBROUTINE(test_foo_params, struct mystruct *x, int d) { |
98 x->d = d; |
98 x->d = d; |
99 CX_TEST_ASSERT(foo(x) == d); |
99 CX_TEST_ASSERT(foo(x) == d); |
100 } |
100 } |
101 |
101 |
106 CX_TEST_CALL_SUBROUTINE(test_foo_params, x, -42); |
106 CX_TEST_CALL_SUBROUTINE(test_foo_params, x, -42); |
107 CX_TEST_CALL_SUBROUTINE(test_foo_params, x, 1337); |
107 CX_TEST_CALL_SUBROUTINE(test_foo_params, x, 1337); |
108 } |
108 } |
109 free(x); |
109 free(x); |
110 } |
110 } |
111 ]]></code-block> |
111 ``` |
112 |
112 |
113 > Any test function, test case or test subroutine, is a normal C function. |
113 > Any test function, test case or test subroutine, is a normal C function. |
114 > As such you can decide to make them `static` when you do not want external linkage. |
114 > As such you can decide to make them `static` when you do not want external linkage. |
115 > For example, just define the test as `static CX_TEST(test_foo)` instead of `CX_TEST(test_foo)`. |
115 > For example, just define the test as `static CX_TEST(test_foo)` instead of `CX_TEST(test_foo)`. |
116 |
116 |