2 * Created by Phil on 28/01/2011.
3 * Copyright 2011 Two Blue Cubes Ltd. All rights reserved.
5 * Distributed under the Boost Software License, Version 1.0. (See accompanying
6 * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 // This define means we have to prefix all the CATCH macros with CATCH_
10 // We're using it here to test it out
11 #define CATCH_CONFIG_PREFIX_ALL
14 inline int multiply( int a
, int b
)
19 CATCH_TEST_CASE( "Generators over two ranges", "[generators]" )
21 using namespace Catch::Generators
;
23 int i
= CATCH_GENERATE( between( 1, 5 ).then( values( 15, 20, 21 ).then( 36 ) ) );
24 int j
= CATCH_GENERATE( between( 100, 107 ) );
26 CATCH_REQUIRE( multiply( i
, 2 ) == i
*2 );
27 CATCH_REQUIRE( multiply( j
, 2 ) == j
*2 );
30 struct IntPair
{ int first
, second
; };
32 CATCH_TEST_CASE( "Generator over a range of pairs", "[generators]" )
34 using namespace Catch::Generators
;
36 IntPair p
[] = { { 0, 1 }, { 2, 3 } };
38 IntPair
* i
= CATCH_GENERATE( between( p
, &p
[1] ) );
40 CATCH_REQUIRE( i
->first
== i
->second
-1 );