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 25 August 2005 : Initial version.
11 #include <boost/test/minimal.hpp>
12 #include <boost/foreach.hpp>
14 ///////////////////////////////////////////////////////////////////////////////
15 // define the container types, used by utility.hpp to generate the helper functions
16 typedef int foreach_container_type
[5];
17 typedef int const foreach_const_container_type
[5];
18 typedef int foreach_value_type
;
19 typedef int &foreach_reference_type
;
20 typedef int const &foreach_const_reference_type
;
22 #include "./utility.hpp"
24 ///////////////////////////////////////////////////////////////////////////////
25 // define some containers
27 int my_array
[5] = { 1,2,3,4,5 };
28 int const (&my_const_array
)[5] = my_array
;
30 ///////////////////////////////////////////////////////////////////////////////
33 int test_main( int, char*[] )
35 // non-const containers by reference
36 BOOST_CHECK(sequence_equal_byref_n(my_array
, "\1\2\3\4\5"));
38 // const containers by reference
39 BOOST_CHECK(sequence_equal_byref_c(my_const_array
, "\1\2\3\4\5"));
41 // mutate the mutable collections
42 mutate_foreach_byref(my_array
);
44 // compare the mutated collections to the actual results
45 BOOST_CHECK(sequence_equal_byref_n(my_array
, "\2\3\4\5\6"));