| 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 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 |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // UNSUPPORTED: c++03 |
| 10 | |
| 11 | // <map> |
| 12 | |
| 13 | // class map |
| 14 | |
| 15 | // map(initializer_list<value_type> il, const key_compare& comp); |
| 16 | |
| 17 | #include <map> |
| 18 | #include <cassert> |
| 19 | #include "test_macros.h" |
| 20 | #include "../../../test_compare.h" |
| 21 | #include "min_allocator.h" |
| 22 | |
| 23 | int main(int, char**) { |
| 24 | { |
| 25 | typedef std::pair<const int, double> V; |
| 26 | typedef test_less<int> C; |
| 27 | std::map<int, double, C> m({{1, 1}, {1, 1.5}, {1, 2}, {2, 1}, {2, 1.5}, {2, 2}, {3, 1}, {3, 1.5}, {3, 2}}, C(3)); |
| 28 | assert(m.size() == 3); |
| 29 | assert(std::distance(m.begin(), m.end()) == 3); |
| 30 | assert(*m.begin() == V(1, 1)); |
| 31 | assert(*std::next(m.begin()) == V(2, 1)); |
| 32 | assert(*std::next(m.begin(), 2) == V(3, 1)); |
| 33 | assert(m.key_comp() == C(3)); |
| 34 | } |
| 35 | { |
| 36 | typedef std::pair<const int, double> V; |
| 37 | typedef test_less<int> C; |
| 38 | std::map<int, double, C, min_allocator<std::pair<const int, double>>> m( |
| 39 | {{1, 1}, {1, 1.5}, {1, 2}, {2, 1}, {2, 1.5}, {2, 2}, {3, 1}, {3, 1.5}, {3, 2}}, C(3)); |
| 40 | assert(m.size() == 3); |
| 41 | assert(std::distance(m.begin(), m.end()) == 3); |
| 42 | assert(*m.begin() == V(1, 1)); |
| 43 | assert(*std::next(m.begin()) == V(2, 1)); |
| 44 | assert(*std::next(m.begin(), 2) == V(3, 1)); |
| 45 | assert(m.key_comp() == C(3)); |
| 46 | } |
| 47 | |
| 48 | return 0; |
| 49 | } |
| 50 | |