]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/23_containers/multimap/init-list.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 23_containers / multimap / init-list.cc
CommitLineData
fbd26352 1// Copyright (C) 2008-2019 Free Software Foundation, Inc.
b23fdac1 2//
3// This file is part of the GNU ISO C++ Library. This library is free
4// software; you can redistribute it and/or modify it under the
5// terms of the GNU General Public License as published by the
6bc9506f 6// Free Software Foundation; either version 3, or (at your option)
b23fdac1 7// any later version.
8//
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License along
6bc9506f 15// with this library; see the file COPYING3. If not see
16// <http://www.gnu.org/licenses/>.
b23fdac1 17//
b23fdac1 18
be58e01d 19// { dg-do run { target c++11 } }
b23fdac1 20
21#include <map>
22#include <testsuite_hooks.h>
23
24using namespace std;
25
2695b941 26void test01()
b23fdac1 27{
b23fdac1 28 typedef multimap<int,double> Container;
29 typedef Container::iterator iterator;
30 typedef pair<iterator,iterator> itpair;
31 Container m({ { 1, 1.0 }, { 1, 2.0 }, { 1, 237.0 } });
32 VERIFY(m.size() == 3);
33 itpair ip = m.equal_range(1);
34 VERIFY(distance(ip.first, ip.second) == 3);
35 iterator i = ip.first;
36 VERIFY((*i++).second == 1.0);
37 VERIFY((*i++).second == 2.0);
38 VERIFY((*i++).second == 237.0);
39
40 m = { {5, 55.0}, { 5, 66.0 }, { 42, 4242.0 } };
41 VERIFY(m.size() == 3);
42 ip = m.equal_range(5);
43 VERIFY(distance(ip.first, ip.second) == 2);
44 i = ip.first;
45 VERIFY((*i++).second == 55.0);
46 VERIFY((*i++).second == 66.0);
47
48 m.insert({ { 7, 77.0 }, { 7, 88.0 } });
49 VERIFY(m.size() == 5);
50 VERIFY(m.count(5) == 2);
51 VERIFY(m.count(42) == 1);
52 VERIFY(m.count(7) == 2);
b23fdac1 53}
54
55int main()
56{
57 __gnu_test::set_memory_limits();
58 test01();
59}