]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/containers/associative/map/map.modifiers/clear.pass.cpp
Vendor import of libc++ trunk r351319 (just before the release_80
[FreeBSD/FreeBSD.git] / test / std / containers / associative / map / map.modifiers / clear.pass.cpp
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 // <map>
11
12 // class map
13
14 // void clear() noexcept;
15
16 #include <map>
17 #include <cassert>
18
19 #include "test_macros.h"
20 #include "min_allocator.h"
21
22 int main()
23 {
24     {
25         typedef std::map<int, double> M;
26         typedef std::pair<int, double> P;
27         P ar[] =
28         {
29             P(1, 1.5),
30             P(2, 2.5),
31             P(3, 3.5),
32             P(4, 4.5),
33             P(5, 5.5),
34             P(6, 6.5),
35             P(7, 7.5),
36             P(8, 8.5),
37         };
38         M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
39         assert(m.size() == 8);
40         ASSERT_NOEXCEPT(m.clear());
41         m.clear();
42         assert(m.size() == 0);
43     }
44 #if TEST_STD_VER >= 11
45     {
46         typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
47         typedef std::pair<int, double> P;
48         P ar[] =
49         {
50             P(1, 1.5),
51             P(2, 2.5),
52             P(3, 3.5),
53             P(4, 4.5),
54             P(5, 5.5),
55             P(6, 6.5),
56             P(7, 7.5),
57             P(8, 8.5),
58         };
59         M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
60         assert(m.size() == 8);
61         ASSERT_NOEXCEPT(m.clear());
62         m.clear();
63         assert(m.size() == 0);
64     }
65 #endif
66 }