1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 // template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
12 // class Alloc = allocator<pair<const Key, T>>>
13 // class unordered_map
15 // mapped_type& at(const key_type& k);
16 // const mapped_type& at(const key_type& k) const;
21 #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
75 TEST_IGNORE_NODISCARD c
.at(11);
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
133 TEST_IGNORE_NODISCARD c
.at(11);
136 catch (std::out_of_range
&)
139 assert(c
.size() == 4);