OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [testsuite/] [23_containers/] [map/] [operations/] [count.cc] - Blame information for rev 742

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 742 jeremybenn
// 2011-10-28  Paolo Carlini  <paolo.carlini@oracle.com>
2
 
3
// Copyright (C) 2011 Free Software Foundation, Inc.
4
//
5
// This file is part of the GNU ISO C++ Library.  This library is free
6
// software; you can redistribute it and/or modify it under the
7
// terms of the GNU General Public License as published by the
8
// Free Software Foundation; either version 3, or (at your option)
9
// any later version.
10
//
11
// This library is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
// GNU General Public License for more details.
15
//
16
// You should have received a copy of the GNU General Public License along
17
// with this library; see the file COPYING3.  If not see
18
// <http://www.gnu.org/licenses/>.
19
//
20
 
21
#include <map>
22
#include <testsuite_hooks.h>
23
 
24
void test01()
25
{
26
  bool test __attribute__((unused)) = true;
27
  using namespace std;
28
 
29
  typedef map<int, int>::value_type value_type;
30
 
31
  map<int, int> m0;
32
  VERIFY( m0.count(0) == 0 );
33
  VERIFY( m0.count(1) == 0 );
34
 
35
  m0.insert(value_type(1, 1));
36
  VERIFY( m0.count(0) == 0 );
37
  VERIFY( m0.count(1) == 1 );
38
 
39
  m0.insert(value_type(1, 2));
40
  VERIFY( m0.count(0) == 0 );
41
  VERIFY( m0.count(1) == 1 );
42
 
43
  m0.insert(value_type(2, 1));
44
  VERIFY( m0.count(2) == 1 );
45
 
46
  m0.insert(value_type(3, 1));
47
  m0.insert(value_type(3, 2));
48
  m0.insert(value_type(3, 3));
49
  VERIFY( m0.count(3) == 1 );
50
 
51
  m0.erase(2);
52
  VERIFY( m0.count(2) == 0 );
53
 
54
  m0.erase(0);
55
  VERIFY( m0.count(0) == 0 );
56
 
57
  map<int, int> m1(m0);
58
  VERIFY( m1.count(0) == 0 );
59
  VERIFY( m1.count(1) == 1 );
60
  VERIFY( m1.count(2) == 0 );
61
  VERIFY( m1.count(3) == 1 );
62
 
63
  m0.clear();
64
  VERIFY( m0.count(0) == 0 );
65
  VERIFY( m0.count(1) == 0 );
66
  VERIFY( m0.count(2) == 0 );
67
  VERIFY( m0.count(3) == 0 );
68
 
69
  m1.insert(value_type(4, 1));
70
  m1.insert(value_type(5, 1));
71
  m1.insert(value_type(5, 2));
72
  m1.insert(value_type(5, 3));
73
  m1.insert(value_type(5, 4));
74
  VERIFY( m1.count(4) == 1 );
75
  VERIFY( m1.count(5) == 1 );
76
 
77
  m1.erase(1);
78
  VERIFY( m1.count(1) == 0 );
79
 
80
  m1.erase(m1.find(5));
81
  VERIFY( m1.count(5) == 0 );
82
 
83
  m1.insert(value_type(1, 1));
84
  m1.insert(value_type(1, 2));
85
  VERIFY( m1.count(1) == 1 );
86
 
87
  m1.erase(5);
88
  VERIFY( m1.count(5) == 0 );
89
 
90
  m1.erase(m1.find(4));
91
  VERIFY( m1.count(4) == 0 );
92
 
93
  m1.clear();
94
  VERIFY( m1.count(0) == 0 );
95
  VERIFY( m1.count(1) == 0 );
96
  VERIFY( m1.count(2) == 0 );
97
  VERIFY( m1.count(3) == 0 );
98
  VERIFY( m1.count(4) == 0 );
99
  VERIFY( m1.count(5) == 0 );
100
}
101
 
102
int main()
103
{
104
  test01();
105
  return 0;
106
}

powered by: WebSVN 2.1.0

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