]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/assign/test/std.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/
12 #include <boost/detail/workaround.hpp>
14 #if BOOST_WORKAROUND(__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
19 #include <boost/assign/std.hpp>
20 #include <boost/test/test_tools.hpp>
25 using namespace boost::assign
;
27 template< typename K
, typename V
>
28 inline pair
<K
,V
> P( K k
, V v
)
30 return make_pair( k
, v
);
35 three( int, int, int ) { }
36 three( const string
&, const string
&, const string
& ) { }
41 four( int, int, int, int ) { }
42 four( const string
&, const string
&, const string
&, const string
& ) { }
47 five( int, int, int, int, int ) { }
48 five( const string
&, const string
&, const string
&,
49 const string
&, const string
& ) { }
55 void test_int_sequence()
59 BOOST_CHECK_EQUAL( c
.size(), 0u );
60 c
+=1,2,3,4,5,6,7,8,9,10;
61 BOOST_CHECK_EQUAL( c
.size(), 10u );
67 void test_string_sequence()
71 BOOST_CHECK_EQUAL( c
.size(), 0u );
72 c
+= "1","2","3","4","5","6","7","8","9","10";
73 BOOST_CHECK_EQUAL( c
.size(), 10u );
78 typedef pair
<string
,int> two_tuple
;
81 void test_tuple_sequence()
85 BOOST_CHECK_EQUAL( c
.size(), 0u );
86 c
+= P("1",1), P("2",2), P("3",3), P("4",4), P("5",5), P("6",6),
87 P("7",7), P("8",8), P("9",9), P("10",10);
88 BOOST_CHECK_EQUAL( c
.size(), 10u );
97 m
+= P( "january", 31 ), P( "february", 28 ),
98 P( "march", 31 ), P( "april", 30 ),
99 P( "may", 31 ), P( "june", 30 ),
100 P( "july", 31 ), P( "august", 31 ),
101 P( "september", 30 ), P( "october", 31 ),
102 P( "november", 30 ), P( "december", 31 );
103 BOOST_CHECK_EQUAL( m
.size(), 12u );
106 ( "january", 31 )( "february", 28 )
107 ( "march", 31 )( "april", 30 )
108 ( "may", 31 )( "june", 30 )
109 ( "july", 31 )( "august", 31 )
110 ( "september", 30 )( "october", 31 )
111 ( "november", 30 )( "december", 31 );
112 BOOST_CHECK_EQUAL( m
.size(), 12u );
119 vector
<three
> v_three
;
123 push_back( v_three
) (1,2,3) ("1","2","3");
124 push_back( v_four
) (1,2,3,4) ("1","2","3","4");
125 push_back( v_five
) (1,2,3,4,5) ("1","2","3","4","5");
126 BOOST_CHECK_EQUAL( v_three
.size(), 2u );
127 BOOST_CHECK_EQUAL( v_four
.size(), 2u );
128 BOOST_CHECK_EQUAL( v_five
.size(), 2u );
136 test_int_sequence
< deque
<int> >();
137 test_int_sequence
< list
<int> >();
138 test_int_sequence
< vector
<int> >();
139 test_int_sequence
< set
<int> >();
140 test_int_sequence
< multiset
<int> >();
141 test_int_sequence
< stack
<int> >();
142 test_int_sequence
< queue
<int> >();
143 test_int_sequence
< priority_queue
<int> >();
145 test_string_sequence
< deque
<string
> >();
146 test_string_sequence
< list
<string
> >();
147 test_string_sequence
< vector
<string
> >();
148 test_string_sequence
< set
<string
> >();
149 test_string_sequence
< multiset
<string
> >();
150 test_string_sequence
< stack
<string
> >();
151 test_string_sequence
< queue
<string
> >();
152 test_string_sequence
< priority_queue
<string
> >();
154 test_tuple_sequence
< deque
<two_tuple
> >();
155 test_tuple_sequence
< list
<two_tuple
> >();
156 test_tuple_sequence
< vector
<two_tuple
> >();
157 test_tuple_sequence
< set
<two_tuple
> >();
158 test_tuple_sequence
< multiset
<two_tuple
> >();
159 test_tuple_sequence
< stack
<two_tuple
> >();
160 test_tuple_sequence
< queue
<two_tuple
> >();
161 test_tuple_sequence
< priority_queue
<two_tuple
> >();
165 push_back( di
)( 1 );
166 push_front( di
)( 2 );
167 BOOST_CHECK_EQUAL( di
[0], 2 );
168 BOOST_CHECK_EQUAL( di
[1], 1 );
171 push_back( li
)( 2 );
172 push_front( li
)( 1 );
173 BOOST_CHECK_EQUAL( li
.front(), 1 );
174 BOOST_CHECK_EQUAL( li
.back(), 2 );
177 push_back( vi
) = 2,3;
178 BOOST_CHECK_EQUAL( vi
[0], 2 );
179 BOOST_CHECK_EQUAL( vi
[1], 3 );
183 BOOST_CHECK_EQUAL( *si
.find( 4 ), 4 );
187 BOOST_CHECK_EQUAL( *msi
.find( 5 ), 5 );
191 BOOST_CHECK_EQUAL( sti
.top(), 6 );
195 BOOST_CHECK_EQUAL( qi
.back(), 7 );
197 priority_queue
<int> pqi
;
199 BOOST_CHECK_EQUAL( pqi
.top(), 8 );
201 test_map
< map
<string
,int> >();
202 test_map
< multimap
<string
,int> >();
208 #include <boost/test/unit_test.hpp>
209 using boost::unit_test::test_suite
;
211 test_suite
* init_unit_test_suite( int argc
, char* argv
[] )
213 test_suite
* test
= BOOST_TEST_SUITE( "List Test Suite" );
215 test
->add( BOOST_TEST_CASE( &check_std
) );