Home | History | Annotate | Download | only in multiset.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 // <set>
     11 
     12 // class multiset
     13 
     14 // template <class InputIterator>
     15 //     multiset(InputIterator first, InputIterator last,
     16 //         const value_compare& comp, const allocator_type& a);
     17 
     18 #include <set>
     19 #include <cassert>
     20 
     21 #include "test_macros.h"
     22 #include "test_iterators.h"
     23 #include "../../../test_compare.h"
     24 #include "test_allocator.h"
     25 
     26 int main()
     27 {
     28     {
     29     typedef int V;
     30     V ar[] =
     31     {
     32         1,
     33         1,
     34         1,
     35         2,
     36         2,
     37         2,
     38         3,
     39         3,
     40         3
     41     };
     42     typedef test_compare<std::less<V> > C;
     43     typedef test_allocator<V> A;
     44     std::multiset<V, C, A> m(input_iterator<const V*>(ar),
     45                         input_iterator<const V*>(ar+sizeof(ar)/sizeof(ar[0])),
     46                         C(5), A(7));
     47     assert(m.value_comp() == C(5));
     48     assert(m.get_allocator() == A(7));
     49     assert(m.size() == 9);
     50     assert(distance(m.begin(), m.end()) == 9);
     51     assert(*next(m.begin(), 0) == 1);
     52     assert(*next(m.begin(), 1) == 1);
     53     assert(*next(m.begin(), 2) == 1);
     54     assert(*next(m.begin(), 3) == 2);
     55     assert(*next(m.begin(), 4) == 2);
     56     assert(*next(m.begin(), 5) == 2);
     57     assert(*next(m.begin(), 6) == 3);
     58     assert(*next(m.begin(), 7) == 3);
     59     assert(*next(m.begin(), 8) == 3);
     60     }
     61 #if TEST_STD_VER > 11
     62     {
     63     typedef int V;
     64     V ar[] =
     65     {
     66         1,
     67         1,
     68         1,
     69         2,
     70         2,
     71         2,
     72         3,
     73         3,
     74         3
     75     };
     76     typedef test_allocator<V> A;
     77     typedef test_compare<std::less<int> > C;
     78     A a;
     79     std::multiset<V, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a);
     80 
     81     assert(m.size() == 9);
     82     assert(distance(m.begin(), m.end()) == 9);
     83     assert(*next(m.begin(), 0) == 1);
     84     assert(*next(m.begin(), 1) == 1);
     85     assert(*next(m.begin(), 2) == 1);
     86     assert(*next(m.begin(), 3) == 2);
     87     assert(*next(m.begin(), 4) == 2);
     88     assert(*next(m.begin(), 5) == 2);
     89     assert(*next(m.begin(), 6) == 3);
     90     assert(*next(m.begin(), 7) == 3);
     91     assert(*next(m.begin(), 8) == 3);
     92     assert(m.get_allocator() == a);
     93     }
     94 #endif
     95 }
     96