]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/test/doc/examples/example82_contexts.run-fail.cpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / test / doc / examples / example82_contexts.run-fail.cpp
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 example82
10 #include <boost/test/included/unit_test.hpp>
11
12 struct Processor
13 {
14 int level;
15 void optimization_level(int l) { level = l; }
16 bool op1(int) { return level < 2; }
17 bool op2(int, int) { return level < 1; }
18 };
19
20 void test_operations(Processor& processor, int limit)
21 {
22 for (int i = 0; i < limit; ++i) {
23 BOOST_TEST_CONTEXT("With parameter i = " << i) {
24 BOOST_TEST(processor.op1(i));
25 for (int j = 0; j < i; ++j) {
26 BOOST_TEST_INFO("With parameter j = " << j);
27 BOOST_TEST(processor.op2(i, j));
28 }
29 }
30 }
31 }
32
33 BOOST_AUTO_TEST_CASE(test1)
34 {
35 Processor processor;
36
37 for (int level = 0; level < 3; ++level) {
38 BOOST_TEST_CONTEXT("With optimization level " << level) {
39 processor.optimization_level(level);
40 test_operations(processor, 2);
41 }
42 }
43 }
44 //]