1 // (C) Copyright Eric Niebler 2004.
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 13 December 2004 : Initial version.
9 25 August 2005 : Initial version.
12 #include <boost/test/minimal.hpp>
13 #include <boost/foreach.hpp>
15 ///////////////////////////////////////////////////////////////////////////////
16 // define the container types, used by utility.hpp to generate the helper functions
17 typedef std::pair
<int*,int*> foreach_container_type
;
18 typedef std::pair
<int const*,int const*> const foreach_const_container_type
;
19 typedef int foreach_value_type
;
20 typedef int &foreach_reference_type
;
21 typedef int const &foreach_const_reference_type
;
23 #include "./utility.hpp"
25 ///////////////////////////////////////////////////////////////////////////////
26 // define some containers
28 int my_array
[] = { 1,2,3,4,5 };
29 std::pair
<int*,int*> my_pair(my_array
,my_array
+5);
30 std::pair
<int const*,int const*> const my_const_pair(my_array
,my_array
+5);
32 ///////////////////////////////////////////////////////////////////////////////
35 int test_main( int, char*[] )
37 // non-const containers by reference
38 BOOST_CHECK(sequence_equal_byref_n(my_pair
, "\1\2\3\4\5"));
40 // const containers by reference
41 BOOST_CHECK(sequence_equal_byref_c(my_const_pair
, "\1\2\3\4\5"));
43 // mutate the mutable collections
44 mutate_foreach_byref(my_pair
);
46 // compare the mutated collections to the actual results
47 BOOST_CHECK(sequence_equal_byref_n(my_pair
, "\2\3\4\5\6"));