Home | History | Annotate | Download | only in multimap.cons
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // <map>
     11 
     12 // class multimap
     13 
     14 // multimap(const multimap& m);
     15 
     16 #include <map>
     17 #include <cassert>
     18 
     19 #include "test_macros.h"
     20 #include "../../../test_compare.h"
     21 #include "test_allocator.h"
     22 #include "min_allocator.h"
     23 
     24 int main()
     25 {
     26     {
     27         typedef std::pair<const int, double> V;
     28         V ar[] =
     29         {
     30             V(1, 1),
     31             V(1, 1.5),
     32             V(1, 2),
     33             V(2, 1),
     34             V(2, 1.5),
     35             V(2, 2),
     36             V(3, 1),
     37             V(3, 1.5),
     38             V(3, 2),
     39         };
     40         typedef test_compare<std::less<int> > C;
     41         typedef test_allocator<V> A;
     42         std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
     43         std::multimap<int, double, C, A> m = mo;
     44         assert(m == mo);
     45         assert(m.get_allocator() == A(7));
     46         assert(m.key_comp() == C(5));
     47 
     48         assert(mo.get_allocator() == A(7));
     49         assert(mo.key_comp() == C(5));
     50     }
     51 #if TEST_STD_VER >= 11
     52     {
     53         typedef std::pair<const int, double> V;
     54         V ar[] =
     55         {
     56             V(1, 1),
     57             V(1, 1.5),
     58             V(1, 2),
     59             V(2, 1),
     60             V(2, 1.5),
     61             V(2, 2),
     62             V(3, 1),
     63             V(3, 1.5),
     64             V(3, 2),
     65         };
     66         typedef test_compare<std::less<int> > C;
     67         typedef other_allocator<V> A;
     68         std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
     69         std::multimap<int, double, C, A> m = mo;
     70         assert(m == mo);
     71         assert(m.get_allocator() == A(-2));
     72         assert(m.key_comp() == C(5));
     73 
     74         assert(mo.get_allocator() == A(7));
     75         assert(mo.key_comp() == C(5));
     76     }
     77     {
     78         typedef std::pair<const int, double> V;
     79         V ar[] =
     80         {
     81             V(1, 1),
     82             V(1, 1.5),
     83             V(1, 2),
     84             V(2, 1),
     85             V(2, 1.5),
     86             V(2, 2),
     87             V(3, 1),
     88             V(3, 1.5),
     89             V(3, 2),
     90         };
     91         typedef test_compare<std::less<int> > C;
     92         typedef min_allocator<V> A;
     93         std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
     94         std::multimap<int, double, C, A> m = mo;
     95         assert(m == mo);
     96         assert(m.get_allocator() == A());
     97         assert(m.key_comp() == C(5));
     98 
     99         assert(mo.get_allocator() == A());
    100         assert(mo.key_comp() == C(5));
    101     }
    102 #endif
    103 }
    104