Home | History | Annotate | Download | only in unord.multimap.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_map>
     11 
     12 // template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
     13 //           class Alloc = allocator<pair<const Key, T>>>
     14 // class unordered_multimap
     15 
     16 // explicit unordered_multimap(const allocator_type& __a);
     17 
     18 #include <unordered_map>
     19 #include <cassert>
     20 
     21 #include "../../../NotConstructible.h"
     22 #include "../../../test_compare.h"
     23 #include "../../../test_hash.h"
     24 #include "test_allocator.h"
     25 #include "min_allocator.h"
     26 
     27 int main()
     28 {
     29     {
     30         typedef std::unordered_multimap<NotConstructible, NotConstructible,
     31                                    test_hash<std::hash<NotConstructible> >,
     32                                    test_compare<std::equal_to<NotConstructible> >,
     33                                    test_allocator<std::pair<const NotConstructible,
     34                                                                   NotConstructible> >
     35                                    > C;
     36         C c(test_allocator<std::pair<const NotConstructible, NotConstructible> >(10));
     37         assert(c.bucket_count() == 0);
     38         assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
     39         assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
     40         assert(c.get_allocator() ==
     41                (test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
     42         assert(c.size() == 0);
     43         assert(c.empty());
     44         assert(std::distance(c.begin(), c.end()) == 0);
     45         assert(c.load_factor() == 0);
     46         assert(c.max_load_factor() == 1);
     47     }
     48 #if __cplusplus >= 201103L
     49     {
     50         typedef std::unordered_multimap<NotConstructible, NotConstructible,
     51                                    test_hash<std::hash<NotConstructible> >,
     52                                    test_compare<std::equal_to<NotConstructible> >,
     53                                    min_allocator<std::pair<const NotConstructible,
     54                                                                   NotConstructible> >
     55                                    > C;
     56         C c(min_allocator<std::pair<const NotConstructible, NotConstructible> >{});
     57         assert(c.bucket_count() == 0);
     58         assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
     59         assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
     60         assert(c.get_allocator() ==
     61                (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
     62         assert(c.size() == 0);
     63         assert(c.empty());
     64         assert(std::distance(c.begin(), c.end()) == 0);
     65         assert(c.load_factor() == 0);
     66         assert(c.max_load_factor() == 1);
     67     }
     68 #if _LIBCPP_STD_VER > 11
     69     {
     70         typedef NotConstructible T;
     71         typedef test_allocator<std::pair<const T, T>> A;
     72         typedef test_hash<std::hash<T>> HF;
     73         typedef test_compare<std::equal_to<T>> Comp;
     74         typedef std::unordered_multimap<T, T, HF, Comp, A> C;
     75 
     76         A a(10);
     77         C c(2, a);
     78         assert(c.bucket_count() == 2);
     79         assert(c.hash_function() == HF());
     80         assert(c.key_eq() == Comp());
     81         assert(c.get_allocator() == a);
     82         assert(c.size() == 0);
     83         assert(c.empty());
     84         assert(std::distance(c.begin(), c.end()) == 0);
     85         assert(c.load_factor() == 0);
     86         assert(c.max_load_factor() == 1);
     87     }
     88     {
     89         typedef NotConstructible T;
     90         typedef test_allocator<std::pair<const T, T>> A;
     91         typedef test_hash<std::hash<T>> HF;
     92         typedef test_compare<std::equal_to<T>> Comp;
     93         typedef std::unordered_multimap<T, T, HF, Comp, A> C;
     94 
     95         A a(10);
     96         HF hf(12);
     97         C c(2, hf, a);
     98         assert(c.bucket_count() == 2);
     99         assert(c.hash_function() == hf);
    100         assert(!(c.hash_function() == HF()));
    101         assert(c.key_eq() == Comp());
    102         assert(c.get_allocator() == a);
    103         assert(c.size() == 0);
    104         assert(c.empty());
    105         assert(std::distance(c.begin(), c.end()) == 0);
    106         assert(c.load_factor() == 0);
    107         assert(c.max_load_factor() == 1);
    108     }
    109 #endif
    110 #endif
    111 }
    112