1// { dg-do run } 2 3// 2005-2-17 Matt Austern <austern@apple.com> 4// 5// Copyright (C) 2005, 2009 Free Software Foundation, Inc. 6// 7// This file is part of the GNU ISO C++ Library. This library is free 8// software; you can redistribute it and/or modify it under the 9// terms of the GNU General Public License as published by the 10// Free Software Foundation; either version 3, or (at your option) 11// any later version. 12// 13// This library is distributed in the hope that it will be useful, 14// but WITHOUT ANY WARRANTY; without even the implied warranty of 15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16// GNU General Public License for more details. 17// 18// You should have received a copy of the GNU General Public License along 19// with this library; see the file COPYING3. If not see 20// <http://www.gnu.org/licenses/>. 21 22// 6.3.4.6 unordered_multimap 23// range insert 24 25#include <string> 26#include <iterator> 27#include <algorithm> 28#include <tr1/unordered_map> 29#include "testsuite_hooks.h" 30 31bool test __attribute__((unused)) = true; 32 33void test01() 34{ 35 typedef std::tr1::unordered_multimap<std::string, int> Map; 36 typedef std::pair<const std::string, int> Pair; 37 38 Map m; 39 VERIFY(m.empty()); 40 41 Pair A[5] = 42 { 43 Pair("red", 5), 44 Pair("green", 9), 45 Pair("blue", 3), 46 Pair("cyan", 8), 47 Pair("magenta", 7) 48 }; 49 50 m.insert(A+0, A+5); 51 VERIFY(m.size() == 5); 52 VERIFY(std::distance(m.begin(), m.end()) == 5); 53 54 for (int i = 0; i < 5; ++i) 55 VERIFY(std::find(m.begin(), m.end(), A[i]) != m.end()); 56} 57 58void test02() 59{ 60 typedef std::tr1::unordered_multimap<std::string, int> Map; 61 typedef std::pair<const std::string, int> Pair; 62 63 Map m; 64 VERIFY(m.empty()); 65 66 Pair A[9] = 67 { 68 Pair("red", 5), 69 Pair("green", 9), 70 Pair("red", 19), 71 Pair("blue", 3), 72 Pair("blue", 60), 73 Pair("cyan", 8), 74 Pair("magenta", 7), 75 Pair("blue", 99), 76 Pair("green", 33) 77 }; 78 79 m.insert(A+0, A+9); 80 VERIFY(m.size() == 9); 81 VERIFY(std::distance(m.begin(), m.end()) == 9); 82 83 for (int i = 0; i < 9; ++i) 84 VERIFY(std::find(m.begin(), m.end(), A[i]) != m.end()); 85} 86 87int main() 88{ 89 test01(); 90 test02(); 91 return 0; 92} 93