example83_contexts.run-fail.cpp 740 B

12345678910111213141516171819202122232425
  1. // (C) Copyright Raffi Enficiaud 2019.
  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. // See http://www.boost.org/libs/test for the library home page.
  6. //[example_code
  7. #define BOOST_TEST_MODULE example83 multicontext
  8. #include <boost/test/included/unit_test.hpp>
  9. #include <cmath>
  10. BOOST_AUTO_TEST_CASE(test_multi_context)
  11. {
  12. for (int level = 0; level < 10; ++level) {
  13. int rand_value = std::abs(rand()) % 50;
  14. BOOST_TEST_CONTEXT("With level " << level, "Random value=" << rand_value){
  15. for( int j = 1; j < rand_value; j++) {
  16. BOOST_TEST(level < rand_value);
  17. rand_value /= 2;
  18. }
  19. }
  20. }
  21. }
  22. //]