llvm-project
85 строк · 2.2 Кб
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// template <class InputIterator>
14// multiset(InputIterator first, InputIterator last);
15
16#include <set>17#include <cassert>18
19#include "test_macros.h"20#include "test_iterators.h"21#include "min_allocator.h"22
23int main(int, char**)24{
25{26typedef int V;27V ar[] =28{291,301,311,322,332,342,353,363,37338};39std::multiset<V> m(cpp17_input_iterator<const int*>(ar),40cpp17_input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0])));41assert(m.size() == 9);42assert(std::distance(m.begin(), m.end()) == 9);43assert(*std::next(m.begin(), 0) == 1);44assert(*std::next(m.begin(), 1) == 1);45assert(*std::next(m.begin(), 2) == 1);46assert(*std::next(m.begin(), 3) == 2);47assert(*std::next(m.begin(), 4) == 2);48assert(*std::next(m.begin(), 5) == 2);49assert(*std::next(m.begin(), 6) == 3);50assert(*std::next(m.begin(), 7) == 3);51assert(*std::next(m.begin(), 8) == 3);52}53#if TEST_STD_VER >= 1154{55typedef int V;56V ar[] =57{581,591,601,612,622,632,643,653,66367};68std::multiset<V, std::less<V>, min_allocator<V>> m(cpp17_input_iterator<const int*>(ar),69cpp17_input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0])));70assert(m.size() == 9);71assert(std::distance(m.begin(), m.end()) == 9);72assert(*std::next(m.begin(), 0) == 1);73assert(*std::next(m.begin(), 1) == 1);74assert(*std::next(m.begin(), 2) == 1);75assert(*std::next(m.begin(), 3) == 2);76assert(*std::next(m.begin(), 4) == 2);77assert(*std::next(m.begin(), 5) == 2);78assert(*std::next(m.begin(), 6) == 3);79assert(*std::next(m.begin(), 7) == 3);80assert(*std::next(m.begin(), 8) == 3);81}82#endif83
84return 0;85}
86