Home | History | Annotate | Download | only in unord.multiset
      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 // <unordered_set>
     11 
     12 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
     13 //           class Alloc = allocator<Value>>
     14 // class unordered_multiset
     15 
     16 // iterator       begin();
     17 // iterator       end();
     18 // const_iterator begin()  const;
     19 // const_iterator end()    const;
     20 // const_iterator cbegin() const;
     21 // const_iterator cend()   const;
     22 
     23 #include <unordered_set>
     24 #include <cassert>
     25 #include <cstddef>
     26 
     27 #include "test_macros.h"
     28 #include "min_allocator.h"
     29 
     30 int main()
     31 {
     32     {
     33         typedef std::unordered_multiset<int> C;
     34         typedef int P;
     35         P a[] =
     36         {
     37             P(1),
     38             P(2),
     39             P(3),
     40             P(4),
     41             P(1),
     42             P(2)
     43         };
     44         C c(a, a + sizeof(a)/sizeof(a[0]));
     45         assert(c.bucket_count() >= 7);
     46         assert(c.size() == 6);
     47         assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size());
     48         assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size());
     49         C::iterator i;
     50     }
     51     {
     52         typedef std::unordered_multiset<int> C;
     53         typedef int P;
     54         P a[] =
     55         {
     56             P(1),
     57             P(2),
     58             P(3),
     59             P(4),
     60             P(1),
     61             P(2)
     62         };
     63         const C c(a, a + sizeof(a)/sizeof(a[0]));
     64         assert(c.bucket_count() >= 7);
     65         assert(c.size() == 6);
     66         assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size());
     67         assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size());
     68         C::const_iterator i;
     69     }
     70 #if TEST_STD_VER >= 11
     71     {
     72         typedef std::unordered_multiset<int, std::hash<int>,
     73                                       std::equal_to<int>, min_allocator<int>> C;
     74         typedef int P;
     75         P a[] =
     76         {
     77             P(1),
     78             P(2),
     79             P(3),
     80             P(4),
     81             P(1),
     82             P(2)
     83         };
     84         C c(a, a + sizeof(a)/sizeof(a[0]));
     85         assert(c.bucket_count() >= 7);
     86         assert(c.size() == 6);
     87         assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size());
     88         assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size());
     89         C::iterator i;
     90     }
     91     {
     92         typedef std::unordered_multiset<int, std::hash<int>,
     93                                       std::equal_to<int>, min_allocator<int>> C;
     94         typedef int P;
     95         P a[] =
     96         {
     97             P(1),
     98             P(2),
     99             P(3),
    100             P(4),
    101             P(1),
    102             P(2)
    103         };
    104         const C c(a, a + sizeof(a)/sizeof(a[0]));
    105         assert(c.bucket_count() >= 7);
    106         assert(c.size() == 6);
    107         assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size());
    108         assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size());
    109         C::const_iterator i;
    110     }
    111 #endif
    112 #if TEST_STD_VER > 11
    113     { // N3644 testing
    114         typedef std::unordered_multiset<int> C;
    115         C::iterator ii1{}, ii2{};
    116         C::iterator ii4 = ii1;
    117         C::const_iterator cii{};
    118         assert ( ii1 == ii2 );
    119         assert ( ii1 == ii4 );
    120 
    121         assert (!(ii1 != ii2 ));
    122 
    123         assert ( (ii1 == cii ));
    124         assert ( (cii == ii1 ));
    125         assert (!(ii1 != cii ));
    126         assert (!(cii != ii1 ));
    127     }
    128 #endif
    129 }
    130