1 #ifndef SEEN_UTEST_TEST_CASES_H
2 #define SEEN_UTEST_TEST_CASES_H
4 #include <utest/utest.h>
7 template<class FArg0, class ValidArg0>
8 struct Case1 {
9 FArg0 f_arg0;
10 ValidArg0 valid_arg0;
11 };
13 /** Often, ValidP can be std::equal_to\<FRet\> (#include \<functional\>), in which case ValidArg0
14 should equal FRet. */
15 template<class FRet, class FArg0, class ValidArg0, class ValidP>
16 static void
17 test_1ary_cases(char const test_name[],
18 FRet (*f)(FArg0),
19 unsigned const ncases, Case1<FArg0, ValidArg0> const cases[])
20 {
21 ValidP valid;
22 UTEST_TEST(test_name) {
23 for(unsigned i = 0; i < ncases; ++i) {
24 Case1<FArg0, ValidArg0> const &c = cases[i];
25 FRet const f_ret(f(c.f_arg0));
26 UTEST_ASSERT(valid(c.valid_arg0, f_ret));
27 }
28 }
29 }
32 #endif /* !SEEN_UTEST_TEST_CASES_H */
34 /*
35 Local Variables:
36 mode:c++
37 c-file-style:"stroustrup"
38 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
39 indent-tabs-mode:nil
40 fill-column:99
41 End:
42 */
43 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :