llvm-project
67 строк · 1.6 Кб
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// <map>
10
11// class multimap
12
13// void clear() noexcept;
14
15#include <map>
16#include <cassert>
17
18#include "test_macros.h"
19#include "min_allocator.h"
20
21int main(int, char**)
22{
23{
24typedef std::multimap<int, double> M;
25typedef std::pair<int, double> P;
26P ar[] =
27{
28P(1, 1.5),
29P(2, 2.5),
30P(3, 3.5),
31P(4, 4.5),
32P(5, 5.5),
33P(6, 6.5),
34P(7, 7.5),
35P(8, 8.5),
36};
37M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
38assert(m.size() == 8);
39ASSERT_NOEXCEPT(m.clear());
40m.clear();
41assert(m.size() == 0);
42}
43#if TEST_STD_VER >= 11
44{
45typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
46typedef std::pair<int, double> P;
47P ar[] =
48{
49P(1, 1.5),
50P(2, 2.5),
51P(3, 3.5),
52P(4, 4.5),
53P(5, 5.5),
54P(6, 6.5),
55P(7, 7.5),
56P(8, 8.5),
57};
58M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
59assert(m.size() == 8);
60ASSERT_NOEXCEPT(m.clear());
61m.clear();
62assert(m.size() == 0);
63}
64#endif
65
66return 0;
67}
68