OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc3/] [libstdc++-v3/] [testsuite/] [tr1/] [6_containers/] [unordered_map/] [insert/] [map_range.cc] - Blame information for rev 516

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
// { 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.4 unordered_map
23
// range insert
24
 
25
#include <string>
26
#include <iterator>
27
#include <algorithm>
28
#include <tr1/unordered_map>
29
#include "testsuite_hooks.h"
30
 
31
bool test __attribute__((unused)) = true;
32
 
33
void test01()
34
{
35
  typedef std::tr1::unordered_map<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
  VERIFY(m["red"] == 5);
55
  VERIFY(m["green"] == 9);
56
  VERIFY(m["blue"] == 3);
57
  VERIFY(m["cyan"] == 8);
58
  VERIFY(m["magenta"] == 7);
59
}
60
 
61
void test02()
62
{
63
  typedef std::tr1::unordered_map<std::string, int> Map;
64
  typedef std::pair<const std::string, int> Pair;
65
 
66
  Map m;
67
  VERIFY(m.empty());
68
 
69
  Pair A[9] =
70
    {
71
      Pair("red", 5),
72
      Pair("green", 9),
73
      Pair("red", 19),
74
      Pair("blue", 3),
75
      Pair("blue", 60),
76
      Pair("cyan", 8),
77
      Pair("magenta", 7),
78
      Pair("blue", 99),
79
      Pair("green", 33)
80
    };
81
 
82
  m.insert(A+0, A+9);
83
  VERIFY(m.size() == 5);
84
  VERIFY(std::distance(m.begin(), m.end()) == 5);
85
 
86
  VERIFY(m["red"] == 5);
87
  VERIFY(m["green"] == 9);
88
  VERIFY(m["blue"] == 3);
89
  VERIFY(m["cyan"] == 8);
90
  VERIFY(m["magenta"] == 7);
91
}
92
 
93
int main()
94
{
95
  test01();
96
  test02();
97
  return 0;
98
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.