llvm-project
186 строк · 4.3 Кб
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// UNSUPPORTED: c++03
10
11// <set>
12
13// class multiset
14
15// multiset& operator=(multiset&& s);
16
17#include <set>18#include <cassert>19
20#include "test_macros.h"21#include "MoveOnly.h"22#include "../../../test_compare.h"23#include "test_allocator.h"24#include "min_allocator.h"25
26int main(int, char**)27{
28{29typedef MoveOnly V;30typedef test_less<MoveOnly> C;31typedef test_allocator<V> A;32typedef std::multiset<MoveOnly, C, A> M;33typedef std::move_iterator<V*> I;34V a1[] =35{36V(1),37V(1),38V(1),39V(2),40V(2),41V(2),42V(3),43V(3),44V(3)45};46M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));47V a2[] =48{49V(1),50V(1),51V(1),52V(2),53V(2),54V(2),55V(3),56V(3),57V(3)58};59M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));60M m3(C(3), A(7));61m3 = std::move(m1);62assert(m3 == m2);63assert(m3.get_allocator() == A(7));64assert(m3.key_comp() == C(5));65assert(m1.empty());66}67{68typedef MoveOnly V;69typedef test_less<MoveOnly> C;70typedef test_allocator<V> A;71typedef std::multiset<MoveOnly, C, A> M;72typedef std::move_iterator<V*> I;73V a1[] =74{75V(1),76V(1),77V(1),78V(2),79V(2),80V(2),81V(3),82V(3),83V(3)84};85M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));86V a2[] =87{88V(1),89V(1),90V(1),91V(2),92V(2),93V(2),94V(3),95V(3),96V(3)97};98M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));99M m3(C(3), A(5));100m3 = std::move(m1);101assert(m3 == m2);102assert(m3.get_allocator() == A(5));103assert(m3.key_comp() == C(5));104LIBCPP_ASSERT(m1.empty());105}106{107typedef MoveOnly V;108typedef test_less<MoveOnly> C;109typedef other_allocator<V> A;110typedef std::multiset<MoveOnly, C, A> M;111typedef std::move_iterator<V*> I;112V a1[] =113{114V(1),115V(1),116V(1),117V(2),118V(2),119V(2),120V(3),121V(3),122V(3)123};124M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));125V a2[] =126{127V(1),128V(1),129V(1),130V(2),131V(2),132V(2),133V(3),134V(3),135V(3)136};137M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));138M m3(C(3), A(5));139m3 = std::move(m1);140assert(m3 == m2);141assert(m3.get_allocator() == A(7));142assert(m3.key_comp() == C(5));143assert(m1.empty());144}145{146typedef MoveOnly V;147typedef test_less<MoveOnly> C;148typedef min_allocator<V> A;149typedef std::multiset<MoveOnly, C, A> M;150typedef std::move_iterator<V*> I;151V a1[] =152{153V(1),154V(1),155V(1),156V(2),157V(2),158V(2),159V(3),160V(3),161V(3)162};163M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A());164V a2[] =165{166V(1),167V(1),168V(1),169V(2),170V(2),171V(2),172V(3),173V(3),174V(3)175};176M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A());177M m3(C(3), A());178m3 = std::move(m1);179assert(m3 == m2);180assert(m3.get_allocator() == A());181assert(m3.key_comp() == C(5));182assert(m1.empty());183}184
185return 0;186}
187