]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/assign/test/array.cpp
1 // Boost.Assign library
3 // Copyright Thorsten Ottosen 2003-2004. Use, modification and
4 // distribution is subject to the Boost Software License, Version
5 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 // For more information, see http://www.boost.org/libs/assign/
11 #include <boost/detail/workaround.hpp>
13 #if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x564) )
14 # pragma warn -8091 // suppress warning in Boost.Test
15 # pragma warn -8057 // unused argument argc/argv in Boost.Test
18 #include <boost/assign/list_of.hpp>
19 #include <boost/array.hpp>
20 #include <boost/test/test_tools.hpp>
30 using namespace boost
;
31 using namespace boost::assign
;
33 typedef array
<float,6> Array
;
36 #if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
37 Array a
= list_of(1)(2)(3)(4)(5)(6).to_array(a
);
39 Array a
= list_of(1)(2)(3)(4)(5)(6);
42 BOOST_CHECK_EQUAL( a
[0], 1 );
43 BOOST_CHECK_EQUAL( a
[5], 6 );
44 // last element is implicitly 0
45 #if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
46 Array a2
= list_of(1)(2)(3)(4)(5).to_array(a2
);
48 Array a2
= list_of(1)(2)(3)(4)(5);
50 BOOST_CHECK_EQUAL( a2
[5], 0 );
51 // two last elements are implicitly
52 #if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
53 a2
= list_of(1))(2)(3)(4).to_array(a2
);
55 a2
= list_of(1)(2)(3)(4);
57 BOOST_CHECK_EQUAL( a2
[4], 0 );
58 BOOST_CHECK_EQUAL( a2
[5], 0 );
60 #if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
62 BOOST_CHECK_THROW( a2
= list_of(1)(2)(3)(4)(5)(6)(6).to_array(a2
),
63 assignment_exception
);
65 BOOST_CHECK_THROW( a2
= list_of(1)(2)(3)(4)(5)(6)(7), assignment_exception
);
72 #include <boost/test/unit_test.hpp>
73 using boost::unit_test::test_suite
;
76 test_suite
* init_unit_test_suite( int argc
, char* argv
[] )
78 test_suite
* test
= BOOST_TEST_SUITE( "List Test Suite" );
80 test
->add( BOOST_TEST_CASE( &check_array
) );