os/ossrv/genericopenlibs/cppstdlib/stl/test/unit/map_test.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/cppstdlib/stl/test/unit/map_test.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,840 @@
     1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +//Has to be first for StackAllocator swap overload to be taken
    1.20 +//into account (at least using GCC 4.0.1)
    1.21 +#include "stack_allocator.h"
    1.22 +
    1.23 +#include <map>
    1.24 +#include <algorithm>
    1.25 +#include <functional>
    1.26 +#include <e32std.h>
    1.27 +
    1.28 +#include "cppunit/cppunit_proxy.h"
    1.29 +
    1.30 +#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
    1.31 +using namespace std;
    1.32 +#endif
    1.33 +
    1.34 +//
    1.35 +// TestCase class
    1.36 +//
    1.37 +class MapTest : public CPPUNIT_NS::TestCase
    1.38 +{
    1.39 +  CPPUNIT_TEST_SUITE(MapTest);
    1.40 +  CPPUNIT_TEST(map1);
    1.41 +  CPPUNIT_TEST(mmap1);
    1.42 +  CPPUNIT_TEST(mmap2);
    1.43 +  CPPUNIT_TEST(iterators);
    1.44 +  CPPUNIT_TEST(equal_range);
    1.45 +  CPPUNIT_TEST(allocator_with_state);
    1.46 +#if !defined (STLPORT) || !defined (_STLP_USE_CONTAINERS_EXTENSION)
    1.47 +  CPPUNIT_IGNORE;
    1.48 +#endif
    1.49 +  CPPUNIT_TEST(template_methods);
    1.50 +  CPPUNIT_TEST(map_cov1);
    1.51 +  CPPUNIT_TEST(map_cov2);
    1.52 +  CPPUNIT_TEST(map_cov3);
    1.53 +  CPPUNIT_TEST(map_cov4);
    1.54 +  CPPUNIT_TEST(multimap_cov1);
    1.55 +  CPPUNIT_TEST(multimap_cov2);
    1.56 +  CPPUNIT_TEST(multimap_cov3);
    1.57 +  CPPUNIT_TEST(multimap_cov4);
    1.58 +  CPPUNIT_TEST_SUITE_END();
    1.59 +
    1.60 +protected:
    1.61 +  void map1();
    1.62 +  void mmap1();
    1.63 +  void mmap2();
    1.64 +  void iterators();
    1.65 +  void equal_range();
    1.66 +  void allocator_with_state();
    1.67 +  void template_methods();
    1.68 +  void map_cov1();
    1.69 +  void map_cov2();
    1.70 +  void map_cov3();
    1.71 +  void map_cov4();
    1.72 +  void multimap_cov1();
    1.73 +  void multimap_cov2();
    1.74 +  void multimap_cov3();
    1.75 +  void multimap_cov4();
    1.76 +};
    1.77 +
    1.78 +CPPUNIT_TEST_SUITE_REGISTRATION(MapTest);
    1.79 +
    1.80 +//
    1.81 +// tests implementation
    1.82 +//
    1.83 +void MapTest::map1()
    1.84 +{
    1.85 +  typedef map<char, int, less<char> > maptype;
    1.86 +  maptype m;
    1.87 +  // Store mappings between roman numerals and decimals.
    1.88 +  m['l'] = 50;
    1.89 +  m['x'] = 20; // Deliberate mistake.
    1.90 +  m['v'] = 5;
    1.91 +  m['i'] = 1;
    1.92 +//  cout << "m['x'] = " << m['x'] << endl;
    1.93 +  CPPUNIT_ASSERT( m['x']== 20 );
    1.94 +  m['x'] = 10; // Correct mistake.
    1.95 +  CPPUNIT_ASSERT( m['x']== 10 );
    1.96 +  CPPUNIT_ASSERT( m['z']== 0 );
    1.97 +  //cout << "m['z'] = " << m['z'] << endl; // Note default value is added.
    1.98 +  CPPUNIT_ASSERT( m.count('z') == 1 );
    1.99 +  //cout << "m.count('z') = " << m.count('z') << endl;
   1.100 +  pair<maptype::iterator, bool> p = m.insert(pair<const char, int>('c', 100));
   1.101 +  CPPUNIT_ASSERT( p.second );
   1.102 +  CPPUNIT_ASSERT( p.first != m.end() );
   1.103 +  CPPUNIT_ASSERT( (*p.first).first == 'c' );
   1.104 +  CPPUNIT_ASSERT( (*p.first).second == 100 );
   1.105 +
   1.106 +  p = m.insert(pair<const char, int>('c', 100));
   1.107 +  CPPUNIT_ASSERT( !p.second ); // already existing pair
   1.108 +  CPPUNIT_ASSERT( p.first != m.end() );
   1.109 +  CPPUNIT_ASSERT( (*p.first).first == 'c' );
   1.110 +  CPPUNIT_ASSERT( (*p.first).second == 100 );
   1.111 +}
   1.112 +
   1.113 +void MapTest::mmap1()
   1.114 +{
   1.115 +  typedef multimap<char, int, less<char> > mmap;
   1.116 +  mmap m;
   1.117 +  CPPUNIT_ASSERT(m.count('X')==0);
   1.118 +
   1.119 +  m.insert(pair<const char, int>('X', 10)); // Standard way.
   1.120 +  CPPUNIT_ASSERT(m.count('X')==1);
   1.121 +
   1.122 +  m.insert(pair<const char, int>('X', 20)); // jbuck: standard way
   1.123 +  CPPUNIT_ASSERT(m.count('X')==2);
   1.124 +
   1.125 +  m.insert(pair<const char, int>('Y', 32)); // jbuck: standard way
   1.126 +  mmap::iterator i = m.find('X'); // Find first match.
   1.127 +  pair<const char, int> p('X', 10);
   1.128 +  CPPUNIT_ASSERT(*i == p);
   1.129 +  CPPUNIT_ASSERT((*i).first == 'X');
   1.130 +  CPPUNIT_ASSERT((*i).second == 10);
   1.131 +  i++;
   1.132 +  CPPUNIT_ASSERT((*i).first == 'X');
   1.133 +  CPPUNIT_ASSERT((*i).second == 20);
   1.134 +  i++;
   1.135 +  CPPUNIT_ASSERT((*i).first == 'Y');
   1.136 +  CPPUNIT_ASSERT((*i).second == 32);
   1.137 +  i++;
   1.138 +  CPPUNIT_ASSERT(i == m.end());
   1.139 +
   1.140 +  size_t count = m.erase('X');
   1.141 +  CPPUNIT_ASSERT(count==2);
   1.142 +}
   1.143 +void MapTest::mmap2()
   1.144 +{
   1.145 +  typedef pair<const int, char> pair_type;
   1.146 +
   1.147 +  pair_type p1(3, 'c');
   1.148 +  pair_type p2(6, 'f');
   1.149 +  pair_type p3(1, 'a');
   1.150 +  pair_type p4(2, 'b');
   1.151 +  pair_type p5(3, 'x');
   1.152 +  pair_type p6(6, 'f');
   1.153 +
   1.154 +  typedef multimap<int, char, less<int> > mmap;
   1.155 +
   1.156 +  pair_type array [] = {
   1.157 +    p1,
   1.158 +    p2,
   1.159 +    p3,
   1.160 +    p4,
   1.161 +    p5,
   1.162 +    p6
   1.163 +  };
   1.164 +
   1.165 +  mmap m(array + 0, array + 6);
   1.166 +  mmap::iterator i;
   1.167 +  i = m.lower_bound(3);
   1.168 +  CPPUNIT_ASSERT((*i).first==3);
   1.169 +  CPPUNIT_ASSERT((*i).second=='c');
   1.170 +
   1.171 +  i = m.upper_bound(3);
   1.172 +  CPPUNIT_ASSERT((*i).first==6);
   1.173 +  CPPUNIT_ASSERT((*i).second=='f');
   1.174 +}
   1.175 +
   1.176 +
   1.177 +void MapTest::iterators()
   1.178 +{
   1.179 +  typedef map<int, char, less<int> > int_map;
   1.180 +  int_map imap;
   1.181 +  {
   1.182 +    int_map::iterator ite(imap.begin());
   1.183 +    int_map::const_iterator cite(imap.begin());
   1.184 +    CPPUNIT_ASSERT( ite == cite );
   1.185 +    CPPUNIT_ASSERT( !(ite != cite) );
   1.186 +    CPPUNIT_ASSERT( cite == ite );
   1.187 +    CPPUNIT_ASSERT( !(cite != ite) );
   1.188 +  }
   1.189 +
   1.190 +  typedef multimap<int, char, less<int> > mmap;
   1.191 +  typedef mmap::value_type pair_type;
   1.192 +
   1.193 +  pair_type p1(3, 'c');
   1.194 +  pair_type p2(6, 'f');
   1.195 +  pair_type p3(1, 'a');
   1.196 +  pair_type p4(2, 'b');
   1.197 +  pair_type p5(3, 'x');
   1.198 +  pair_type p6(6, 'f');
   1.199 +
   1.200 +  pair_type array [] = {
   1.201 +    p1,
   1.202 +    p2,
   1.203 +    p3,
   1.204 +    p4,
   1.205 +    p5,
   1.206 +    p6
   1.207 +  };
   1.208 +
   1.209 +  mmap m(array+0, array + 6);
   1.210 +
   1.211 +  {
   1.212 +    mmap::iterator ite(m.begin());
   1.213 +    mmap::const_iterator cite(m.begin());
   1.214 +    //test compare between const_iterator and iterator
   1.215 +    CPPUNIT_ASSERT( ite == cite );
   1.216 +    CPPUNIT_ASSERT( !(ite != cite) );
   1.217 +    CPPUNIT_ASSERT( cite == ite );
   1.218 +    CPPUNIT_ASSERT( !(cite != ite) );
   1.219 +  }
   1.220 +
   1.221 +#if 0
   1.222 +  /*
   1.223 +   * A check that map and multimap iterators are NOT comparable
   1.224 +   * the following code should generate a compile time error
   1.225 +   */
   1.226 +  {
   1.227 +    int_map::iterator mite(imap.begin());
   1.228 +    int_map::const_iterator mcite(imap.begin());
   1.229 +    mmap::iterator mmite(m.begin());
   1.230 +    mmap::const_iterator mmcite(m.begin());
   1.231 +    CPPUNIT_ASSERT( !(mite == mmite) );
   1.232 +    CPPUNIT_ASSERT( !(mcite == mmcite) );
   1.233 +    CPPUNIT_ASSERT( mite != mmite );
   1.234 +    CPPUNIT_ASSERT( mcite != mmcite );
   1.235 +    CPPUNIT_ASSERT( !(mite == mmcite) );
   1.236 +    CPPUNIT_ASSERT( !(mite == mmcite) );
   1.237 +    CPPUNIT_ASSERT( mite != mmcite );
   1.238 +    CPPUNIT_ASSERT( mite != mmcite );
   1.239 +  }
   1.240 +
   1.241 +#endif
   1.242 +
   1.243 +  mmap::reverse_iterator ri = m.rbegin();
   1.244 +  CPPUNIT_ASSERT( ri != m.rend() );
   1.245 +  CPPUNIT_ASSERT( ri == m.rbegin() );
   1.246 +  CPPUNIT_ASSERT( (*ri).first == 6 );
   1.247 +  CPPUNIT_ASSERT( (*ri++).second == 'f' );
   1.248 +  CPPUNIT_ASSERT( (*ri).first == 6 );
   1.249 +  CPPUNIT_ASSERT( (*ri).second == 'f' );
   1.250 +
   1.251 +  mmap const& cm = m;
   1.252 +  mmap::const_reverse_iterator rci = cm.rbegin();
   1.253 +  CPPUNIT_ASSERT( rci != cm.rend() );
   1.254 +  CPPUNIT_ASSERT( (*rci).first == 6 );
   1.255 +  CPPUNIT_ASSERT( (*rci++).second == 'f' );
   1.256 +  CPPUNIT_ASSERT( (*rci).first == 6 );
   1.257 +  CPPUNIT_ASSERT( (*rci).second == 'f' );
   1.258 +}
   1.259 +
   1.260 +void MapTest::equal_range()
   1.261 +{
   1.262 +  typedef map<char, int, less<char> > maptype;
   1.263 +  {
   1.264 +    maptype m;
   1.265 +    m['x'] = 10;
   1.266 +
   1.267 +    pair<maptype::iterator, maptype::iterator> ret;
   1.268 +    ret = m.equal_range('x');
   1.269 +    CPPUNIT_ASSERT( ret.first != ret.second );
   1.270 +    CPPUNIT_ASSERT( (*(ret.first)).first == 'x' );
   1.271 +    CPPUNIT_ASSERT( (*(ret.first)).second == 10 );
   1.272 +    CPPUNIT_ASSERT( ++(ret.first) == ret.second );
   1.273 +  }
   1.274 +  {
   1.275 +    {
   1.276 +      maptype m;
   1.277 +
   1.278 +      maptype::iterator i = m.lower_bound( 'x' );
   1.279 +      CPPUNIT_ASSERT( i == m.end() );
   1.280 +
   1.281 +      i = m.upper_bound( 'x' );
   1.282 +      CPPUNIT_ASSERT( i == m.end() );
   1.283 +
   1.284 +      pair<maptype::iterator, maptype::iterator> ret;
   1.285 +      ret = m.equal_range('x');
   1.286 +      CPPUNIT_ASSERT( ret.first == ret.second );
   1.287 +      CPPUNIT_ASSERT( ret.first == m.end() );
   1.288 +    }
   1.289 +
   1.290 +    {
   1.291 +      const maptype m;
   1.292 +      pair<maptype::const_iterator, maptype::const_iterator> ret;
   1.293 +      ret = m.equal_range('x');
   1.294 +      CPPUNIT_ASSERT( ret.first == ret.second );
   1.295 +      CPPUNIT_ASSERT( ret.first == m.end() );
   1.296 +    }
   1.297 +  }
   1.298 +}
   1.299 +
   1.300 +void MapTest::allocator_with_state()
   1.301 +{
   1.302 +  char buf1[1024];
   1.303 +  StackAllocator<pair<const int, int> > stack1(buf1, buf1 + sizeof(buf1));
   1.304 +
   1.305 +  char buf2[1024];
   1.306 +  StackAllocator<pair<const int, int> > stack2(buf2, buf2 + sizeof(buf2));
   1.307 +
   1.308 +  {
   1.309 +    typedef map<int, int, less<int>, StackAllocator<pair<const int, int> > > MapInt;
   1.310 +    less<int> intLess;
   1.311 +    MapInt mint1(intLess, stack1);
   1.312 +    int i;
   1.313 +    for (i = 0; i < 5; ++i)
   1.314 +      mint1.insert(MapInt::value_type(i, i));
   1.315 +    MapInt mint1Cpy(mint1);
   1.316 +
   1.317 +    MapInt mint2(intLess, stack2);
   1.318 +    for (; i < 10; ++i)
   1.319 +      mint2.insert(MapInt::value_type(i, i));
   1.320 +    MapInt mint2Cpy(mint2);
   1.321 +
   1.322 +    mint1.swap(mint2);
   1.323 +
   1.324 +    CPPUNIT_ASSERT( mint1.get_allocator().swaped() );
   1.325 +    CPPUNIT_ASSERT( mint2.get_allocator().swaped() );
   1.326 +
   1.327 +    CPPUNIT_ASSERT( mint1 == mint2Cpy );
   1.328 +    CPPUNIT_ASSERT( mint2 == mint1Cpy );
   1.329 +    CPPUNIT_ASSERT( mint1.get_allocator() == stack2 );
   1.330 +    CPPUNIT_ASSERT( mint2.get_allocator() == stack1 );
   1.331 +  }
   1.332 +  CPPUNIT_ASSERT( stack1.ok() );
   1.333 +  CPPUNIT_ASSERT( stack2.ok() );
   1.334 +}
   1.335 +
   1.336 +struct Key
   1.337 +{
   1.338 +  Key() : m_data(0) {}
   1.339 +  explicit Key(int data) : m_data(data) {}
   1.340 +
   1.341 +  int m_data;
   1.342 +};
   1.343 +
   1.344 +struct KeyCmp
   1.345 +{
   1.346 +  bool operator () (Key lhs, Key rhs) const
   1.347 +  { return lhs.m_data < rhs.m_data; }
   1.348 +
   1.349 +  bool operator () (Key lhs, int rhs) const
   1.350 +  { return lhs.m_data < rhs; }
   1.351 +
   1.352 +  bool operator () (int lhs, Key rhs) const
   1.353 +  { return lhs < rhs.m_data; }
   1.354 +};
   1.355 +
   1.356 +struct KeyCmpPtr
   1.357 +{
   1.358 +  bool operator () (Key const volatile *lhs, Key const volatile *rhs) const
   1.359 +  { return (*lhs).m_data < (*rhs).m_data; }
   1.360 +
   1.361 +  bool operator () (Key const volatile *lhs, int rhs) const
   1.362 +  { return (*lhs).m_data < rhs; }
   1.363 +
   1.364 +  bool operator () (int lhs, Key const volatile *rhs) const
   1.365 +  { return lhs < (*rhs).m_data; }
   1.366 +};
   1.367 +
   1.368 +void MapTest::template_methods()
   1.369 +{
   1.370 +#if defined (STLPORT) && defined (_STLP_USE_CONTAINERS_EXTENSION)
   1.371 +  {
   1.372 +    typedef map<Key, int, KeyCmp> Container;
   1.373 +    typedef Container::value_type value;
   1.374 +    Container cont;
   1.375 +    cont.insert(value(Key(1), 1));
   1.376 +    cont.insert(value(Key(2), 2));
   1.377 +    cont.insert(value(Key(3), 3));
   1.378 +    cont.insert(value(Key(4), 4));
   1.379 +
   1.380 +    CPPUNIT_ASSERT( cont.count(Key(1)) == 1 );
   1.381 +    CPPUNIT_ASSERT( cont.count(1) == 1 );
   1.382 +    CPPUNIT_ASSERT( cont.count(5) == 0 );
   1.383 +
   1.384 +    CPPUNIT_ASSERT( cont.find(2) != cont.end() );
   1.385 +    CPPUNIT_ASSERT( cont.lower_bound(2) != cont.end() );
   1.386 +    CPPUNIT_ASSERT( cont.upper_bound(2) != cont.end() );
   1.387 +    CPPUNIT_ASSERT( cont.equal_range(2) != make_pair(cont.begin(), cont.end()) );
   1.388 +
   1.389 +    Container const& ccont = cont;
   1.390 +    CPPUNIT_ASSERT( ccont.find(2) != ccont.end() );
   1.391 +    CPPUNIT_ASSERT( ccont.lower_bound(2) != ccont.end() );
   1.392 +    CPPUNIT_ASSERT( ccont.upper_bound(2) != ccont.end() );
   1.393 +    CPPUNIT_ASSERT( ccont.equal_range(2) != make_pair(ccont.end(), ccont.end()) );
   1.394 +  }
   1.395 +
   1.396 +  {
   1.397 +    typedef map<Key*, int, KeyCmpPtr> Container;
   1.398 +    typedef Container::value_type value;
   1.399 +    Container cont;
   1.400 +    Key key1(1), key2(2), key3(3), key4(4);
   1.401 +    cont.insert(value(&key1, 1));
   1.402 +    cont.insert(value(&key2, 2));
   1.403 +    cont.insert(value(&key3, 3));
   1.404 +    cont.insert(value(&key4, 4));
   1.405 +
   1.406 +    CPPUNIT_ASSERT( cont.count(1) == 1 );
   1.407 +    CPPUNIT_ASSERT( cont.count(5) == 0 );
   1.408 +
   1.409 +    CPPUNIT_ASSERT( cont.find(2) != cont.end() );
   1.410 +    CPPUNIT_ASSERT( cont.lower_bound(2) != cont.end() );
   1.411 +    CPPUNIT_ASSERT( cont.upper_bound(2) != cont.end() );
   1.412 +    CPPUNIT_ASSERT( cont.equal_range(2) != make_pair(cont.begin(), cont.end()) );
   1.413 +
   1.414 +    Container const& ccont = cont;
   1.415 +    CPPUNIT_ASSERT( ccont.find(2) != ccont.end() );
   1.416 +    CPPUNIT_ASSERT( ccont.lower_bound(2) != ccont.end() );
   1.417 +    CPPUNIT_ASSERT( ccont.upper_bound(2) != ccont.end() );
   1.418 +    CPPUNIT_ASSERT( ccont.equal_range(2) != make_pair(ccont.begin(), ccont.end()) );
   1.419 +  }
   1.420 +  {
   1.421 +    typedef multimap<Key, int, KeyCmp> Container;
   1.422 +    typedef Container::value_type value;
   1.423 +    Container cont;
   1.424 +    cont.insert(value(Key(1), 1));
   1.425 +    cont.insert(value(Key(2), 2));
   1.426 +    cont.insert(value(Key(3), 3));
   1.427 +    cont.insert(value(Key(4), 4));
   1.428 +
   1.429 +    CPPUNIT_ASSERT( cont.count(Key(1)) == 1 );
   1.430 +    CPPUNIT_ASSERT( cont.count(1) == 1 );
   1.431 +    CPPUNIT_ASSERT( cont.count(5) == 0 );
   1.432 +
   1.433 +    CPPUNIT_ASSERT( cont.find(2) != cont.end() );
   1.434 +    CPPUNIT_ASSERT( cont.lower_bound(2) != cont.end() );
   1.435 +    CPPUNIT_ASSERT( cont.upper_bound(2) != cont.end() );
   1.436 +    CPPUNIT_ASSERT( cont.equal_range(2) != make_pair(cont.begin(), cont.end()) );
   1.437 +
   1.438 +    Container const& ccont = cont;
   1.439 +    CPPUNIT_ASSERT( ccont.find(2) != ccont.end() );
   1.440 +    CPPUNIT_ASSERT( ccont.lower_bound(2) != ccont.end() );
   1.441 +    CPPUNIT_ASSERT( ccont.upper_bound(2) != ccont.end() );
   1.442 +    CPPUNIT_ASSERT( ccont.equal_range(2) != make_pair(ccont.end(), ccont.end()) );
   1.443 +  }
   1.444 +
   1.445 +  {
   1.446 +    typedef multimap<Key const volatile*, int, KeyCmpPtr> Container;
   1.447 +    typedef Container::value_type value;
   1.448 +    Container cont;
   1.449 +    Key key1(1), key2(2), key3(3), key4(4);
   1.450 +    cont.insert(value(&key1, 1));
   1.451 +    cont.insert(value(&key2, 2));
   1.452 +    cont.insert(value(&key3, 3));
   1.453 +    cont.insert(value(&key4, 4));
   1.454 +
   1.455 +    CPPUNIT_ASSERT( cont.count(1) == 1 );
   1.456 +    CPPUNIT_ASSERT( cont.count(5) == 0 );
   1.457 +
   1.458 +    CPPUNIT_ASSERT( cont.find(2) != cont.end() );
   1.459 +    CPPUNIT_ASSERT( cont.lower_bound(2) != cont.end() );
   1.460 +    CPPUNIT_ASSERT( cont.upper_bound(2) != cont.end() );
   1.461 +    CPPUNIT_ASSERT( cont.equal_range(2) != make_pair(cont.begin(), cont.end()) );
   1.462 +
   1.463 +    Container const& ccont = cont;
   1.464 +    CPPUNIT_ASSERT( ccont.find(2) != ccont.end() );
   1.465 +    CPPUNIT_ASSERT( ccont.lower_bound(2) != ccont.end() );
   1.466 +    CPPUNIT_ASSERT( ccont.upper_bound(2) != ccont.end() );
   1.467 +    CPPUNIT_ASSERT( ccont.equal_range(2) != make_pair(ccont.begin(), ccont.end()) );
   1.468 +  }
   1.469 +#endif
   1.470 +}
   1.471 +
   1.472 +void MapTest::map_cov1()
   1.473 +	{
   1.474 +	  __UHEAP_MARK;
   1.475 +		{
   1.476 +		map<int, int> m1;
   1.477 +	    map<int, int>::size_type i;
   1.478 +	    typedef pair<int, int> Int_Pair;
   1.479 +	    m1.insert(Int_Pair(1, 1));
   1.480 +	    m1.insert(Int_Pair(2, 4));
   1.481 +
   1.482 +	    i = m1.size();
   1.483 +	    CPPUNIT_ASSERT( i==2 );
   1.484 +	    m1.clear();
   1.485 +	    i = m1.size();
   1.486 +	    CPPUNIT_ASSERT( i==0 );
   1.487 +		}
   1.488 +		{
   1.489 +		map <int, int> m1, m2;
   1.490 +		bool flag;
   1.491 +		typedef pair <int, int> Int_Pair;
   1.492 +		
   1.493 +		m1.insert ( Int_Pair ( 1, 1 ) );
   1.494 +		flag = m1.empty();
   1.495 +		CPPUNIT_ASSERT( flag==false );
   1.496 +		flag = m2.empty();
   1.497 +		CPPUNIT_ASSERT( flag==true );
   1.498 +		}
   1.499 +		{
   1.500 +		map <int, int> m1;
   1.501 +		map <int, int> :: iterator m1_Iter;
   1.502 +		map <int, int> :: reverse_iterator m1_rIter;
   1.503 +		typedef pair <int, int> Int_Pair;
   1.504 +		
   1.505 +		m1.insert ( Int_Pair ( 1, 10 ) );
   1.506 + 	    m1.insert ( Int_Pair ( 2, 20 ) );
   1.507 +		m1.insert ( Int_Pair ( 3, 30 ) );
   1.508 +		m1_rIter = m1.rbegin( );
   1.509 +		CPPUNIT_ASSERT( m1_rIter->first == 3 );
   1.510 +		m1_rIter = m1.rend( );
   1.511 +		m1_rIter--;
   1.512 +		CPPUNIT_ASSERT( m1_rIter->first == 1 );
   1.513 +		}	
   1.514 +		  __UHEAP_MARKEND;
   1.515 +	}
   1.516 +void MapTest::map_cov2()
   1.517 +	{
   1.518 +	  __UHEAP_MARK;
   1.519 +		{
   1.520 +		map<int, int> m1, m2, m3;
   1.521 +	    map<int, int>::iterator pIter, Iter1, Iter2;
   1.522 +	    int i;
   1.523 +	    typedef pair<int, int> Int_Pair;
   1.524 +	    
   1.525 +	    for (i = 1; i < 5; i++)
   1.526 +	        {
   1.527 +	        m1.insert(Int_Pair(i, i));
   1.528 +	        m2.insert(Int_Pair(i, i*i));
   1.529 +	        m3.insert(Int_Pair(i, i-1));
   1.530 +	        }
   1.531 +	    Iter1 = ++m1.begin();
   1.532 +	    m1.erase(Iter1);
   1.533 +
   1.534 +	    pIter = m1.begin(); 
   1.535 +	    CPPUNIT_ASSERT( pIter->second == 1 );
   1.536 +	    pIter++;
   1.537 +	    CPPUNIT_ASSERT( pIter->second == 3 );
   1.538 +	    pIter++;
   1.539 +	    CPPUNIT_ASSERT( pIter->second == 4 );
   1.540 +	    
   1.541 +	    Iter1 = ++m2.begin();
   1.542 +	    Iter2 = --m2.end();
   1.543 +	    m2.erase(Iter1, Iter2);
   1.544 +	    pIter = m2.begin(); 
   1.545 +	    CPPUNIT_ASSERT( pIter->second == 1 );
   1.546 +	    pIter++;
   1.547 +	    CPPUNIT_ASSERT( pIter->second == 16 );
   1.548 +	    
   1.549 +	    map<int, int>::size_type n = m3.erase(2);
   1.550 +	    pIter = m3.begin(); 
   1.551 +	    CPPUNIT_ASSERT( pIter->second == 0 );
   1.552 +	    pIter++;
   1.553 +	    CPPUNIT_ASSERT( pIter->second == 2 );
   1.554 +	    pIter++;
   1.555 +	    CPPUNIT_ASSERT( pIter->second == 3 );
   1.556 +		}
   1.557 +		{
   1.558 +		map <int, int> m1;
   1.559 +		m1.max_size( );
   1.560 +		}
   1.561 +		  __UHEAP_MARKEND;
   1.562 +	}
   1.563 +void MapTest::map_cov3()
   1.564 +	{
   1.565 +	  __UHEAP_MARK;
   1.566 +		{
   1.567 +		map <int, int> m1;
   1.568 +
   1.569 +		map <int, int> :: iterator m1_Iter;
   1.570 +		map <int, int> :: reverse_iterator m1_rIter;
   1.571 +		map <int, int> :: const_reverse_iterator m1_crIter;
   1.572 +		typedef pair <int, int> Int_Pair;
   1.573 +	
   1.574 +		m1.insert ( Int_Pair ( 1, 10 ) );
   1.575 + 	    m1.insert ( Int_Pair ( 2, 20 ) );
   1.576 +		m1.insert ( Int_Pair ( 3, 30 ) );
   1.577 +		m1_crIter = m1.rbegin( );
   1.578 +		CPPUNIT_ASSERT( m1_crIter->first == 3 );
   1.579 +		m1_crIter = m1.rend( );
   1.580 +		m1_crIter--;
   1.581 +		CPPUNIT_ASSERT( m1_crIter->first == 1 );
   1.582 +		}
   1.583 +		{
   1.584 +		map <int, int, less<int> > m1;
   1.585 +		map <int, int, less<int> >::value_compare vc1 = m1.value_comp( );
   1.586 +		pair< map<int,int>::iterator, bool > pr1, pr2;
   1.587 +		   
   1.588 +		pr1= m1.insert ( map <int, int> :: value_type ( 1, 10 ) );
   1.589 +		pr2= m1.insert ( map <int, int> :: value_type ( 2, 5 ) );
   1.590 +
   1.591 +		CPPUNIT_ASSERT( vc1( *pr1.first, *pr2.first ) == true );
   1.592 +		}
   1.593 +		{
   1.594 +		map <int, int> m1, m2;
   1.595 +		typedef pair <int, int> Int_Pair;
   1.596 +		map <int, int>::iterator m2_Iter;
   1.597 +		map<int, int>::size_type i;
   1.598 +    	m1.insert ( Int_Pair ( 1, 10 ) );
   1.599 +		m1.insert ( Int_Pair ( 2, 20 ) );
   1.600 +		m1.insert ( Int_Pair ( 3, 30 ) );
   1.601 +		m2=m1;
   1.602 +		m2_Iter = m2.begin( ); 
   1.603 +		CPPUNIT_ASSERT(m2_Iter -> second == 10);
   1.604 +	    i = m2.size();
   1.605 +		CPPUNIT_ASSERT(i == 3);			
   1.606 +		}
   1.607 +		  __UHEAP_MARKEND;
   1.608 +	}
   1.609 +void MapTest::map_cov4()
   1.610 +	{
   1.611 +	  __UHEAP_MARK;
   1.612 +		{
   1.613 +		map <int, int> m1, m3;
   1.614 +		map <int, int>::iterator m1_Iter;
   1.615 +		typedef pair <int, int> Int_Pair;
   1.616 +
   1.617 +		m1.insert ( Int_Pair ( 1, 10 ) );
   1.618 +		m1.insert ( Int_Pair ( 2, 20 ) );
   1.619 +		m1.insert ( Int_Pair ( 3, 30 ) );
   1.620 +		m3.insert ( Int_Pair ( 30, 300 ) );
   1.621 +		
   1.622 +		swap(m1,m3);
   1.623 +		m1_Iter = m1.begin();
   1.624 +		
   1.625 +		CPPUNIT_ASSERT(m1_Iter -> second == 300);
   1.626 +		}
   1.627 +		{
   1.628 +		map <int, int> m1, m3;
   1.629 +		typedef pair <int, int> Int_Pair;
   1.630 +
   1.631 +		m1.insert ( Int_Pair ( 1, 10 ) );
   1.632 +		m3.insert ( Int_Pair ( 30, 300 ) );
   1.633 +		
   1.634 +		bool x = m1 < m3;
   1.635 +		CPPUNIT_ASSERT(x == true);
   1.636 +		}
   1.637 +		  __UHEAP_MARKEND;
   1.638 +	}
   1.639 +
   1.640 +void MapTest::multimap_cov1()
   1.641 +	{
   1.642 +	  __UHEAP_MARK;
   1.643 +		{
   1.644 +		multimap<int, int> m1;
   1.645 +		multimap<int, int>::size_type i;
   1.646 +		typedef pair<int, int> Int_Pair;
   1.647 +
   1.648 +		m1.insert(Int_Pair(1, 1));
   1.649 +		m1.insert(Int_Pair(2, 4));
   1.650 +
   1.651 +		i = m1.size();
   1.652 +	    CPPUNIT_ASSERT( i==2 );
   1.653 +	    m1.clear();
   1.654 +	    i = m1.size();
   1.655 +	    CPPUNIT_ASSERT( i==0 );
   1.656 +		}
   1.657 +		{
   1.658 +		multimap <int, int> m1, m2;
   1.659 +		bool flag;
   1.660 +		typedef pair <int, int> Int_Pair;
   1.661 +		
   1.662 +		m1.insert ( Int_Pair ( 1, 1 ) );
   1.663 +		flag = m1.empty();
   1.664 +		CPPUNIT_ASSERT( flag==false );
   1.665 +		flag = m2.empty();
   1.666 +		CPPUNIT_ASSERT( flag==true );
   1.667 +		}
   1.668 +		{
   1.669 +		multimap <int, int>::allocator_type m1_Alloc;
   1.670 +		multimap <int, int>::allocator_type m2_Alloc;
   1.671 +		multimap <int, int>::allocator_type m4_Alloc;
   1.672 +	
   1.673 +		multimap <int, int> m1;
   1.674 +		multimap <int, int, allocator<int> > m2;
   1.675 +		m1_Alloc = m1.get_allocator( );
   1.676 +		m2_Alloc = m2.get_allocator( );
   1.677 +		map <int, int> m4( less<int>( ), m1_Alloc );
   1.678 +		m4_Alloc = m4.get_allocator( );
   1.679 +	
   1.680 +		CPPUNIT_ASSERT( m1_Alloc == m4_Alloc );
   1.681 +		}
   1.682 +		  __UHEAP_MARKEND;
   1.683 +	}
   1.684 +void MapTest::multimap_cov2()
   1.685 +	{
   1.686 +	  __UHEAP_MARK;
   1.687 +		{
   1.688 +		multimap<int, int> m1, m2;
   1.689 +		multimap<int, int>::iterator pIter, Iter1, Iter2;
   1.690 +	    int i;
   1.691 +	    typedef pair<int, int> Int_Pair;
   1.692 +	    
   1.693 +	    for (i = 1; i < 5; i++)
   1.694 +	        {
   1.695 +	        m1.insert(Int_Pair(i, i));
   1.696 +	        m2.insert(Int_Pair(i, i*i));
   1.697 +	        }
   1.698 +	    Iter1 = ++m1.begin();
   1.699 +	    m1.erase(Iter1);
   1.700 +
   1.701 +	    pIter = m1.begin(); 
   1.702 +	    CPPUNIT_ASSERT( pIter->second == 1 );
   1.703 +	    pIter++;
   1.704 +	    CPPUNIT_ASSERT( pIter->second == 3 );
   1.705 +	    pIter++;
   1.706 +	    CPPUNIT_ASSERT( pIter->second == 4 );
   1.707 +	    
   1.708 +	    Iter1 = ++m2.begin();
   1.709 +	    Iter2 = --m2.end();
   1.710 +	    m2.erase(Iter1, Iter2);
   1.711 +	    pIter = m2.begin(); 
   1.712 +	    CPPUNIT_ASSERT( pIter->second == 1 );
   1.713 +	    pIter++;
   1.714 +	    CPPUNIT_ASSERT( pIter->second == 16 );
   1.715 +		}
   1.716 +		{
   1.717 +		multimap <int, int>::iterator m1_pIter, m2_pIter;
   1.718 +		multimap <int, int> :: reverse_iterator m1_rIter;
   1.719 +		multimap <int, int> m1, m2;
   1.720 +		typedef pair <int, int> Int_Pair;
   1.721 +		
   1.722 +		m1.insert ( Int_Pair ( 1, 10 ) );
   1.723 +		m1.insert ( Int_Pair ( 2, 20 ) );
   1.724 +		m1.insert ( Int_Pair ( 3, 30 ) );
   1.725 +		m1.insert( --m1.end( ), Int_Pair ( 4, 40 )  );
   1.726 +		
   1.727 +		m1_rIter = m1.rbegin( );
   1.728 +		CPPUNIT_ASSERT( m1_rIter->first == 4 );
   1.729 +
   1.730 +		m2.insert ( Int_Pair ( 10, 100 ) );
   1.731 +		m2.insert( ++m1.begin( ), --m1.end( ) );
   1.732 +		m2_pIter = m2.begin( ); 
   1.733 +		CPPUNIT_ASSERT(m2_pIter -> first == 2);
   1.734 +		}
   1.735 +		{
   1.736 +		multimap <int, int> m1;
   1.737 +		m1.max_size( );
   1.738 +		}
   1.739 +		  __UHEAP_MARKEND;
   1.740 +	}
   1.741 +void MapTest::multimap_cov3()
   1.742 +	{
   1.743 +	  __UHEAP_MARK;
   1.744 +		{
   1.745 +		multimap <int, int, less<int> > m1;
   1.746 +		multimap <int, int, less<int> >::key_compare kc1 = m1.key_comp( ) ;
   1.747 +		bool result1 = kc1( 2, 3 ) ;
   1.748 +		CPPUNIT_ASSERT(result1 == true);
   1.749 +		
   1.750 +		multimap <int, int, greater_equal<int> > m2;
   1.751 +		multimap <int, int, greater_equal<int> >::key_compare kc2 = m2.key_comp( );
   1.752 +		bool result2 = kc2( 3, 3 ) ;
   1.753 +		CPPUNIT_ASSERT(result1 == true);
   1.754 +		}
   1.755 +		{
   1.756 +	    multimap<int, int> m1, m2;
   1.757 +	    multimap<int, int>::size_type i;
   1.758 +	    typedef pair<int, int> Int_Pair;
   1.759 +
   1.760 +	    m1.insert(Int_Pair(1, 1));
   1.761 +	    i = m1.size();
   1.762 +		CPPUNIT_ASSERT(i == 1);			
   1.763 +	    m1.insert(Int_Pair(2, 4));
   1.764 +	    i = m1.size();
   1.765 +		CPPUNIT_ASSERT(i == 2);			
   1.766 +		}
   1.767 +		{
   1.768 +		multimap <int, int> m1, m2;
   1.769 +		multimap <int, int>::iterator m1_Iter;
   1.770 +		typedef pair <int, int> Int_Pair;
   1.771 +	    multimap<int, int>::size_type i;
   1.772 +	    
   1.773 +    	m1.insert ( Int_Pair ( 1, 10 ) );
   1.774 +		m1.insert ( Int_Pair ( 2, 20 ) );
   1.775 +		m1.insert ( Int_Pair ( 3, 30 ) );
   1.776 +		m2.insert ( Int_Pair ( 30, 300 ) );
   1.777 +		m1.swap( m2 );
   1.778 +		m1_Iter = m1.begin( ); 
   1.779 +		CPPUNIT_ASSERT(m1_Iter -> second == 300);
   1.780 +	    i = m1.size();
   1.781 +		CPPUNIT_ASSERT(i == 1);			
   1.782 +		}
   1.783 +		  __UHEAP_MARKEND;
   1.784 +	}
   1.785 +void MapTest::multimap_cov4()
   1.786 +	{
   1.787 +	  __UHEAP_MARK;
   1.788 +		{
   1.789 +		multimap <int, int, less<int> > m1;
   1.790 +		multimap <int, int, less<int> >::value_compare vc1 = m1.value_comp( );
   1.791 +		multimap<int,int>::iterator Iter1, Iter2;
   1.792 +
   1.793 +		Iter1= m1.insert ( multimap <int, int> :: value_type ( 1, 10 ) );
   1.794 +		Iter2= m1.insert ( multimap <int, int> :: value_type ( 2, 5 ) );
   1.795 +		CPPUNIT_ASSERT( vc1( *Iter1, *Iter2 ) == true );
   1.796 +		}
   1.797 +		{
   1.798 +		multimap <int, int> m1, m2;
   1.799 +		typedef pair <int, int> Int_Pair;
   1.800 +		multimap <int, int>::iterator m2_Iter;
   1.801 +	    multimap<int, int>::size_type i;
   1.802 +	    
   1.803 +    	m1.insert ( Int_Pair ( 1, 10 ) );
   1.804 +		m1.insert ( Int_Pair ( 2, 20 ) );
   1.805 +		m1.insert ( Int_Pair ( 3, 30 ) );
   1.806 +		
   1.807 +		m2=m1;
   1.808 +		m2_Iter = m2.begin( ); 
   1.809 +		CPPUNIT_ASSERT(m2_Iter -> second == 10);
   1.810 +	    i = m2.size();
   1.811 +		CPPUNIT_ASSERT(i == 3);			
   1.812 +
   1.813 +		}
   1.814 +		{
   1.815 +		multimap <int, int> m1, m2;
   1.816 +		multimap <int, int>::iterator m1_Iter;
   1.817 +		typedef pair <int, int> Int_Pair;
   1.818 +	    multimap<int, int>::size_type i;
   1.819 +	    
   1.820 +    	m1.insert ( Int_Pair ( 1, 10 ) );
   1.821 +		m1.insert ( Int_Pair ( 2, 20 ) );
   1.822 +		m1.insert ( Int_Pair ( 3, 30 ) );
   1.823 +		m2.insert ( Int_Pair ( 30, 300 ) );
   1.824 +		swap( m1,m2 );
   1.825 +		m1_Iter = m1.begin( ); 
   1.826 +		CPPUNIT_ASSERT(m1_Iter -> second == 300);
   1.827 +	    i = m1.size();
   1.828 +		CPPUNIT_ASSERT(i == 1);			
   1.829 +		}
   1.830 +		{
   1.831 +		multimap <int, int> m1, m2;
   1.832 +		typedef pair <int, int> Int_Pair;
   1.833 +	    
   1.834 +    	m1.insert ( Int_Pair ( 1, 10 ) );
   1.835 +		m2.insert ( Int_Pair ( 30, 300 ) );
   1.836 +		
   1.837 +		bool val = m1 < m2;
   1.838 +		CPPUNIT_ASSERT(val == true);
   1.839 +		val = (m1 == m2);
   1.840 +		CPPUNIT_ASSERT(val == false);
   1.841 +		}
   1.842 +		  __UHEAP_MARKEND;
   1.843 +	}