llvm-project
63 строки · 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 multiset
12
13// iterator insert(const value_type& v);
14
15#include <set>16#include <cassert>17
18#include "test_macros.h"19#include "min_allocator.h"20
21template<class Container>22void do_insert_cv_test()23{
24typedef Container M;25typedef typename M::iterator R;26typedef typename M::value_type VT;27M m;28const VT v1(2);29R r = m.insert(v1);30assert(r == m.begin());31assert(m.size() == 1);32assert(*r == 2);33
34const VT v2(1);35r = m.insert(v2);36assert(r == m.begin());37assert(m.size() == 2);38assert(*r == 1);39
40const VT v3(3);41r = m.insert(v3);42assert(r == std::prev(m.end()));43assert(m.size() == 3);44assert(*r == 3);45
46r = m.insert(v3);47assert(r == std::prev(m.end()));48assert(m.size() == 4);49assert(*r == 3);50}
51
52int main(int, char**)53{
54do_insert_cv_test<std::multiset<int> >();55#if TEST_STD_VER >= 1156{57typedef std::multiset<int, std::less<int>, min_allocator<int>> M;58do_insert_cv_test<M>();59}60#endif61
62return 0;63}
64