Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / containers / associative / set / size.pass.cpp
blobbdce58e98f3fea594fe066e828f80c3b75ac9794
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 // <set>
11 // class set
13 // size_type size() const;
15 #include <set>
16 #include <cassert>
18 #include "test_macros.h"
19 #include "min_allocator.h"
21 int main(int, char**)
24 typedef std::set<int> M;
25 M m;
26 assert(m.size() == 0);
27 m.insert(M::value_type(2));
28 assert(m.size() == 1);
29 m.insert(M::value_type(1));
30 assert(m.size() == 2);
31 m.insert(M::value_type(3));
32 assert(m.size() == 3);
33 m.erase(m.begin());
34 assert(m.size() == 2);
35 m.erase(m.begin());
36 assert(m.size() == 1);
37 m.erase(m.begin());
38 assert(m.size() == 0);
40 #if TEST_STD_VER >= 11
42 typedef std::set<int, std::less<int>, min_allocator<int>> M;
43 M m;
44 assert(m.size() == 0);
45 m.insert(M::value_type(2));
46 assert(m.size() == 1);
47 m.insert(M::value_type(1));
48 assert(m.size() == 2);
49 m.insert(M::value_type(3));
50 assert(m.size() == 3);
51 m.erase(m.begin());
52 assert(m.size() == 2);
53 m.erase(m.begin());
54 assert(m.size() == 1);
55 m.erase(m.begin());
56 assert(m.size() == 0);
58 #endif
60 return 0;