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

Subversion Repositories openrisc

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

Go to most recent revision | 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 multimap<int, int>::value_type value_type;
30
 
31
  multimap<int, int> mm0;
32
  VERIFY( mm0.count(0) == 0 );
33
  VERIFY( mm0.count(1) == 0 );
34
 
35
  mm0.insert(value_type(1, 1));
36
  VERIFY( mm0.count(0) == 0 );
37
  VERIFY( mm0.count(1) == 1 );
38
 
39
  mm0.insert(value_type(1, 2));
40
  VERIFY( mm0.count(0) == 0 );
41
  VERIFY( mm0.count(1) == 2 );
42
 
43
  mm0.insert(value_type(2, 1));
44
  VERIFY( mm0.count(2) == 1 );
45
 
46
  mm0.insert(value_type(3, 1));
47
  mm0.insert(value_type(3, 2));
48
  mm0.insert(value_type(3, 3));
49
  VERIFY( mm0.count(3) == 3 );
50
 
51
  mm0.erase(2);
52
  VERIFY( mm0.count(2) == 0 );
53
 
54
  mm0.erase(0);
55
  VERIFY( mm0.count(0) == 0 );
56
 
57
  multimap<int, int> mm1(mm0);
58
  VERIFY( mm1.count(0) == 0 );
59
  VERIFY( mm1.count(1) == 2 );
60
  VERIFY( mm1.count(2) == 0 );
61
  VERIFY( mm1.count(3) == 3 );
62
 
63
  mm0.clear();
64
  VERIFY( mm0.count(0) == 0 );
65
  VERIFY( mm0.count(1) == 0 );
66
  VERIFY( mm0.count(2) == 0 );
67
  VERIFY( mm0.count(3) == 0 );
68
 
69
  mm1.insert(value_type(4, 1));
70
  mm1.insert(value_type(5, 1));
71
  mm1.insert(value_type(5, 2));
72
  mm1.insert(value_type(5, 3));
73
  mm1.insert(value_type(5, 4));
74
  VERIFY( mm1.count(4) == 1 );
75
  VERIFY( mm1.count(5) == 4 );
76
 
77
  mm1.erase(1);
78
  VERIFY( mm1.count(1) == 0 );
79
 
80
  mm1.erase(mm1.find(5));
81
  VERIFY( mm1.count(5) == 3 );
82
 
83
  mm1.insert(value_type(1, 1));
84
  mm1.insert(value_type(1, 2));
85
  VERIFY( mm1.count(1) == 2 );
86
 
87
  mm1.erase(5);
88
  VERIFY( mm1.count(5) == 0 );
89
 
90
  mm1.erase(mm1.find(4));
91
  VERIFY( mm1.count(4) == 0 );
92
 
93
  mm1.clear();
94
  VERIFY( mm1.count(0) == 0 );
95
  VERIFY( mm1.count(1) == 0 );
96
  VERIFY( mm1.count(2) == 0 );
97
  VERIFY( mm1.count(3) == 0 );
98
  VERIFY( mm1.count(4) == 0 );
99
  VERIFY( mm1.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.