]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // (C) Copyright Andrzej Krzemienski 2015. |
2 | // Distributed under the Boost Software License, Version 1.0. | |
3 | // (See accompanying file LICENSE_1_0.txt or copy at | |
4 | // http://www.boost.org/LICENSE_1_0.txt) | |
5 | ||
6 | // See http://www.boost.org/libs/test for the library home page. | |
7 | ||
8 | //[example_code | |
9 | #define BOOST_TEST_MODULE decorator_08 | |
10 | #include <boost/test/included/unit_test.hpp> | |
11 | namespace utf = boost::unit_test; | |
12 | namespace tt = boost::test_tools; | |
13 | ||
14 | BOOST_AUTO_TEST_CASE(test1) | |
15 | { | |
16 | BOOST_TEST(true); | |
17 | } | |
18 | ||
19 | BOOST_AUTO_TEST_CASE(test2) | |
20 | { | |
21 | BOOST_TEST(false); | |
22 | } | |
23 | ||
24 | struct if_either | |
25 | { | |
26 | std::string tc1, tc2; | |
27 | if_either(std::string t1, std::string t2) | |
28 | : tc1(t1), tc2(t2) {} | |
29 | ||
30 | tt::assertion_result operator()(utf::test_unit_id) | |
31 | { | |
32 | auto& master = utf::framework::master_test_suite(); | |
33 | auto& collector = utf::results_collector_t::instance(); | |
34 | auto& test1_result = collector.results(master.get(tc1)); | |
35 | auto& test2_result = collector.results(master.get(tc2)); | |
36 | ||
37 | if (test1_result.passed() || test2_result.passed()) | |
38 | return true; | |
39 | ||
40 | tt::assertion_result ans(false); | |
41 | ans.message() << tc1 << " and " << tc2 << " failed"; | |
42 | return ans; | |
43 | } | |
44 | }; | |
45 | ||
46 | BOOST_AUTO_TEST_CASE(test3, | |
47 | * utf::precondition(if_either("test1", "test2"))) | |
48 | { | |
49 | BOOST_TEST(false); | |
50 | } | |
51 | ||
52 | BOOST_AUTO_TEST_CASE(test4, | |
53 | * utf::precondition(if_either("test2", "test3"))) | |
54 | { | |
55 | BOOST_TEST(false); | |
56 | } | |
57 | //] |