Home | History | Annotate | Download | only in unord.multiset.cnstr
      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 // unordered_multiset(const unordered_multiset& u, const allocator_type& a);
     17 
     18 #include <unordered_set>
     19 #include <cassert>
     20 #include <cfloat>
     21 
     22 #include "../../../test_compare.h"
     23 #include "../../../test_hash.h"
     24 #include "../../../test_allocator.h"
     25 
     26 int main()
     27 {
     28     {
     29         typedef std::unordered_multiset<int,
     30                                    test_hash<std::hash<int> >,
     31                                    test_compare<std::equal_to<int> >,
     32                                    test_allocator<int>
     33                                    > 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 c0(a, a + sizeof(a)/sizeof(a[0]),
     45             7,
     46             test_hash<std::hash<int> >(8),
     47             test_compare<std::equal_to<int> >(9),
     48             test_allocator<int>(10)
     49            );
     50         C c(c0, test_allocator<int>(5));
     51         assert(c.bucket_count() == 7);
     52         assert(c.size() == 6);
     53         C::const_iterator i = c.cbegin();
     54         assert(*i == 1);
     55         ++i;
     56         assert(*i == 1);
     57         ++i;
     58         assert(*i == 2);
     59         ++i;
     60         assert(*i == 2);
     61         ++i;
     62         assert(*i == 3);
     63         ++i;
     64         assert(*i == 4);
     65         assert(c.hash_function() == test_hash<std::hash<int> >(8));
     66         assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
     67         assert(c.get_allocator() == test_allocator<int>(5));
     68         assert(!c.empty());
     69         assert(std::distance(c.begin(), c.end()) == c.size());
     70         assert(std::distance(c.cbegin(), c.cend()) == c.size());
     71         assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
     72         assert(c.max_load_factor() == 1);
     73     }
     74 }
     75