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 // class unordered_set
13 // size_type size() const noexcept;
15 #include <unordered_set>
18 #include "test_macros.h"
19 #include "min_allocator.h"
24 typedef std::unordered_set
<int> M
;
26 ASSERT_NOEXCEPT(m
.size());
27 assert(m
.size() == 0);
28 m
.insert(M::value_type(2));
29 assert(m
.size() == 1);
30 m
.insert(M::value_type(1));
31 assert(m
.size() == 2);
32 m
.insert(M::value_type(3));
33 assert(m
.size() == 3);
35 assert(m
.size() == 2);
37 assert(m
.size() == 1);
39 assert(m
.size() == 0);
41 #if TEST_STD_VER >= 11
43 typedef std::unordered_set
<int, std::hash
<int>, std::equal_to
<int>, min_allocator
<int>> M
;
45 ASSERT_NOEXCEPT(m
.size());
46 assert(m
.size() == 0);
47 m
.insert(M::value_type(2));
48 assert(m
.size() == 1);
49 m
.insert(M::value_type(1));
50 assert(m
.size() == 2);
51 m
.insert(M::value_type(3));
52 assert(m
.size() == 3);
54 assert(m
.size() == 2);
56 assert(m
.size() == 1);
58 assert(m
.size() == 0);