1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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_map
16 // mapped_type& at(const key_type& k);
17 // const mapped_type& at(const key_type& k) const;
19 #include <unordered_map>
24 #include "min_allocator.h"
25 #include "test_macros.h"
30 typedef std::unordered_map<int, std::string> C;
31 typedef std::pair<int, std::string> P;
41 C c(a, a + sizeof(a)/sizeof(a[0]));
42 assert(c.size() == 4);
44 assert(c.at(1) == "ONE");
45 #ifndef TEST_HAS_NO_EXCEPTIONS
51 catch (std::out_of_range&)
54 assert(c.size() == 4);
58 typedef std::unordered_map<int, std::string> C;
59 typedef std::pair<int, std::string> P;
69 const C c(a, a + sizeof(a)/sizeof(a[0]));
70 assert(c.size() == 4);
71 assert(c.at(1) == "one");
72 #ifndef TEST_HAS_NO_EXCEPTIONS
78 catch (std::out_of_range&)
81 assert(c.size() == 4);
84 #if TEST_STD_VER >= 11
86 typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
87 min_allocator<std::pair<const int, std::string>>> C;
88 typedef std::pair<int, std::string> P;
98 C c(a, a + sizeof(a)/sizeof(a[0]));
99 assert(c.size() == 4);
101 assert(c.at(1) == "ONE");
102 #ifndef TEST_HAS_NO_EXCEPTIONS
108 catch (std::out_of_range&)
111 assert(c.size() == 4);
115 typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
116 min_allocator<std::pair<const int, std::string>>> C;
117 typedef std::pair<int, std::string> P;
127 const C c(a, a + sizeof(a)/sizeof(a[0]));
128 assert(c.size() == 4);
129 assert(c.at(1) == "one");
130 #ifndef TEST_HAS_NO_EXCEPTIONS
136 catch (std::out_of_range&)
139 assert(c.size() == 4);