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 6 // See http://www.boost.org/libs/test for the library home page. 7 8 //[example_code 9 #define BOOST_TEST_MODULE dataset_example63 10 #include <boost/test/included/unit_test.hpp> 11 #include <boost/test/data/test_case.hpp> 12 #include <boost/test/data/monomorphic.hpp> 13 14 namespace bdata = boost::unit_test::data; 15 16 17 BOOST_DATA_TEST_CASE( 18 test1, 19 bdata::random(1, 17) ^ bdata::xrange(7), 20 random_sample, index ) 21 { 22 std::cout << "test 1: " << random_sample 23 << ", " << index << std::endl; 24 BOOST_TEST((random_sample <= 17 && random_sample >= 1)); 25 } 26 27 BOOST_DATA_TEST_CASE( 28 test2, 29 bdata::random( (bdata::distribution=std::uniform_real_distribution<float>(1, 2)) ) 30 ^ bdata::xrange(7), 31 random_sample, index ) 32 { 33 std::cout << "test 2: " << random_sample 34 << ", " << index << std::endl; 35 BOOST_TEST(random_sample < 1.7); // 30% chance of failure 36 } 37 //] 38