llvm-project
61 строка · 1.4 Кб
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//===----------------------------------------------------------------------===//
8
9// <set>
10
11// class set
12
13// size_type size() const;
14
15#include <set>16#include <cassert>17
18#include "test_macros.h"19#include "min_allocator.h"20
21int main(int, char**)22{
23{24typedef std::set<int> M;25M m;26assert(m.size() == 0);27m.insert(M::value_type(2));28assert(m.size() == 1);29m.insert(M::value_type(1));30assert(m.size() == 2);31m.insert(M::value_type(3));32assert(m.size() == 3);33m.erase(m.begin());34assert(m.size() == 2);35m.erase(m.begin());36assert(m.size() == 1);37m.erase(m.begin());38assert(m.size() == 0);39}40#if TEST_STD_VER >= 1141{42typedef std::set<int, std::less<int>, min_allocator<int>> M;43M m;44assert(m.size() == 0);45m.insert(M::value_type(2));46assert(m.size() == 1);47m.insert(M::value_type(1));48assert(m.size() == 2);49m.insert(M::value_type(3));50assert(m.size() == 3);51m.erase(m.begin());52assert(m.size() == 2);53m.erase(m.begin());54assert(m.size() == 1);55m.erase(m.begin());56assert(m.size() == 0);57}58#endif59
60return 0;61}
62