Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | 5b08a8a | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | 412dbeb | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <set> |
| 11 | |
| 12 | // class set |
| 13 | |
Marshall Clow | 934e9a3 | 2018-08-22 04:28:43 +0000 | [diff] [blame] | 14 | // void clear() noexcept; |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 15 | |
| 16 | #include <set> |
| 17 | #include <cassert> |
| 18 | |
Marshall Clow | 934e9a3 | 2018-08-22 04:28:43 +0000 | [diff] [blame] | 19 | #include "test_macros.h" |
Marshall Clow | e34f6f6 | 2013-11-26 20:58:02 +0000 | [diff] [blame] | 20 | #include "min_allocator.h" |
Howard Hinnant | 07d3ecc | 2013-06-19 21:29:40 +0000 | [diff] [blame] | 21 | |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 22 | int main() |
| 23 | { |
| 24 | { |
| 25 | typedef std::set<int> M; |
| 26 | typedef int V; |
| 27 | V ar[] = |
| 28 | { |
| 29 | 1, |
| 30 | 2, |
| 31 | 3, |
| 32 | 4, |
| 33 | 5, |
| 34 | 6, |
| 35 | 7, |
| 36 | 8 |
| 37 | }; |
| 38 | M m(ar, ar + sizeof(ar)/sizeof(ar[0])); |
| 39 | assert(m.size() == 8); |
Marshall Clow | 934e9a3 | 2018-08-22 04:28:43 +0000 | [diff] [blame] | 40 | ASSERT_NOEXCEPT(m.clear()); |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 41 | m.clear(); |
| 42 | assert(m.size() == 0); |
| 43 | } |
Eric Fiselier | f2f2a63 | 2016-06-14 21:31:42 +0000 | [diff] [blame] | 44 | #if TEST_STD_VER >= 11 |
Howard Hinnant | 07d3ecc | 2013-06-19 21:29:40 +0000 | [diff] [blame] | 45 | { |
| 46 | typedef std::set<int, std::less<int>, min_allocator<int>> M; |
| 47 | typedef int V; |
| 48 | V ar[] = |
| 49 | { |
| 50 | 1, |
| 51 | 2, |
| 52 | 3, |
| 53 | 4, |
| 54 | 5, |
| 55 | 6, |
| 56 | 7, |
| 57 | 8 |
| 58 | }; |
| 59 | M m(ar, ar + sizeof(ar)/sizeof(ar[0])); |
| 60 | assert(m.size() == 8); |
Marshall Clow | 934e9a3 | 2018-08-22 04:28:43 +0000 | [diff] [blame] | 61 | ASSERT_NOEXCEPT(m.clear()); |
Howard Hinnant | 07d3ecc | 2013-06-19 21:29:40 +0000 | [diff] [blame] | 62 | m.clear(); |
| 63 | assert(m.size() == 0); |
| 64 | } |
| 65 | #endif |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 66 | } |