From c8773b4ecf3192da7dd9e3de8b1091275537e32a Mon Sep 17 00:00:00 2001 From: paolo Date: Fri, 28 Oct 2011 11:54:04 +0000 Subject: [PATCH] 2011-10-28 Paolo Carlini * testsuite/23_containers/unordered_map/operations/count.cc: New. * testsuite/23_containers/multimap/operations/count.cc: Likewise. * testsuite/23_containers/set/operations/count.cc: Likewise. * testsuite/23_containers/unordered_multimap/operations/count.cc: Likewise. * testsuite/23_containers/unordered_set/operations/count.cc: Likewise. * testsuite/23_containers/multiset/operations/count.cc: Likewise. * testsuite/23_containers/unordered_multiset/operations/count.cc: Likewise. * testsuite/23_containers/map/operations/count.cc: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180612 138bc75d-0d04-0410-961f-82ee72b054a4 --- .../23_containers/map/operations/count.cc | 106 ++++++++++++++++++++ .../23_containers/multimap/operations/count.cc | 106 ++++++++++++++++++++ .../23_containers/multiset/operations/count.cc | 104 ++++++++++++++++++++ .../23_containers/set/operations/count.cc | 104 ++++++++++++++++++++ .../unordered_map/operations/count.cc | 108 +++++++++++++++++++++ .../unordered_multimap/operations/count.cc | 108 +++++++++++++++++++++ .../unordered_multiset/operations/count.cc | 106 ++++++++++++++++++++ .../unordered_set/operations/count.cc | 106 ++++++++++++++++++++ 8 files changed, 848 insertions(+) create mode 100644 libstdc++-v3/testsuite/23_containers/map/operations/count.cc create mode 100644 libstdc++-v3/testsuite/23_containers/multimap/operations/count.cc create mode 100644 libstdc++-v3/testsuite/23_containers/multiset/operations/count.cc create mode 100644 libstdc++-v3/testsuite/23_containers/set/operations/count.cc create mode 100644 libstdc++-v3/testsuite/23_containers/unordered_map/operations/count.cc create mode 100644 libstdc++-v3/testsuite/23_containers/unordered_multimap/operations/count.cc create mode 100644 libstdc++-v3/testsuite/23_containers/unordered_multiset/operations/count.cc create mode 100644 libstdc++-v3/testsuite/23_containers/unordered_set/operations/count.cc diff --git a/libstdc++-v3/testsuite/23_containers/map/operations/count.cc b/libstdc++-v3/testsuite/23_containers/map/operations/count.cc new file mode 100644 index 00000000000..dfbaee6eda4 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/operations/count.cc @@ -0,0 +1,106 @@ +// 2011-10-28 Paolo Carlini + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef map::value_type value_type; + + map m0; + VERIFY( m0.count(0) == 0 ); + VERIFY( m0.count(1) == 0 ); + + m0.insert(value_type(1, 1)); + VERIFY( m0.count(0) == 0 ); + VERIFY( m0.count(1) == 1 ); + + m0.insert(value_type(1, 2)); + VERIFY( m0.count(0) == 0 ); + VERIFY( m0.count(1) == 1 ); + + m0.insert(value_type(2, 1)); + VERIFY( m0.count(2) == 1 ); + + m0.insert(value_type(3, 1)); + m0.insert(value_type(3, 2)); + m0.insert(value_type(3, 3)); + VERIFY( m0.count(3) == 1 ); + + m0.erase(2); + VERIFY( m0.count(2) == 0 ); + + m0.erase(0); + VERIFY( m0.count(0) == 0 ); + + map m1(m0); + VERIFY( m1.count(0) == 0 ); + VERIFY( m1.count(1) == 1 ); + VERIFY( m1.count(2) == 0 ); + VERIFY( m1.count(3) == 1 ); + + m0.clear(); + VERIFY( m0.count(0) == 0 ); + VERIFY( m0.count(1) == 0 ); + VERIFY( m0.count(2) == 0 ); + VERIFY( m0.count(3) == 0 ); + + m1.insert(value_type(4, 1)); + m1.insert(value_type(5, 1)); + m1.insert(value_type(5, 2)); + m1.insert(value_type(5, 3)); + m1.insert(value_type(5, 4)); + VERIFY( m1.count(4) == 1 ); + VERIFY( m1.count(5) == 1 ); + + m1.erase(1); + VERIFY( m1.count(1) == 0 ); + + m1.erase(m1.find(5)); + VERIFY( m1.count(5) == 0 ); + + m1.insert(value_type(1, 1)); + m1.insert(value_type(1, 2)); + VERIFY( m1.count(1) == 1 ); + + m1.erase(5); + VERIFY( m1.count(5) == 0 ); + + m1.erase(m1.find(4)); + VERIFY( m1.count(4) == 0 ); + + m1.clear(); + VERIFY( m1.count(0) == 0 ); + VERIFY( m1.count(1) == 0 ); + VERIFY( m1.count(2) == 0 ); + VERIFY( m1.count(3) == 0 ); + VERIFY( m1.count(4) == 0 ); + VERIFY( m1.count(5) == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/multimap/operations/count.cc b/libstdc++-v3/testsuite/23_containers/multimap/operations/count.cc new file mode 100644 index 00000000000..2658615776e --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/multimap/operations/count.cc @@ -0,0 +1,106 @@ +// 2011-10-28 Paolo Carlini + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef multimap::value_type value_type; + + multimap mm0; + VERIFY( mm0.count(0) == 0 ); + VERIFY( mm0.count(1) == 0 ); + + mm0.insert(value_type(1, 1)); + VERIFY( mm0.count(0) == 0 ); + VERIFY( mm0.count(1) == 1 ); + + mm0.insert(value_type(1, 2)); + VERIFY( mm0.count(0) == 0 ); + VERIFY( mm0.count(1) == 2 ); + + mm0.insert(value_type(2, 1)); + VERIFY( mm0.count(2) == 1 ); + + mm0.insert(value_type(3, 1)); + mm0.insert(value_type(3, 2)); + mm0.insert(value_type(3, 3)); + VERIFY( mm0.count(3) == 3 ); + + mm0.erase(2); + VERIFY( mm0.count(2) == 0 ); + + mm0.erase(0); + VERIFY( mm0.count(0) == 0 ); + + multimap mm1(mm0); + VERIFY( mm1.count(0) == 0 ); + VERIFY( mm1.count(1) == 2 ); + VERIFY( mm1.count(2) == 0 ); + VERIFY( mm1.count(3) == 3 ); + + mm0.clear(); + VERIFY( mm0.count(0) == 0 ); + VERIFY( mm0.count(1) == 0 ); + VERIFY( mm0.count(2) == 0 ); + VERIFY( mm0.count(3) == 0 ); + + mm1.insert(value_type(4, 1)); + mm1.insert(value_type(5, 1)); + mm1.insert(value_type(5, 2)); + mm1.insert(value_type(5, 3)); + mm1.insert(value_type(5, 4)); + VERIFY( mm1.count(4) == 1 ); + VERIFY( mm1.count(5) == 4 ); + + mm1.erase(1); + VERIFY( mm1.count(1) == 0 ); + + mm1.erase(mm1.find(5)); + VERIFY( mm1.count(5) == 3 ); + + mm1.insert(value_type(1, 1)); + mm1.insert(value_type(1, 2)); + VERIFY( mm1.count(1) == 2 ); + + mm1.erase(5); + VERIFY( mm1.count(5) == 0 ); + + mm1.erase(mm1.find(4)); + VERIFY( mm1.count(4) == 0 ); + + mm1.clear(); + VERIFY( mm1.count(0) == 0 ); + VERIFY( mm1.count(1) == 0 ); + VERIFY( mm1.count(2) == 0 ); + VERIFY( mm1.count(3) == 0 ); + VERIFY( mm1.count(4) == 0 ); + VERIFY( mm1.count(5) == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/multiset/operations/count.cc b/libstdc++-v3/testsuite/23_containers/multiset/operations/count.cc new file mode 100644 index 00000000000..96323877c49 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/multiset/operations/count.cc @@ -0,0 +1,104 @@ +// 2011-10-28 Paolo Carlini + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + multiset ms0; + VERIFY( ms0.count(0) == 0 ); + VERIFY( ms0.count(1) == 0 ); + + ms0.insert(1); + VERIFY( ms0.count(0) == 0 ); + VERIFY( ms0.count(1) == 1 ); + + ms0.insert(1); + VERIFY( ms0.count(0) == 0 ); + VERIFY( ms0.count(1) == 2 ); + + ms0.insert(2); + VERIFY( ms0.count(2) == 1 ); + + ms0.insert(3); + ms0.insert(3); + ms0.insert(3); + VERIFY( ms0.count(3) == 3 ); + + ms0.erase(2); + VERIFY( ms0.count(2) == 0 ); + + ms0.erase(0); + VERIFY( ms0.count(0) == 0 ); + + multiset ms1(ms0); + VERIFY( ms1.count(0) == 0 ); + VERIFY( ms1.count(1) == 2 ); + VERIFY( ms1.count(2) == 0 ); + VERIFY( ms1.count(3) == 3 ); + + ms0.clear(); + VERIFY( ms0.count(0) == 0 ); + VERIFY( ms0.count(1) == 0 ); + VERIFY( ms0.count(2) == 0 ); + VERIFY( ms0.count(3) == 0 ); + + ms1.insert(4); + ms1.insert(5); + ms1.insert(5); + ms1.insert(5); + ms1.insert(5); + VERIFY( ms1.count(4) == 1 ); + VERIFY( ms1.count(5) == 4 ); + + ms1.erase(1); + VERIFY( ms1.count(1) == 0 ); + + ms1.erase(ms1.find(5)); + VERIFY( ms1.count(5) == 3 ); + + ms1.insert(1); + ms1.insert(1); + VERIFY( ms1.count(1) == 2 ); + + ms1.erase(5); + VERIFY( ms1.count(5) == 0 ); + + ms1.erase(ms1.find(4)); + VERIFY( ms1.count(4) == 0 ); + + ms1.clear(); + VERIFY( ms1.count(0) == 0 ); + VERIFY( ms1.count(1) == 0 ); + VERIFY( ms1.count(2) == 0 ); + VERIFY( ms1.count(3) == 0 ); + VERIFY( ms1.count(4) == 0 ); + VERIFY( ms1.count(5) == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/set/operations/count.cc b/libstdc++-v3/testsuite/23_containers/set/operations/count.cc new file mode 100644 index 00000000000..4a6b0f2683f --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/set/operations/count.cc @@ -0,0 +1,104 @@ +// 2011-10-28 Paolo Carlini + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + set s0; + VERIFY( s0.count(0) == 0 ); + VERIFY( s0.count(1) == 0 ); + + s0.insert(1); + VERIFY( s0.count(0) == 0 ); + VERIFY( s0.count(1) == 1 ); + + s0.insert(1); + VERIFY( s0.count(0) == 0 ); + VERIFY( s0.count(1) == 1 ); + + s0.insert(2); + VERIFY( s0.count(2) == 1 ); + + s0.insert(3); + s0.insert(3); + s0.insert(3); + VERIFY( s0.count(3) == 1 ); + + s0.erase(2); + VERIFY( s0.count(2) == 0 ); + + s0.erase(0); + VERIFY( s0.count(0) == 0 ); + + set s1(s0); + VERIFY( s1.count(0) == 0 ); + VERIFY( s1.count(1) == 1 ); + VERIFY( s1.count(2) == 0 ); + VERIFY( s1.count(3) == 1 ); + + s0.clear(); + VERIFY( s0.count(0) == 0 ); + VERIFY( s0.count(1) == 0 ); + VERIFY( s0.count(2) == 0 ); + VERIFY( s0.count(3) == 0 ); + + s1.insert(4); + s1.insert(5); + s1.insert(5); + s1.insert(5); + s1.insert(5); + VERIFY( s1.count(4) == 1 ); + VERIFY( s1.count(5) == 1 ); + + s1.erase(1); + VERIFY( s1.count(1) == 0 ); + + s1.erase(s1.find(5)); + VERIFY( s1.count(5) == 0 ); + + s1.insert(1); + s1.insert(1); + VERIFY( s1.count(1) == 1 ); + + s1.erase(5); + VERIFY( s1.count(5) == 0 ); + + s1.erase(s1.find(4)); + VERIFY( s1.count(4) == 0 ); + + s1.clear(); + VERIFY( s1.count(0) == 0 ); + VERIFY( s1.count(1) == 0 ); + VERIFY( s1.count(2) == 0 ); + VERIFY( s1.count(3) == 0 ); + VERIFY( s1.count(4) == 0 ); + VERIFY( s1.count(5) == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/operations/count.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/operations/count.cc new file mode 100644 index 00000000000..4aedc5e1e11 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/operations/count.cc @@ -0,0 +1,108 @@ +// { dg-options "-std=gnu++0x" } + +// 2011-10-28 Paolo Carlini + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef unordered_map::value_type value_type; + + unordered_map um0; + VERIFY( um0.count(0) == 0 ); + VERIFY( um0.count(1) == 0 ); + + um0.insert(value_type(1, 1)); + VERIFY( um0.count(0) == 0 ); + VERIFY( um0.count(1) == 1 ); + + um0.insert(value_type(1, 2)); + VERIFY( um0.count(0) == 0 ); + VERIFY( um0.count(1) == 1 ); + + um0.insert(value_type(2, 1)); + VERIFY( um0.count(2) == 1 ); + + um0.insert(value_type(3, 1)); + um0.insert(value_type(3, 2)); + um0.insert(value_type(3, 3)); + VERIFY( um0.count(3) == 1 ); + + um0.erase(2); + VERIFY( um0.count(2) == 0 ); + + um0.erase(0); + VERIFY( um0.count(0) == 0 ); + + unordered_map um1(um0); + VERIFY( um1.count(0) == 0 ); + VERIFY( um1.count(1) == 1 ); + VERIFY( um1.count(2) == 0 ); + VERIFY( um1.count(3) == 1 ); + + um0.clear(); + VERIFY( um0.count(0) == 0 ); + VERIFY( um0.count(1) == 0 ); + VERIFY( um0.count(2) == 0 ); + VERIFY( um0.count(3) == 0 ); + + um1.insert(value_type(4, 1)); + um1.insert(value_type(5, 1)); + um1.insert(value_type(5, 2)); + um1.insert(value_type(5, 3)); + um1.insert(value_type(5, 4)); + VERIFY( um1.count(4) == 1 ); + VERIFY( um1.count(5) == 1 ); + + um1.erase(1); + VERIFY( um1.count(1) == 0 ); + + um1.erase(um1.find(5)); + VERIFY( um1.count(5) == 0 ); + + um1.insert(value_type(1, 1)); + um1.insert(value_type(1, 2)); + VERIFY( um1.count(1) == 1 ); + + um1.erase(5); + VERIFY( um1.count(5) == 0 ); + + um1.erase(um1.find(4)); + VERIFY( um1.count(4) == 0 ); + + um1.clear(); + VERIFY( um1.count(0) == 0 ); + VERIFY( um1.count(1) == 0 ); + VERIFY( um1.count(2) == 0 ); + VERIFY( um1.count(3) == 0 ); + VERIFY( um1.count(4) == 0 ); + VERIFY( um1.count(5) == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/operations/count.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/operations/count.cc new file mode 100644 index 00000000000..12f9e1f5ebc --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/operations/count.cc @@ -0,0 +1,108 @@ +// { dg-options "-std=gnu++0x" } + +// 2011-10-28 Paolo Carlini + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef unordered_multimap::value_type value_type; + + unordered_multimap umm0; + VERIFY( umm0.count(0) == 0 ); + VERIFY( umm0.count(1) == 0 ); + + umm0.insert(value_type(1, 1)); + VERIFY( umm0.count(0) == 0 ); + VERIFY( umm0.count(1) == 1 ); + + umm0.insert(value_type(1, 2)); + VERIFY( umm0.count(0) == 0 ); + VERIFY( umm0.count(1) == 2 ); + + umm0.insert(value_type(2, 1)); + VERIFY( umm0.count(2) == 1 ); + + umm0.insert(value_type(3, 1)); + umm0.insert(value_type(3, 2)); + umm0.insert(value_type(3, 3)); + VERIFY( umm0.count(3) == 3 ); + + umm0.erase(2); + VERIFY( umm0.count(2) == 0 ); + + umm0.erase(0); + VERIFY( umm0.count(0) == 0 ); + + unordered_multimap umm1(umm0); + VERIFY( umm1.count(0) == 0 ); + VERIFY( umm1.count(1) == 2 ); + VERIFY( umm1.count(2) == 0 ); + VERIFY( umm1.count(3) == 3 ); + + umm0.clear(); + VERIFY( umm0.count(0) == 0 ); + VERIFY( umm0.count(1) == 0 ); + VERIFY( umm0.count(2) == 0 ); + VERIFY( umm0.count(3) == 0 ); + + umm1.insert(value_type(4, 1)); + umm1.insert(value_type(5, 1)); + umm1.insert(value_type(5, 2)); + umm1.insert(value_type(5, 3)); + umm1.insert(value_type(5, 4)); + VERIFY( umm1.count(4) == 1 ); + VERIFY( umm1.count(5) == 4 ); + + umm1.erase(1); + VERIFY( umm1.count(1) == 0 ); + + umm1.erase(umm1.find(5)); + VERIFY( umm1.count(5) == 3 ); + + umm1.insert(value_type(1, 1)); + umm1.insert(value_type(1, 2)); + VERIFY( umm1.count(1) == 2 ); + + umm1.erase(5); + VERIFY( umm1.count(5) == 0 ); + + umm1.erase(umm1.find(4)); + VERIFY( umm1.count(4) == 0 ); + + umm1.clear(); + VERIFY( umm1.count(0) == 0 ); + VERIFY( umm1.count(1) == 0 ); + VERIFY( umm1.count(2) == 0 ); + VERIFY( umm1.count(3) == 0 ); + VERIFY( umm1.count(4) == 0 ); + VERIFY( umm1.count(5) == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/operations/count.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/operations/count.cc new file mode 100644 index 00000000000..17c37f82ed7 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/operations/count.cc @@ -0,0 +1,106 @@ +// { dg-options "-std=gnu++0x" } + +// 2011-10-28 Paolo Carlini + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + unordered_multiset ums0; + VERIFY( ums0.count(0) == 0 ); + VERIFY( ums0.count(1) == 0 ); + + ums0.insert(1); + VERIFY( ums0.count(0) == 0 ); + VERIFY( ums0.count(1) == 1 ); + + ums0.insert(1); + VERIFY( ums0.count(0) == 0 ); + VERIFY( ums0.count(1) == 2 ); + + ums0.insert(2); + VERIFY( ums0.count(2) == 1 ); + + ums0.insert(3); + ums0.insert(3); + ums0.insert(3); + VERIFY( ums0.count(3) == 3 ); + + ums0.erase(2); + VERIFY( ums0.count(2) == 0 ); + + ums0.erase(0); + VERIFY( ums0.count(0) == 0 ); + + unordered_multiset ums1(ums0); + VERIFY( ums1.count(0) == 0 ); + VERIFY( ums1.count(1) == 2 ); + VERIFY( ums1.count(2) == 0 ); + VERIFY( ums1.count(3) == 3 ); + + ums0.clear(); + VERIFY( ums0.count(0) == 0 ); + VERIFY( ums0.count(1) == 0 ); + VERIFY( ums0.count(2) == 0 ); + VERIFY( ums0.count(3) == 0 ); + + ums1.insert(4); + ums1.insert(5); + ums1.insert(5); + ums1.insert(5); + ums1.insert(5); + VERIFY( ums1.count(4) == 1 ); + VERIFY( ums1.count(5) == 4 ); + + ums1.erase(1); + VERIFY( ums1.count(1) == 0 ); + + ums1.erase(ums1.find(5)); + VERIFY( ums1.count(5) == 3 ); + + ums1.insert(1); + ums1.insert(1); + VERIFY( ums1.count(1) == 2 ); + + ums1.erase(5); + VERIFY( ums1.count(5) == 0 ); + + ums1.erase(ums1.find(4)); + VERIFY( ums1.count(4) == 0 ); + + ums1.clear(); + VERIFY( ums1.count(0) == 0 ); + VERIFY( ums1.count(1) == 0 ); + VERIFY( ums1.count(2) == 0 ); + VERIFY( ums1.count(3) == 0 ); + VERIFY( ums1.count(4) == 0 ); + VERIFY( ums1.count(5) == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/operations/count.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/operations/count.cc new file mode 100644 index 00000000000..942338f9e5a --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/operations/count.cc @@ -0,0 +1,106 @@ +// { dg-options "-std=gnu++0x" } + +// 2011-10-28 Paolo Carlini + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . +// + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + unordered_set us0; + VERIFY( us0.count(0) == 0 ); + VERIFY( us0.count(1) == 0 ); + + us0.insert(1); + VERIFY( us0.count(0) == 0 ); + VERIFY( us0.count(1) == 1 ); + + us0.insert(1); + VERIFY( us0.count(0) == 0 ); + VERIFY( us0.count(1) == 1 ); + + us0.insert(2); + VERIFY( us0.count(2) == 1 ); + + us0.insert(3); + us0.insert(3); + us0.insert(3); + VERIFY( us0.count(3) == 1 ); + + us0.erase(2); + VERIFY( us0.count(2) == 0 ); + + us0.erase(0); + VERIFY( us0.count(0) == 0 ); + + unordered_set us1(us0); + VERIFY( us1.count(0) == 0 ); + VERIFY( us1.count(1) == 1 ); + VERIFY( us1.count(2) == 0 ); + VERIFY( us1.count(3) == 1 ); + + us0.clear(); + VERIFY( us0.count(0) == 0 ); + VERIFY( us0.count(1) == 0 ); + VERIFY( us0.count(2) == 0 ); + VERIFY( us0.count(3) == 0 ); + + us1.insert(4); + us1.insert(5); + us1.insert(5); + us1.insert(5); + us1.insert(5); + VERIFY( us1.count(4) == 1 ); + VERIFY( us1.count(5) == 1 ); + + us1.erase(1); + VERIFY( us1.count(1) == 0 ); + + us1.erase(us1.find(5)); + VERIFY( us1.count(5) == 0 ); + + us1.insert(1); + us1.insert(1); + VERIFY( us1.count(1) == 1 ); + + us1.erase(5); + VERIFY( us1.count(5) == 0 ); + + us1.erase(us1.find(4)); + VERIFY( us1.count(4) == 0 ); + + us1.clear(); + VERIFY( us1.count(0) == 0 ); + VERIFY( us1.count(1) == 0 ); + VERIFY( us1.count(2) == 0 ); + VERIFY( us1.count(3) == 0 ); + VERIFY( us1.count(4) == 0 ); + VERIFY( us1.count(5) == 0 ); +} + +int main() +{ + test01(); + return 0; +} -- 2.11.0