First public contribution.
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 //Has to be first for StackAllocator swap overload to be taken
17 //into account (at least using GCC 4.0.1)
18 #include "stack_allocator.h"
25 #include "cppunit/cppunit_proxy.h"
27 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
34 class MapTest : public CPPUNIT_NS::TestCase
36 CPPUNIT_TEST_SUITE(MapTest);
40 CPPUNIT_TEST(iterators);
41 CPPUNIT_TEST(equal_range);
42 CPPUNIT_TEST(allocator_with_state);
43 #if !defined (STLPORT) || !defined (_STLP_USE_CONTAINERS_EXTENSION)
46 CPPUNIT_TEST(template_methods);
47 CPPUNIT_TEST(map_cov1);
48 CPPUNIT_TEST(map_cov2);
49 CPPUNIT_TEST(map_cov3);
50 CPPUNIT_TEST(map_cov4);
51 CPPUNIT_TEST(multimap_cov1);
52 CPPUNIT_TEST(multimap_cov2);
53 CPPUNIT_TEST(multimap_cov3);
54 CPPUNIT_TEST(multimap_cov4);
55 CPPUNIT_TEST_SUITE_END();
63 void allocator_with_state();
64 void template_methods();
75 CPPUNIT_TEST_SUITE_REGISTRATION(MapTest);
78 // tests implementation
82 typedef map<char, int, less<char> > maptype;
84 // Store mappings between roman numerals and decimals.
86 m['x'] = 20; // Deliberate mistake.
89 // cout << "m['x'] = " << m['x'] << endl;
90 CPPUNIT_ASSERT( m['x']== 20 );
91 m['x'] = 10; // Correct mistake.
92 CPPUNIT_ASSERT( m['x']== 10 );
93 CPPUNIT_ASSERT( m['z']== 0 );
94 //cout << "m['z'] = " << m['z'] << endl; // Note default value is added.
95 CPPUNIT_ASSERT( m.count('z') == 1 );
96 //cout << "m.count('z') = " << m.count('z') << endl;
97 pair<maptype::iterator, bool> p = m.insert(pair<const char, int>('c', 100));
98 CPPUNIT_ASSERT( p.second );
99 CPPUNIT_ASSERT( p.first != m.end() );
100 CPPUNIT_ASSERT( (*p.first).first == 'c' );
101 CPPUNIT_ASSERT( (*p.first).second == 100 );
103 p = m.insert(pair<const char, int>('c', 100));
104 CPPUNIT_ASSERT( !p.second ); // already existing pair
105 CPPUNIT_ASSERT( p.first != m.end() );
106 CPPUNIT_ASSERT( (*p.first).first == 'c' );
107 CPPUNIT_ASSERT( (*p.first).second == 100 );
110 void MapTest::mmap1()
112 typedef multimap<char, int, less<char> > mmap;
114 CPPUNIT_ASSERT(m.count('X')==0);
116 m.insert(pair<const char, int>('X', 10)); // Standard way.
117 CPPUNIT_ASSERT(m.count('X')==1);
119 m.insert(pair<const char, int>('X', 20)); // jbuck: standard way
120 CPPUNIT_ASSERT(m.count('X')==2);
122 m.insert(pair<const char, int>('Y', 32)); // jbuck: standard way
123 mmap::iterator i = m.find('X'); // Find first match.
124 pair<const char, int> p('X', 10);
125 CPPUNIT_ASSERT(*i == p);
126 CPPUNIT_ASSERT((*i).first == 'X');
127 CPPUNIT_ASSERT((*i).second == 10);
129 CPPUNIT_ASSERT((*i).first == 'X');
130 CPPUNIT_ASSERT((*i).second == 20);
132 CPPUNIT_ASSERT((*i).first == 'Y');
133 CPPUNIT_ASSERT((*i).second == 32);
135 CPPUNIT_ASSERT(i == m.end());
137 size_t count = m.erase('X');
138 CPPUNIT_ASSERT(count==2);
140 void MapTest::mmap2()
142 typedef pair<const int, char> pair_type;
144 pair_type p1(3, 'c');
145 pair_type p2(6, 'f');
146 pair_type p3(1, 'a');
147 pair_type p4(2, 'b');
148 pair_type p5(3, 'x');
149 pair_type p6(6, 'f');
151 typedef multimap<int, char, less<int> > mmap;
153 pair_type array [] = {
162 mmap m(array + 0, array + 6);
164 i = m.lower_bound(3);
165 CPPUNIT_ASSERT((*i).first==3);
166 CPPUNIT_ASSERT((*i).second=='c');
168 i = m.upper_bound(3);
169 CPPUNIT_ASSERT((*i).first==6);
170 CPPUNIT_ASSERT((*i).second=='f');
174 void MapTest::iterators()
176 typedef map<int, char, less<int> > int_map;
179 int_map::iterator ite(imap.begin());
180 int_map::const_iterator cite(imap.begin());
181 CPPUNIT_ASSERT( ite == cite );
182 CPPUNIT_ASSERT( !(ite != cite) );
183 CPPUNIT_ASSERT( cite == ite );
184 CPPUNIT_ASSERT( !(cite != ite) );
187 typedef multimap<int, char, less<int> > mmap;
188 typedef mmap::value_type pair_type;
190 pair_type p1(3, 'c');
191 pair_type p2(6, 'f');
192 pair_type p3(1, 'a');
193 pair_type p4(2, 'b');
194 pair_type p5(3, 'x');
195 pair_type p6(6, 'f');
197 pair_type array [] = {
206 mmap m(array+0, array + 6);
209 mmap::iterator ite(m.begin());
210 mmap::const_iterator cite(m.begin());
211 //test compare between const_iterator and iterator
212 CPPUNIT_ASSERT( ite == cite );
213 CPPUNIT_ASSERT( !(ite != cite) );
214 CPPUNIT_ASSERT( cite == ite );
215 CPPUNIT_ASSERT( !(cite != ite) );
220 * A check that map and multimap iterators are NOT comparable
221 * the following code should generate a compile time error
224 int_map::iterator mite(imap.begin());
225 int_map::const_iterator mcite(imap.begin());
226 mmap::iterator mmite(m.begin());
227 mmap::const_iterator mmcite(m.begin());
228 CPPUNIT_ASSERT( !(mite == mmite) );
229 CPPUNIT_ASSERT( !(mcite == mmcite) );
230 CPPUNIT_ASSERT( mite != mmite );
231 CPPUNIT_ASSERT( mcite != mmcite );
232 CPPUNIT_ASSERT( !(mite == mmcite) );
233 CPPUNIT_ASSERT( !(mite == mmcite) );
234 CPPUNIT_ASSERT( mite != mmcite );
235 CPPUNIT_ASSERT( mite != mmcite );
240 mmap::reverse_iterator ri = m.rbegin();
241 CPPUNIT_ASSERT( ri != m.rend() );
242 CPPUNIT_ASSERT( ri == m.rbegin() );
243 CPPUNIT_ASSERT( (*ri).first == 6 );
244 CPPUNIT_ASSERT( (*ri++).second == 'f' );
245 CPPUNIT_ASSERT( (*ri).first == 6 );
246 CPPUNIT_ASSERT( (*ri).second == 'f' );
249 mmap::const_reverse_iterator rci = cm.rbegin();
250 CPPUNIT_ASSERT( rci != cm.rend() );
251 CPPUNIT_ASSERT( (*rci).first == 6 );
252 CPPUNIT_ASSERT( (*rci++).second == 'f' );
253 CPPUNIT_ASSERT( (*rci).first == 6 );
254 CPPUNIT_ASSERT( (*rci).second == 'f' );
257 void MapTest::equal_range()
259 typedef map<char, int, less<char> > maptype;
264 pair<maptype::iterator, maptype::iterator> ret;
265 ret = m.equal_range('x');
266 CPPUNIT_ASSERT( ret.first != ret.second );
267 CPPUNIT_ASSERT( (*(ret.first)).first == 'x' );
268 CPPUNIT_ASSERT( (*(ret.first)).second == 10 );
269 CPPUNIT_ASSERT( ++(ret.first) == ret.second );
275 maptype::iterator i = m.lower_bound( 'x' );
276 CPPUNIT_ASSERT( i == m.end() );
278 i = m.upper_bound( 'x' );
279 CPPUNIT_ASSERT( i == m.end() );
281 pair<maptype::iterator, maptype::iterator> ret;
282 ret = m.equal_range('x');
283 CPPUNIT_ASSERT( ret.first == ret.second );
284 CPPUNIT_ASSERT( ret.first == m.end() );
289 pair<maptype::const_iterator, maptype::const_iterator> ret;
290 ret = m.equal_range('x');
291 CPPUNIT_ASSERT( ret.first == ret.second );
292 CPPUNIT_ASSERT( ret.first == m.end() );
297 void MapTest::allocator_with_state()
300 StackAllocator<pair<const int, int> > stack1(buf1, buf1 + sizeof(buf1));
303 StackAllocator<pair<const int, int> > stack2(buf2, buf2 + sizeof(buf2));
306 typedef map<int, int, less<int>, StackAllocator<pair<const int, int> > > MapInt;
308 MapInt mint1(intLess, stack1);
310 for (i = 0; i < 5; ++i)
311 mint1.insert(MapInt::value_type(i, i));
312 MapInt mint1Cpy(mint1);
314 MapInt mint2(intLess, stack2);
316 mint2.insert(MapInt::value_type(i, i));
317 MapInt mint2Cpy(mint2);
321 CPPUNIT_ASSERT( mint1.get_allocator().swaped() );
322 CPPUNIT_ASSERT( mint2.get_allocator().swaped() );
324 CPPUNIT_ASSERT( mint1 == mint2Cpy );
325 CPPUNIT_ASSERT( mint2 == mint1Cpy );
326 CPPUNIT_ASSERT( mint1.get_allocator() == stack2 );
327 CPPUNIT_ASSERT( mint2.get_allocator() == stack1 );
329 CPPUNIT_ASSERT( stack1.ok() );
330 CPPUNIT_ASSERT( stack2.ok() );
336 explicit Key(int data) : m_data(data) {}
343 bool operator () (Key lhs, Key rhs) const
344 { return lhs.m_data < rhs.m_data; }
346 bool operator () (Key lhs, int rhs) const
347 { return lhs.m_data < rhs; }
349 bool operator () (int lhs, Key rhs) const
350 { return lhs < rhs.m_data; }
355 bool operator () (Key const volatile *lhs, Key const volatile *rhs) const
356 { return (*lhs).m_data < (*rhs).m_data; }
358 bool operator () (Key const volatile *lhs, int rhs) const
359 { return (*lhs).m_data < rhs; }
361 bool operator () (int lhs, Key const volatile *rhs) const
362 { return lhs < (*rhs).m_data; }
365 void MapTest::template_methods()
367 #if defined (STLPORT) && defined (_STLP_USE_CONTAINERS_EXTENSION)
369 typedef map<Key, int, KeyCmp> Container;
370 typedef Container::value_type value;
372 cont.insert(value(Key(1), 1));
373 cont.insert(value(Key(2), 2));
374 cont.insert(value(Key(3), 3));
375 cont.insert(value(Key(4), 4));
377 CPPUNIT_ASSERT( cont.count(Key(1)) == 1 );
378 CPPUNIT_ASSERT( cont.count(1) == 1 );
379 CPPUNIT_ASSERT( cont.count(5) == 0 );
381 CPPUNIT_ASSERT( cont.find(2) != cont.end() );
382 CPPUNIT_ASSERT( cont.lower_bound(2) != cont.end() );
383 CPPUNIT_ASSERT( cont.upper_bound(2) != cont.end() );
384 CPPUNIT_ASSERT( cont.equal_range(2) != make_pair(cont.begin(), cont.end()) );
386 Container const& ccont = cont;
387 CPPUNIT_ASSERT( ccont.find(2) != ccont.end() );
388 CPPUNIT_ASSERT( ccont.lower_bound(2) != ccont.end() );
389 CPPUNIT_ASSERT( ccont.upper_bound(2) != ccont.end() );
390 CPPUNIT_ASSERT( ccont.equal_range(2) != make_pair(ccont.end(), ccont.end()) );
394 typedef map<Key*, int, KeyCmpPtr> Container;
395 typedef Container::value_type value;
397 Key key1(1), key2(2), key3(3), key4(4);
398 cont.insert(value(&key1, 1));
399 cont.insert(value(&key2, 2));
400 cont.insert(value(&key3, 3));
401 cont.insert(value(&key4, 4));
403 CPPUNIT_ASSERT( cont.count(1) == 1 );
404 CPPUNIT_ASSERT( cont.count(5) == 0 );
406 CPPUNIT_ASSERT( cont.find(2) != cont.end() );
407 CPPUNIT_ASSERT( cont.lower_bound(2) != cont.end() );
408 CPPUNIT_ASSERT( cont.upper_bound(2) != cont.end() );
409 CPPUNIT_ASSERT( cont.equal_range(2) != make_pair(cont.begin(), cont.end()) );
411 Container const& ccont = cont;
412 CPPUNIT_ASSERT( ccont.find(2) != ccont.end() );
413 CPPUNIT_ASSERT( ccont.lower_bound(2) != ccont.end() );
414 CPPUNIT_ASSERT( ccont.upper_bound(2) != ccont.end() );
415 CPPUNIT_ASSERT( ccont.equal_range(2) != make_pair(ccont.begin(), ccont.end()) );
418 typedef multimap<Key, int, KeyCmp> Container;
419 typedef Container::value_type value;
421 cont.insert(value(Key(1), 1));
422 cont.insert(value(Key(2), 2));
423 cont.insert(value(Key(3), 3));
424 cont.insert(value(Key(4), 4));
426 CPPUNIT_ASSERT( cont.count(Key(1)) == 1 );
427 CPPUNIT_ASSERT( cont.count(1) == 1 );
428 CPPUNIT_ASSERT( cont.count(5) == 0 );
430 CPPUNIT_ASSERT( cont.find(2) != cont.end() );
431 CPPUNIT_ASSERT( cont.lower_bound(2) != cont.end() );
432 CPPUNIT_ASSERT( cont.upper_bound(2) != cont.end() );
433 CPPUNIT_ASSERT( cont.equal_range(2) != make_pair(cont.begin(), cont.end()) );
435 Container const& ccont = cont;
436 CPPUNIT_ASSERT( ccont.find(2) != ccont.end() );
437 CPPUNIT_ASSERT( ccont.lower_bound(2) != ccont.end() );
438 CPPUNIT_ASSERT( ccont.upper_bound(2) != ccont.end() );
439 CPPUNIT_ASSERT( ccont.equal_range(2) != make_pair(ccont.end(), ccont.end()) );
443 typedef multimap<Key const volatile*, int, KeyCmpPtr> Container;
444 typedef Container::value_type value;
446 Key key1(1), key2(2), key3(3), key4(4);
447 cont.insert(value(&key1, 1));
448 cont.insert(value(&key2, 2));
449 cont.insert(value(&key3, 3));
450 cont.insert(value(&key4, 4));
452 CPPUNIT_ASSERT( cont.count(1) == 1 );
453 CPPUNIT_ASSERT( cont.count(5) == 0 );
455 CPPUNIT_ASSERT( cont.find(2) != cont.end() );
456 CPPUNIT_ASSERT( cont.lower_bound(2) != cont.end() );
457 CPPUNIT_ASSERT( cont.upper_bound(2) != cont.end() );
458 CPPUNIT_ASSERT( cont.equal_range(2) != make_pair(cont.begin(), cont.end()) );
460 Container const& ccont = cont;
461 CPPUNIT_ASSERT( ccont.find(2) != ccont.end() );
462 CPPUNIT_ASSERT( ccont.lower_bound(2) != ccont.end() );
463 CPPUNIT_ASSERT( ccont.upper_bound(2) != ccont.end() );
464 CPPUNIT_ASSERT( ccont.equal_range(2) != make_pair(ccont.begin(), ccont.end()) );
469 void MapTest::map_cov1()
474 map<int, int>::size_type i;
475 typedef pair<int, int> Int_Pair;
476 m1.insert(Int_Pair(1, 1));
477 m1.insert(Int_Pair(2, 4));
480 CPPUNIT_ASSERT( i==2 );
483 CPPUNIT_ASSERT( i==0 );
486 map <int, int> m1, m2;
488 typedef pair <int, int> Int_Pair;
490 m1.insert ( Int_Pair ( 1, 1 ) );
492 CPPUNIT_ASSERT( flag==false );
494 CPPUNIT_ASSERT( flag==true );
498 map <int, int> :: iterator m1_Iter;
499 map <int, int> :: reverse_iterator m1_rIter;
500 typedef pair <int, int> Int_Pair;
502 m1.insert ( Int_Pair ( 1, 10 ) );
503 m1.insert ( Int_Pair ( 2, 20 ) );
504 m1.insert ( Int_Pair ( 3, 30 ) );
505 m1_rIter = m1.rbegin( );
506 CPPUNIT_ASSERT( m1_rIter->first == 3 );
507 m1_rIter = m1.rend( );
509 CPPUNIT_ASSERT( m1_rIter->first == 1 );
513 void MapTest::map_cov2()
517 map<int, int> m1, m2, m3;
518 map<int, int>::iterator pIter, Iter1, Iter2;
520 typedef pair<int, int> Int_Pair;
522 for (i = 1; i < 5; i++)
524 m1.insert(Int_Pair(i, i));
525 m2.insert(Int_Pair(i, i*i));
526 m3.insert(Int_Pair(i, i-1));
528 Iter1 = ++m1.begin();
532 CPPUNIT_ASSERT( pIter->second == 1 );
534 CPPUNIT_ASSERT( pIter->second == 3 );
536 CPPUNIT_ASSERT( pIter->second == 4 );
538 Iter1 = ++m2.begin();
540 m2.erase(Iter1, Iter2);
542 CPPUNIT_ASSERT( pIter->second == 1 );
544 CPPUNIT_ASSERT( pIter->second == 16 );
546 map<int, int>::size_type n = m3.erase(2);
548 CPPUNIT_ASSERT( pIter->second == 0 );
550 CPPUNIT_ASSERT( pIter->second == 2 );
552 CPPUNIT_ASSERT( pIter->second == 3 );
560 void MapTest::map_cov3()
566 map <int, int> :: iterator m1_Iter;
567 map <int, int> :: reverse_iterator m1_rIter;
568 map <int, int> :: const_reverse_iterator m1_crIter;
569 typedef pair <int, int> Int_Pair;
571 m1.insert ( Int_Pair ( 1, 10 ) );
572 m1.insert ( Int_Pair ( 2, 20 ) );
573 m1.insert ( Int_Pair ( 3, 30 ) );
574 m1_crIter = m1.rbegin( );
575 CPPUNIT_ASSERT( m1_crIter->first == 3 );
576 m1_crIter = m1.rend( );
578 CPPUNIT_ASSERT( m1_crIter->first == 1 );
581 map <int, int, less<int> > m1;
582 map <int, int, less<int> >::value_compare vc1 = m1.value_comp( );
583 pair< map<int,int>::iterator, bool > pr1, pr2;
585 pr1= m1.insert ( map <int, int> :: value_type ( 1, 10 ) );
586 pr2= m1.insert ( map <int, int> :: value_type ( 2, 5 ) );
588 CPPUNIT_ASSERT( vc1( *pr1.first, *pr2.first ) == true );
591 map <int, int> m1, m2;
592 typedef pair <int, int> Int_Pair;
593 map <int, int>::iterator m2_Iter;
594 map<int, int>::size_type i;
595 m1.insert ( Int_Pair ( 1, 10 ) );
596 m1.insert ( Int_Pair ( 2, 20 ) );
597 m1.insert ( Int_Pair ( 3, 30 ) );
599 m2_Iter = m2.begin( );
600 CPPUNIT_ASSERT(m2_Iter -> second == 10);
602 CPPUNIT_ASSERT(i == 3);
606 void MapTest::map_cov4()
610 map <int, int> m1, m3;
611 map <int, int>::iterator m1_Iter;
612 typedef pair <int, int> Int_Pair;
614 m1.insert ( Int_Pair ( 1, 10 ) );
615 m1.insert ( Int_Pair ( 2, 20 ) );
616 m1.insert ( Int_Pair ( 3, 30 ) );
617 m3.insert ( Int_Pair ( 30, 300 ) );
620 m1_Iter = m1.begin();
622 CPPUNIT_ASSERT(m1_Iter -> second == 300);
625 map <int, int> m1, m3;
626 typedef pair <int, int> Int_Pair;
628 m1.insert ( Int_Pair ( 1, 10 ) );
629 m3.insert ( Int_Pair ( 30, 300 ) );
632 CPPUNIT_ASSERT(x == true);
637 void MapTest::multimap_cov1()
641 multimap<int, int> m1;
642 multimap<int, int>::size_type i;
643 typedef pair<int, int> Int_Pair;
645 m1.insert(Int_Pair(1, 1));
646 m1.insert(Int_Pair(2, 4));
649 CPPUNIT_ASSERT( i==2 );
652 CPPUNIT_ASSERT( i==0 );
655 multimap <int, int> m1, m2;
657 typedef pair <int, int> Int_Pair;
659 m1.insert ( Int_Pair ( 1, 1 ) );
661 CPPUNIT_ASSERT( flag==false );
663 CPPUNIT_ASSERT( flag==true );
666 multimap <int, int>::allocator_type m1_Alloc;
667 multimap <int, int>::allocator_type m2_Alloc;
668 multimap <int, int>::allocator_type m4_Alloc;
670 multimap <int, int> m1;
671 multimap <int, int, allocator<int> > m2;
672 m1_Alloc = m1.get_allocator( );
673 m2_Alloc = m2.get_allocator( );
674 map <int, int> m4( less<int>( ), m1_Alloc );
675 m4_Alloc = m4.get_allocator( );
677 CPPUNIT_ASSERT( m1_Alloc == m4_Alloc );
681 void MapTest::multimap_cov2()
685 multimap<int, int> m1, m2;
686 multimap<int, int>::iterator pIter, Iter1, Iter2;
688 typedef pair<int, int> Int_Pair;
690 for (i = 1; i < 5; i++)
692 m1.insert(Int_Pair(i, i));
693 m2.insert(Int_Pair(i, i*i));
695 Iter1 = ++m1.begin();
699 CPPUNIT_ASSERT( pIter->second == 1 );
701 CPPUNIT_ASSERT( pIter->second == 3 );
703 CPPUNIT_ASSERT( pIter->second == 4 );
705 Iter1 = ++m2.begin();
707 m2.erase(Iter1, Iter2);
709 CPPUNIT_ASSERT( pIter->second == 1 );
711 CPPUNIT_ASSERT( pIter->second == 16 );
714 multimap <int, int>::iterator m1_pIter, m2_pIter;
715 multimap <int, int> :: reverse_iterator m1_rIter;
716 multimap <int, int> m1, m2;
717 typedef pair <int, int> Int_Pair;
719 m1.insert ( Int_Pair ( 1, 10 ) );
720 m1.insert ( Int_Pair ( 2, 20 ) );
721 m1.insert ( Int_Pair ( 3, 30 ) );
722 m1.insert( --m1.end( ), Int_Pair ( 4, 40 ) );
724 m1_rIter = m1.rbegin( );
725 CPPUNIT_ASSERT( m1_rIter->first == 4 );
727 m2.insert ( Int_Pair ( 10, 100 ) );
728 m2.insert( ++m1.begin( ), --m1.end( ) );
729 m2_pIter = m2.begin( );
730 CPPUNIT_ASSERT(m2_pIter -> first == 2);
733 multimap <int, int> m1;
738 void MapTest::multimap_cov3()
742 multimap <int, int, less<int> > m1;
743 multimap <int, int, less<int> >::key_compare kc1 = m1.key_comp( ) ;
744 bool result1 = kc1( 2, 3 ) ;
745 CPPUNIT_ASSERT(result1 == true);
747 multimap <int, int, greater_equal<int> > m2;
748 multimap <int, int, greater_equal<int> >::key_compare kc2 = m2.key_comp( );
749 bool result2 = kc2( 3, 3 ) ;
750 CPPUNIT_ASSERT(result1 == true);
753 multimap<int, int> m1, m2;
754 multimap<int, int>::size_type i;
755 typedef pair<int, int> Int_Pair;
757 m1.insert(Int_Pair(1, 1));
759 CPPUNIT_ASSERT(i == 1);
760 m1.insert(Int_Pair(2, 4));
762 CPPUNIT_ASSERT(i == 2);
765 multimap <int, int> m1, m2;
766 multimap <int, int>::iterator m1_Iter;
767 typedef pair <int, int> Int_Pair;
768 multimap<int, int>::size_type i;
770 m1.insert ( Int_Pair ( 1, 10 ) );
771 m1.insert ( Int_Pair ( 2, 20 ) );
772 m1.insert ( Int_Pair ( 3, 30 ) );
773 m2.insert ( Int_Pair ( 30, 300 ) );
775 m1_Iter = m1.begin( );
776 CPPUNIT_ASSERT(m1_Iter -> second == 300);
778 CPPUNIT_ASSERT(i == 1);
782 void MapTest::multimap_cov4()
786 multimap <int, int, less<int> > m1;
787 multimap <int, int, less<int> >::value_compare vc1 = m1.value_comp( );
788 multimap<int,int>::iterator Iter1, Iter2;
790 Iter1= m1.insert ( multimap <int, int> :: value_type ( 1, 10 ) );
791 Iter2= m1.insert ( multimap <int, int> :: value_type ( 2, 5 ) );
792 CPPUNIT_ASSERT( vc1( *Iter1, *Iter2 ) == true );
795 multimap <int, int> m1, m2;
796 typedef pair <int, int> Int_Pair;
797 multimap <int, int>::iterator m2_Iter;
798 multimap<int, int>::size_type i;
800 m1.insert ( Int_Pair ( 1, 10 ) );
801 m1.insert ( Int_Pair ( 2, 20 ) );
802 m1.insert ( Int_Pair ( 3, 30 ) );
805 m2_Iter = m2.begin( );
806 CPPUNIT_ASSERT(m2_Iter -> second == 10);
808 CPPUNIT_ASSERT(i == 3);
812 multimap <int, int> m1, m2;
813 multimap <int, int>::iterator m1_Iter;
814 typedef pair <int, int> Int_Pair;
815 multimap<int, int>::size_type i;
817 m1.insert ( Int_Pair ( 1, 10 ) );
818 m1.insert ( Int_Pair ( 2, 20 ) );
819 m1.insert ( Int_Pair ( 3, 30 ) );
820 m2.insert ( Int_Pair ( 30, 300 ) );
822 m1_Iter = m1.begin( );
823 CPPUNIT_ASSERT(m1_Iter -> second == 300);
825 CPPUNIT_ASSERT(i == 1);
828 multimap <int, int> m1, m2;
829 typedef pair <int, int> Int_Pair;
831 m1.insert ( Int_Pair ( 1, 10 ) );
832 m2.insert ( Int_Pair ( 30, 300 ) );
835 CPPUNIT_ASSERT(val == true);
837 CPPUNIT_ASSERT(val == false);