llvm-project
70 строк · 2.0 Кб
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// multiset(const multiset& m, const allocator_type& a);
14
15#include <set>16#include <cassert>17
18#include "test_macros.h"19#include "../../../test_compare.h"20#include "test_allocator.h"21
22int main(int, char**)23{
24typedef int V;25V ar[] =26{271,281,291,302,312,322,333,343,35336};37typedef test_less<int> C;38typedef test_allocator<V> A;39std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));40std::multiset<int, C, A> m(mo, A(3));41assert(m.get_allocator() == A(3));42assert(m.key_comp() == C(5));43assert(m.size() == 9);44assert(std::distance(m.begin(), m.end()) == 9);45assert(*std::next(m.begin(), 0) == 1);46assert(*std::next(m.begin(), 1) == 1);47assert(*std::next(m.begin(), 2) == 1);48assert(*std::next(m.begin(), 3) == 2);49assert(*std::next(m.begin(), 4) == 2);50assert(*std::next(m.begin(), 5) == 2);51assert(*std::next(m.begin(), 6) == 3);52assert(*std::next(m.begin(), 7) == 3);53assert(*std::next(m.begin(), 8) == 3);54
55assert(mo.get_allocator() == A(7));56assert(mo.key_comp() == C(5));57assert(mo.size() == 9);58assert(std::distance(mo.begin(), mo.end()) == 9);59assert(*std::next(mo.begin(), 0) == 1);60assert(*std::next(mo.begin(), 1) == 1);61assert(*std::next(mo.begin(), 2) == 1);62assert(*std::next(mo.begin(), 3) == 2);63assert(*std::next(mo.begin(), 4) == 2);64assert(*std::next(mo.begin(), 5) == 2);65assert(*std::next(mo.begin(), 6) == 3);66assert(*std::next(mo.begin(), 7) == 3);67assert(*std::next(mo.begin(), 8) == 3);68
69return 0;70}
71