dataset_example63.run-fail.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // (C) Copyright Raffi Enficiaud 2014.
  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 dataset_example63
  8. #include <boost/test/included/unit_test.hpp>
  9. #include <boost/test/data/test_case.hpp>
  10. #include <boost/test/data/monomorphic.hpp>
  11. namespace bdata = boost::unit_test::data;
  12. BOOST_DATA_TEST_CASE(
  13. test1,
  14. bdata::random(1, 17) ^ bdata::xrange(7),
  15. random_sample, index )
  16. {
  17. std::cout << "test 1: " << random_sample
  18. << ", " << index << std::endl;
  19. BOOST_TEST((random_sample <= 17 && random_sample >= 1));
  20. }
  21. BOOST_DATA_TEST_CASE(
  22. test2,
  23. bdata::random( (bdata::distribution=std::uniform_real_distribution<float>(1, 2)) )
  24. ^ bdata::xrange(7),
  25. random_sample, index )
  26. {
  27. std::cout << "test 2: " << random_sample
  28. << ", " << index << std::endl;
  29. BOOST_TEST(random_sample < 1.7); // 30% chance of failure
  30. }
  31. //]