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)
6 // See http://www.boost.org/libs/test for the library home page.
9 #define BOOST_TEST_MODULE dataset_example68
10 #include <boost/test/included/unit_test.hpp>
11 #include <boost/test/data/test_case.hpp>
12 #include <boost/test/data/monomorphic.hpp>
15 namespace bdata
= boost::unit_test::data
;
17 // Dataset generating a Fibonacci sequence
18 class fibonacci_dataset
{
20 // Samples type is int
26 iterator() : a(1), b(1) {}
28 int operator*() const { return b
; }
36 int b
; // b is the output
39 fibonacci_dataset() {}
42 bdata::size_t size() const { return bdata::BOOST_TEST_DS_INFINITE_SIZE
; }
45 iterator
begin() const { return iterator(); }
48 namespace boost
{ namespace unit_test
{ namespace data
{ namespace monomorphic
{
49 // registering fibonacci_dataset as a proper dataset
51 struct is_dataset
<fibonacci_dataset
> : boost::mpl::true_
{};
54 // Creating a test-driven dataset
57 fibonacci_dataset() ^ bdata::make( { 1, 2, 3, 5, 8, 13, 21, 35, 56 } ),
60 BOOST_TEST(fib_sample
== exp
);