]>
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(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
19 #include <boost/assign/std.hpp>
20 #include <boost/test/test_tools.hpp>
33 using std::priority_queue
;
37 using namespace boost::assign
;
39 template< typename K
, typename V
>
40 inline pair
<K
,V
> P( K k
, V v
)
42 return make_pair( k
, v
);
47 three( int, int, int ) { }
48 three( const string
&, const string
&, const string
& ) { }
53 four( int, int, int, int ) { }
54 four( const string
&, const string
&, const string
&, const string
& ) { }
59 five( int, int, int, int, int ) { }
60 five( const string
&, const string
&, const string
&,
61 const string
&, const string
& ) { }
67 void test_int_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 );
79 void test_string_sequence()
83 BOOST_CHECK_EQUAL( c
.size(), 0u );
84 c
+= "1","2","3","4","5","6","7","8","9","10";
85 BOOST_CHECK_EQUAL( c
.size(), 10u );
90 typedef pair
<string
,int> two_tuple
;
93 void test_tuple_sequence()
97 BOOST_CHECK_EQUAL( c
.size(), 0u );
98 c
+= P("1",1), P("2",2), P("3",3), P("4",4), P("5",5), P("6",6),
99 P("7",7), P("8",8), P("9",9), P("10",10);
100 BOOST_CHECK_EQUAL( c
.size(), 10u );
109 m
+= P( "january", 31 ), P( "february", 28 ),
110 P( "march", 31 ), P( "april", 30 ),
111 P( "may", 31 ), P( "june", 30 ),
112 P( "july", 31 ), P( "august", 31 ),
113 P( "september", 30 ), P( "october", 31 ),
114 P( "november", 30 ), P( "december", 31 );
115 BOOST_CHECK_EQUAL( m
.size(), 12u );
118 ( "january", 31 )( "february", 28 )
119 ( "march", 31 )( "april", 30 )
120 ( "may", 31 )( "june", 30 )
121 ( "july", 31 )( "august", 31 )
122 ( "september", 30 )( "october", 31 )
123 ( "november", 30 )( "december", 31 );
124 BOOST_CHECK_EQUAL( m
.size(), 12u );
131 vector
<three
> v_three
;
135 push_back( v_three
) (1,2,3) ("1","2","3");
136 push_back( v_four
) (1,2,3,4) ("1","2","3","4");
137 push_back( v_five
) (1,2,3,4,5) ("1","2","3","4","5");
138 BOOST_CHECK_EQUAL( v_three
.size(), 2u );
139 BOOST_CHECK_EQUAL( v_four
.size(), 2u );
140 BOOST_CHECK_EQUAL( v_five
.size(), 2u );
148 test_int_sequence
< deque
<int> >();
149 test_int_sequence
< list
<int> >();
150 test_int_sequence
< vector
<int> >();
151 test_int_sequence
< set
<int> >();
152 test_int_sequence
< multiset
<int> >();
153 test_int_sequence
< stack
<int> >();
154 test_int_sequence
< queue
<int> >();
155 test_int_sequence
< priority_queue
<int> >();
157 test_string_sequence
< deque
<string
> >();
158 test_string_sequence
< list
<string
> >();
159 test_string_sequence
< vector
<string
> >();
160 test_string_sequence
< set
<string
> >();
161 test_string_sequence
< multiset
<string
> >();
162 test_string_sequence
< stack
<string
> >();
163 test_string_sequence
< queue
<string
> >();
164 test_string_sequence
< priority_queue
<string
> >();
166 test_tuple_sequence
< deque
<two_tuple
> >();
167 test_tuple_sequence
< list
<two_tuple
> >();
168 test_tuple_sequence
< vector
<two_tuple
> >();
169 test_tuple_sequence
< set
<two_tuple
> >();
170 test_tuple_sequence
< multiset
<two_tuple
> >();
171 test_tuple_sequence
< stack
<two_tuple
> >();
172 test_tuple_sequence
< queue
<two_tuple
> >();
173 test_tuple_sequence
< priority_queue
<two_tuple
> >();
177 push_back( di
)( 1 );
178 push_front( di
)( 2 );
179 BOOST_CHECK_EQUAL( di
[0], 2 );
180 BOOST_CHECK_EQUAL( di
[1], 1 );
183 push_back( li
)( 2 );
184 push_front( li
)( 1 );
185 BOOST_CHECK_EQUAL( li
.front(), 1 );
186 BOOST_CHECK_EQUAL( li
.back(), 2 );
189 push_back( vi
) = 2,3;
190 BOOST_CHECK_EQUAL( vi
[0], 2 );
191 BOOST_CHECK_EQUAL( vi
[1], 3 );
195 BOOST_CHECK_EQUAL( *si
.find( 4 ), 4 );
199 BOOST_CHECK_EQUAL( *msi
.find( 5 ), 5 );
203 BOOST_CHECK_EQUAL( sti
.top(), 6 );
207 BOOST_CHECK_EQUAL( qi
.back(), 7 );
209 priority_queue
<int> pqi
;
211 BOOST_CHECK_EQUAL( pqi
.top(), 8 );
213 test_map
< map
<string
,int> >();
214 test_map
< multimap
<string
,int> >();
220 #include <boost/test/unit_test.hpp>
221 using boost::unit_test::test_suite
;
223 test_suite
* init_unit_test_suite( int argc
, char* argv
[] )
225 test_suite
* test
= BOOST_TEST_SUITE( "List Test Suite" );
227 test
->add( BOOST_TEST_CASE( &check_std
) );