1 | // Boost.Assign library |
2 | // |
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) |
7 | // |
8 | // For more information, see http://www.boost.org/libs/assign/ |
9 | // |
10 | |
11 | |
12 | #include <boost/detail/workaround.hpp> |
13 | |
14 | #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) |
15 | # pragma warn -8091 // suppress warning in Boost.Test |
16 | # pragma warn -8057 // unused argument argc/argv in Boost.Test |
17 | #endif |
18 | |
19 | #include <boost/assign/list_of.hpp> |
20 | #include <boost/test/test_tools.hpp> |
21 | #include <algorithm> |
22 | #include <iostream> |
23 | #include <string> |
24 | #include <vector> |
25 | #include <map> |
26 | |
27 | void check_tuple_list_of() |
28 | { |
29 | using namespace boost::assign; |
30 | |
31 | typedef boost::tuple<int,std::string,int> tuple; |
32 | |
33 | std::vector<tuple> v = tuple_list_of( u: 1, us: "foo" , us: 2 )( 3, "bar" , 4 ); |
34 | BOOST_CHECK( v.size() == 2 ); |
35 | BOOST_CHECK( boost::get<0>( v[1] ) == 3 ); |
36 | |
37 | std::map<std::string,int> m = pair_list_of( f: "foo" , s: 3 )( "bar" , 5 ); |
38 | BOOST_CHECK( m.size() == 2 ); |
39 | BOOST_CHECK( m["foo" ] == 3 ); |
40 | } |
41 | |
42 | #include <boost/test/unit_test.hpp> |
43 | using boost::unit_test::test_suite; |
44 | |
45 | test_suite* init_unit_test_suite( int argc, char* argv[] ) |
46 | { |
47 | test_suite* test = BOOST_TEST_SUITE( "List Test Suite" ); |
48 | |
49 | test->add( BOOST_TEST_CASE( &check_tuple_list_of ) ); |
50 | |
51 | return test; |
52 | } |
53 | |
54 | |
55 | |