Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / containers / unord / unord.set / size.pass.cpp
blobf7967fcd5f7a5fbcdca01748577cd9f8aac55265
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 //===----------------------------------------------------------------------===//
9 // <unordered_set>
11 // class unordered_set
13 // size_type size() const noexcept;
15 #include <unordered_set>
16 #include <cassert>
18 #include "test_macros.h"
19 #include "min_allocator.h"
21 int main(int, char**)
24 typedef std::unordered_set<int> M;
25 M 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);
34 m.erase(m.begin());
35 assert(m.size() == 2);
36 m.erase(m.begin());
37 assert(m.size() == 1);
38 m.erase(m.begin());
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;
44 M 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);
53 m.erase(m.begin());
54 assert(m.size() == 2);
55 m.erase(m.begin());
56 assert(m.size() == 1);
57 m.erase(m.begin());
58 assert(m.size() == 0);
60 #endif
62 return 0;