From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../unordered_multimap/capacity/29134-multimap.cc | 38 ++++ .../tr1/6_containers/unordered_multimap/erase/1.cc | 130 +++++++++++++ .../unordered_multimap/erase/24061-multimap.cc | 108 +++++++++++ .../unordered_multimap/find/multimap1.cc | 84 +++++++++ .../unordered_multimap/insert/24061-multimap.cc | 60 ++++++ .../unordered_multimap/insert/multimap_range.cc | 92 +++++++++ .../unordered_multimap/insert/multimap_single.cc | 77 ++++++++ .../requirements/explicit_instantiation.cc | 42 +++++ .../requirements/iterator_neg.cc | 40 ++++ .../requirements/iterator_null_neg.cc | 28 +++ .../unordered_multimap/requirements/typedefs.cc | 46 +++++ .../tr1/6_containers/unordered_multimap/swap/1.cc | 177 ++++++++++++++++++ .../tr1/6_containers/unordered_multimap/swap/2.cc | 206 +++++++++++++++++++++ 13 files changed, 1128 insertions(+) create mode 100644 libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/capacity/29134-multimap.cc create mode 100644 libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/erase/1.cc create mode 100644 libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/erase/24061-multimap.cc create mode 100644 libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/find/multimap1.cc create mode 100644 libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/insert/24061-multimap.cc create mode 100644 libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/insert/multimap_range.cc create mode 100644 libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/insert/multimap_single.cc create mode 100644 libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/iterator_neg.cc create mode 100644 libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/iterator_null_neg.cc create mode 100644 libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/swap/1.cc create mode 100644 libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/swap/2.cc (limited to 'libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap') diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/capacity/29134-multimap.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/capacity/29134-multimap.cc new file mode 100644 index 000000000..970593e0d --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/capacity/29134-multimap.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2006, 2007, 2008, 2009 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 +// . + +// 6.3.4.6 Class template unordered_multimap + +#include +#include + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::tr1::unordered_multimap umm; + + VERIFY( (umm.max_size() == std::allocator, false> >().max_size()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/erase/1.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/erase/1.cc new file mode 100644 index 000000000..ef2c18e09 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/erase/1.cc @@ -0,0 +1,130 @@ +// 2007-02-22 Paolo Carlini +// +// Copyright (C) 2007, 2009 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 +// . + +// 6.3.4.6 Class template unordered_multimap + +#include +#include +#include + +// In the occasion of libstdc++/25896 +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::tr1::unordered_multimap Mmap; + typedef Mmap::iterator iterator; + typedef Mmap::const_iterator const_iterator; + typedef Mmap::value_type value_type; + + Mmap mm1; + + mm1.insert(value_type("because to why", 1)); + mm1.insert(value_type("the stockholm syndrome", 2)); + mm1.insert(value_type("a cereous night", 3)); + mm1.insert(value_type("eeilo", 4)); + mm1.insert(value_type("protean", 5)); + mm1.insert(value_type("the way you are when", 6)); + mm1.insert(value_type("tillsammans", 7)); + mm1.insert(value_type("umbra/penumbra", 8)); + mm1.insert(value_type("belonging (no longer mix)", 9)); + mm1.insert(value_type("one line behind", 10)); + VERIFY( mm1.size() == 10 ); + + VERIFY( mm1.erase("eeilo") == 1 ); + VERIFY( mm1.size() == 9 ); + iterator it1 = mm1.find("eeilo"); + VERIFY( it1 == mm1.end() ); + + VERIFY( mm1.erase("tillsammans") == 1 ); + VERIFY( mm1.size() == 8 ); + iterator it2 = mm1.find("tillsammans"); + VERIFY( it2 == mm1.end() ); + + // Must work (see DR 526) + iterator it3 = mm1.find("belonging (no longer mix)"); + VERIFY( it3 != mm1.end() ); + VERIFY( mm1.erase(it3->first) == 1 ); + VERIFY( mm1.size() == 7 ); + it3 = mm1.find("belonging (no longer mix)"); + VERIFY( it3 == mm1.end() ); + + VERIFY( !mm1.erase("abra") ); + VERIFY( mm1.size() == 7 ); + + VERIFY( !mm1.erase("eeilo") ); + VERIFY( mm1.size() == 7 ); + + VERIFY( mm1.erase("because to why") == 1 ); + VERIFY( mm1.size() == 6 ); + iterator it4 = mm1.find("because to why"); + VERIFY( it4 == mm1.end() ); + + iterator it5 = mm1.find("umbra/penumbra"); + iterator it6 = mm1.find("one line behind"); + VERIFY( it5 != mm1.end() ); + VERIFY( it6 != mm1.end() ); + + VERIFY( mm1.find("the stockholm syndrome") != mm1.end() ); + VERIFY( mm1.find("a cereous night") != mm1.end() ); + VERIFY( mm1.find("the way you are when") != mm1.end() ); + VERIFY( mm1.find("a cereous night") != mm1.end() ); + + VERIFY( mm1.erase(it5->first) == 1 ); + VERIFY( mm1.size() == 5 ); + it5 = mm1.find("umbra/penumbra"); + VERIFY( it5 == mm1.end() ); + + VERIFY( mm1.erase(it6->first) == 1 ); + VERIFY( mm1.size() == 4 ); + it6 = mm1.find("one line behind"); + VERIFY( it6 == mm1.end() ); + + iterator it7 = mm1.begin(); + iterator it8 = it7; + ++it8; + iterator it9 = it8; + ++it9; + + VERIFY( mm1.erase(it8->first) == 1 ); + VERIFY( mm1.size() == 3 ); + VERIFY( ++it7 == it9 ); + + iterator it10 = it9; + ++it10; + iterator it11 = it10; + + VERIFY( mm1.erase(it9->first) == 1 ); + VERIFY( mm1.size() == 2 ); + VERIFY( ++it10 == mm1.end() ); + + VERIFY( mm1.erase(mm1.begin()) != mm1.end() ); + VERIFY( mm1.size() == 1 ); + VERIFY( mm1.begin() == it11 ); + + VERIFY( mm1.erase(mm1.begin()->first) == 1 ); + VERIFY( mm1.size() == 0 ); + VERIFY( mm1.begin() == mm1.end() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/erase/24061-multimap.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/erase/24061-multimap.cc new file mode 100644 index 000000000..3a14f26b2 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/erase/24061-multimap.cc @@ -0,0 +1,108 @@ +// 2005-10-08 Paolo Carlini +// +// Copyright (C) 2005, 2009 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 +// . + +// 6.3.4.6 Class template unordered_multimap + +#include +#include +#include + +// libstdc++/24061 +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::tr1::unordered_multimap Mmap; + typedef Mmap::iterator iterator; + typedef Mmap::const_iterator const_iterator; + typedef Mmap::value_type value_type; + + Mmap mm1; + + mm1.insert(value_type("all the love in the world", 1)); + mm1.insert(value_type("you know what you are?", 2)); + mm1.insert(value_type("the collector", 3)); + mm1.insert(value_type("the hand that feeds", 4)); + mm1.insert(value_type("love is not enough", 5)); + mm1.insert(value_type("every day is exactly the same", 6)); + mm1.insert(value_type("with teeth", 7)); + mm1.insert(value_type("only", 8)); + mm1.insert(value_type("getting smaller", 9)); + mm1.insert(value_type("sunspots", 10)); + + mm1.insert(value_type("you know what you are?", 5)); + mm1.insert(value_type("the collector", 6)); + mm1.insert(value_type("the hand that feeds", 7)); + VERIFY( mm1.size() == 13 ); + + iterator it1 = mm1.begin(); + ++it1; + iterator it2 = it1; + ++it2; + iterator it3 = mm1.erase(it1); + VERIFY( mm1.size() == 12 ); + VERIFY( it3 == it2 ); + VERIFY( *it3 == *it2 ); + + iterator it4 = mm1.begin(); + ++it4; + ++it4; + ++it4; + iterator it5 = it4; + ++it5; + ++it5; + iterator it6 = mm1.erase(it4, it5); + VERIFY( mm1.size() == 10 ); + VERIFY( it6 == it5 ); + VERIFY( *it6 == *it5 ); + + const_iterator it7 = mm1.begin(); + ++it7; + ++it7; + ++it7; + const_iterator it8 = it7; + ++it8; + const_iterator it9 = mm1.erase(it7); + VERIFY( mm1.size() == 9 ); + VERIFY( it9 == it8 ); + VERIFY( *it9 == *it8 ); + + const_iterator it10 = mm1.begin(); + ++it10; + const_iterator it11 = it10; + ++it11; + ++it11; + ++it11; + ++it11; + const_iterator it12 = mm1.erase(it10, it11); + VERIFY( mm1.size() == 5 ); + VERIFY( it12 == it11 ); + VERIFY( *it12 == *it11 ); + + iterator it13 = mm1.erase(mm1.begin(), mm1.end()); + VERIFY( mm1.size() == 0 ); + VERIFY( it13 == mm1.end() ); + VERIFY( it13 == mm1.begin() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/find/multimap1.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/find/multimap1.cc new file mode 100644 index 000000000..c1255c10e --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/find/multimap1.cc @@ -0,0 +1,84 @@ +// { dg-do run } + +// 2005-2-18 Matt Austern +// +// Copyright (C) 2005, 2009 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 +// . + +// 6.3.4.6 unordered_multimap +// find, equal_range, count + +#include +#include +#include +#include +#include +#include "testsuite_hooks.h" + +bool test __attribute__((unused)) = true; + +void test01() +{ + typedef std::tr1::unordered_multimap Map; + typedef std::pair Pair; + + Map m; + VERIFY(m.empty()); + + m.insert(Pair("grape", 3)); + m.insert(Pair("durian", 8)); + m.insert(Pair("grape", 7)); + + Map::iterator i1 = m.find("grape"); + Map::iterator i2 = m.find("durian"); + Map::iterator i3 = m.find("kiwi"); + + VERIFY(i1 != m.end()); + VERIFY(i1->first == "grape"); + VERIFY(i1->second == 3 || i2->second == 7); + VERIFY(i2 != m.end()); + VERIFY(i2->first == "durian"); + VERIFY(i2->second == 8); + VERIFY(i3 == m.end()); + + std::pair p1 = m.equal_range("grape"); + VERIFY(std::distance(p1.first, p1.second) == 2); + Map::iterator tmp = p1.first; + ++tmp; + VERIFY(p1.first->first == "grape"); + VERIFY(tmp->first == "grape"); + VERIFY((p1.first->second == 3 && tmp->second == 7) || + (p1.first->second == 7 && tmp->second == 3)); + + std::pair p2 = m.equal_range("durian"); + VERIFY(std::distance(p2.first, p2.second) == 1); + VERIFY(p2.first->first == "durian"); + VERIFY(p2.first->second == 8); + + std::pair p3 = m.equal_range("kiwi"); + VERIFY(p3.first == p3.second); + + VERIFY(m.count("grape") == 2); + VERIFY(m.count("durian") == 1); + VERIFY(m.count("kiwi") == 0); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/insert/24061-multimap.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/insert/24061-multimap.cc new file mode 100644 index 000000000..be3e077d8 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/insert/24061-multimap.cc @@ -0,0 +1,60 @@ +// 2005-10-08 Paolo Carlini +// +// Copyright (C) 2005, 2009 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 +// . + +// 6.3.4.6 Class template unordered_multimap + +#include +#include +#include + +// libstdc++/24061 +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::tr1::unordered_multimap Mmap; + typedef Mmap::iterator iterator; + typedef Mmap::const_iterator const_iterator; + typedef Mmap::value_type value_type; + + Mmap mm1; + + iterator it1 = mm1.insert(mm1.begin(), + value_type("all the love in the world", 1)); + VERIFY( mm1.size() == 1 ); + VERIFY( *it1 == value_type("all the love in the world", 1) ); + + const_iterator cit1(it1); + const_iterator cit2 = mm1.insert(cit1, + value_type("you know what you are?", 2)); + VERIFY( mm1.size() == 2 ); + VERIFY( cit2 != cit1 ); + VERIFY( *cit2 == value_type("you know what you are?", 2) ); + + iterator it2 = mm1.insert(it1, value_type("all the love in the world", 3)); + VERIFY( mm1.size() == 3 ); + VERIFY( it2 != it1 ); + VERIFY( *it2 == value_type("all the love in the world", 3) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/insert/multimap_range.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/insert/multimap_range.cc new file mode 100644 index 000000000..0c1d1cec4 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/insert/multimap_range.cc @@ -0,0 +1,92 @@ +// { dg-do run } + +// 2005-2-17 Matt Austern +// +// Copyright (C) 2005, 2009 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 +// . + +// 6.3.4.6 unordered_multimap +// range insert + +#include +#include +#include +#include +#include "testsuite_hooks.h" + +bool test __attribute__((unused)) = true; + +void test01() +{ + typedef std::tr1::unordered_multimap Map; + typedef std::pair Pair; + + Map m; + VERIFY(m.empty()); + + Pair A[5] = + { + Pair("red", 5), + Pair("green", 9), + Pair("blue", 3), + Pair("cyan", 8), + Pair("magenta", 7) + }; + + m.insert(A+0, A+5); + VERIFY(m.size() == 5); + VERIFY(std::distance(m.begin(), m.end()) == 5); + + for (int i = 0; i < 5; ++i) + VERIFY(std::find(m.begin(), m.end(), A[i]) != m.end()); +} + +void test02() +{ + typedef std::tr1::unordered_multimap Map; + typedef std::pair Pair; + + Map m; + VERIFY(m.empty()); + + Pair A[9] = + { + Pair("red", 5), + Pair("green", 9), + Pair("red", 19), + Pair("blue", 3), + Pair("blue", 60), + Pair("cyan", 8), + Pair("magenta", 7), + Pair("blue", 99), + Pair("green", 33) + }; + + m.insert(A+0, A+9); + VERIFY(m.size() == 9); + VERIFY(std::distance(m.begin(), m.end()) == 9); + + for (int i = 0; i < 9; ++i) + VERIFY(std::find(m.begin(), m.end(), A[i]) != m.end()); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/insert/multimap_single.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/insert/multimap_single.cc new file mode 100644 index 000000000..f4e1ab968 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/insert/multimap_single.cc @@ -0,0 +1,77 @@ +// { dg-do run } + +// 2005-2-17 Matt Austern +// +// Copyright (C) 2005, 2009 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 +// . + +// 6.3.4.6 unordered_multimap +// Single-element insert + +#include +#include +#include +#include "testsuite_hooks.h" + +bool test __attribute__((unused)) = true; + +void test01() +{ + typedef std::tr1::unordered_multimap Map; + typedef std::pair Pair; + + Map m; + VERIFY(m.empty()); + + Map::iterator i = m.insert(Pair("abcde", 3)); + VERIFY(m.size() == 1); + VERIFY(std::distance(m.begin(), m.end()) == 1); + VERIFY(i == m.begin()); + VERIFY(i->first == "abcde"); + VERIFY(i->second == 3); +} + +void test02() +{ + typedef std::tr1::unordered_multimap Map; + typedef std::pair Pair; + + Map m; + VERIFY(m.empty()); + + m.insert(Pair("abcde", 3)); + m.insert(Pair("abcde", 7)); + + VERIFY(m.size() == 2); + VERIFY(std::distance(m.begin(), m.end()) == 2); + + Map::iterator i1 = m.begin(); + Map::iterator i2 = i1; + ++i2; + + VERIFY(i1->first == "abcde"); + VERIFY(i2->first == "abcde"); + VERIFY((i1->second == 3 && i2->second == 7) || + (i1->second == 7 && i2->second == 3)); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..0eec033ce --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/explicit_instantiation.cc @@ -0,0 +1,42 @@ +// { dg-do compile } + +// 2005-02-17 Matt Austern +// +// Copyright (C) 2005, 2006, 2007, 2009 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 +// . + +// 6.3.4.6 unordered_multimap + +#include +#include + +using namespace std::tr1; +using std::string; +using std::equal_to; +using std::allocator; +using std::pair; + +template class unordered_multimap; +template class unordered_multimap, equal_to, + allocator > >; +template class unordered_multimap, equal_to, + allocator >; +template class __unordered_multimap, equal_to, + allocator >, true>; diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/iterator_neg.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/iterator_neg.cc new file mode 100644 index 000000000..fb0db99cf --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/iterator_neg.cc @@ -0,0 +1,40 @@ +// 2005-10-02 Paolo Carlini +// +// Copyright (C) 2005, 2009 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 +// . +// + +// { dg-do compile } + +#include + +void test01() +{ + typedef std::tr1::unordered_multimap Mmap; + + Mmap mm; + + Mmap::const_iterator cit = mm.begin(); + (*cit).second = 0; // { dg-error "read-only" } + + Mmap::const_local_iterator clit = mm.begin(0); + (*clit).second = 0; // { dg-error "read-only" } + + Mmap::iterator it = cit; // { dg-error "conversion" } + + Mmap::local_iterator lit = clit; // { dg-error "conversion" } +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/iterator_null_neg.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/iterator_null_neg.cc new file mode 100644 index 000000000..1709816c3 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/iterator_null_neg.cc @@ -0,0 +1,28 @@ +// 2005-09-10 Paolo Carlini +// +// Copyright (C) 2005, 2009, 2010 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 +// . +// + +// { dg-do compile } + +// libstdc++/23781 +#include +#include + +std::tr1::unordered_multimap::iterator it2 = NULL; // { dg-error "conversion" } +std::tr1::unordered_multimap::const_iterator cit2 = NULL; // { dg-error "conversion" } diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/typedefs.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/typedefs.cc new file mode 100644 index 000000000..54ae610e6 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/requirements/typedefs.cc @@ -0,0 +1,46 @@ +// { dg-do compile } +// 2008-08-27 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// 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 +// . + +// 6.3.4.6 unordered_multimap + +#include + +void test01() +{ + // Check for required typedefs + typedef std::tr1::unordered_multimap test_type; + + typedef test_type::key_type key_type; + typedef test_type::value_type value_type; + typedef test_type::mapped_type mapped_type; + typedef test_type::hasher hasher; + typedef test_type::key_equal key_equal; + typedef test_type::allocator_type allocator_type; + typedef test_type::pointer pointer; + typedef test_type::const_pointer const_pointer; + typedef test_type::reference reference; + typedef test_type::const_reference const_reference; + typedef test_type::size_type size_type; + typedef test_type::difference_type difference_type; + typedef test_type::iterator iterator; + typedef test_type::const_iterator const_iterator; + typedef test_type::local_iterator local_iterator; + typedef test_type::const_local_iterator const_local_iterator; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/swap/1.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/swap/1.cc new file mode 100644 index 000000000..590e85ec8 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/swap/1.cc @@ -0,0 +1,177 @@ +// 2005-12-20 Paolo Carlini + +// Copyright (C) 2005, 2009 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 +// . + +// 6.3.4.6 unordered_multimap::swap + +#include +#include +#include +#include + +// uneq_allocator as a non-empty allocator. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::tr1; + using std::pair; + using std::equal_to; + using std::map; + using std::multimap; + + typedef pair my_pair; + typedef __gnu_test::uneq_allocator my_alloc; + typedef unordered_multimap, equal_to, my_alloc> + my_ummap; + + const char title01[] = "Rivers of sand"; + const char title02[] = "Concret PH"; + const char title03[] = "Sonatas and Interludes for Prepared Piano"; + const char title04[] = "never as tired as when i'm waking up"; + + const size_t N1 = sizeof(title01); + const size_t N2 = sizeof(title02); + const size_t N3 = sizeof(title03); + const size_t N4 = sizeof(title04); + + typedef multimap my_mmap; + my_mmap mmap01_ref; + for (size_t i = 0; i < N1; ++i) + mmap01_ref.insert(my_pair(title01[i], i)); + my_mmap mmap02_ref; + for (size_t i = 0; i < N2; ++i) + mmap02_ref.insert(my_pair(title02[i], i)); + my_mmap mmap03_ref; + for (size_t i = 0; i < N3; ++i) + mmap03_ref.insert(my_pair(title03[i], i)); + my_mmap mmap04_ref; + for (size_t i = 0; i < N4; ++i) + mmap04_ref.insert(my_pair(title04[i], i)); + + typedef map my_map; + + my_ummap::size_type size01, size02; + + my_alloc alloc01(1); + + my_ummap ummap01(10, hash(), equal_to(), alloc01); + size01 = ummap01.size(); + my_ummap ummap02(10, hash(), equal_to(), alloc01); + size02 = ummap02.size(); + + ummap01.swap(ummap02); + VERIFY( ummap01.size() == size02 ); + VERIFY( ummap01.empty() ); + VERIFY( ummap02.size() == size01 ); + VERIFY( ummap02.empty() ); + + my_ummap ummap03(10, hash(), equal_to(), alloc01); + size01 = ummap03.size(); + my_ummap ummap04(mmap02_ref.begin(), mmap02_ref.end(), 10, hash(), + equal_to(), alloc01); + size02 = ummap04.size(); + + ummap03.swap(ummap04); + VERIFY( ummap03.size() == size02 ); + VERIFY( my_map(ummap03.begin(), ummap03.end()) + == my_map(mmap02_ref.begin(), mmap02_ref.end()) ); + VERIFY( ummap04.size() == size01 ); + VERIFY( ummap04.empty() ); + + my_ummap ummap05(mmap01_ref.begin(), mmap01_ref.end(), 10, hash(), + equal_to(), alloc01); + size01 = ummap05.size(); + my_ummap ummap06(mmap02_ref.begin(), mmap02_ref.end(), 10, hash(), + equal_to(), alloc01); + size02 = ummap06.size(); + + ummap05.swap(ummap06); + VERIFY( ummap05.size() == size02 ); + VERIFY( my_map(ummap05.begin(), ummap05.end()) + == my_map(mmap02_ref.begin(), mmap02_ref.end()) ); + VERIFY( ummap06.size() == size01 ); + VERIFY( my_map(ummap06.begin(), ummap06.end()) + == my_map(mmap01_ref.begin(), mmap01_ref.end()) ); + + my_ummap ummap07(mmap01_ref.begin(), mmap01_ref.end(), 10, hash(), + equal_to(), alloc01); + size01 = ummap07.size(); + my_ummap ummap08(mmap03_ref.begin(), mmap03_ref.end(), 10, hash(), + equal_to(), alloc01); + size02 = ummap08.size(); + + ummap07.swap(ummap08); + VERIFY( ummap07.size() == size02 ); + VERIFY( my_map(ummap07.begin(), ummap07.end()) + == my_map(mmap03_ref.begin(), mmap03_ref.end()) ); + VERIFY( ummap08.size() == size01 ); + VERIFY( my_map(ummap08.begin(), ummap08.end()) + == my_map(mmap01_ref.begin(), mmap01_ref.end()) ); + + my_ummap ummap09(mmap03_ref.begin(), mmap03_ref.end(), 10, hash(), + equal_to(), alloc01); + size01 = ummap09.size(); + my_ummap ummap10(mmap04_ref.begin(), mmap04_ref.end(), 10, hash(), + equal_to(), alloc01); + size02 = ummap10.size(); + + ummap09.swap(ummap10); + VERIFY( ummap09.size() == size02 ); + VERIFY( my_map(ummap09.begin(), ummap09.end()) + == my_map(mmap04_ref.begin(), mmap04_ref.end()) ); + VERIFY( ummap10.size() == size01 ); + VERIFY( my_map(ummap10.begin(), ummap10.end()) + == my_map(mmap03_ref.begin(), mmap03_ref.end()) ); + + my_ummap ummap11(mmap04_ref.begin(), mmap04_ref.end(), 10, hash(), + equal_to(), alloc01); + size01 = ummap11.size(); + my_ummap ummap12(mmap01_ref.begin(), mmap01_ref.end(), 10, hash(), + equal_to(), alloc01); + size02 = ummap12.size(); + + ummap11.swap(ummap12); + VERIFY( ummap11.size() == size02 ); + VERIFY( my_map(ummap11.begin(), ummap11.end()) + == my_map(mmap01_ref.begin(), mmap01_ref.end()) ); + VERIFY( ummap12.size() == size01 ); + VERIFY( my_map(ummap12.begin(), ummap12.end()) + == my_map(mmap04_ref.begin(), mmap04_ref.end()) ); + + my_ummap ummap13(mmap03_ref.begin(), mmap03_ref.end(), 10, hash(), + equal_to(), alloc01); + size01 = ummap13.size(); + my_ummap ummap14(mmap03_ref.begin(), mmap03_ref.end(), 10, hash(), + equal_to(), alloc01); + size02 = ummap14.size(); + + ummap13.swap(ummap14); + VERIFY( ummap13.size() == size02 ); + VERIFY( my_map(ummap13.begin(), ummap13.end()) + == my_map(mmap03_ref.begin(), mmap03_ref.end()) ); + VERIFY( ummap14.size() == size01 ); + VERIFY( my_map(ummap14.begin(), ummap14.end()) + == my_map(mmap03_ref.begin(), mmap03_ref.end()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/swap/2.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/swap/2.cc new file mode 100644 index 000000000..56528b820 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/swap/2.cc @@ -0,0 +1,206 @@ +// 2005-12-20 Paolo Carlini + +// Copyright (C) 2005, 2009 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 +// . + +// 6.3.4.6 unordered_multimap::swap + +#include +#include +#include +#include + +// uneq_allocator, two different personalities. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::tr1; + using std::pair; + using std::equal_to; + using std::map; + using std::multimap; + + typedef pair my_pair; + typedef __gnu_test::uneq_allocator my_alloc; + typedef unordered_multimap, equal_to, my_alloc> + my_ummap; + + const char title01[] = "Rivers of sand"; + const char title02[] = "Concret PH"; + const char title03[] = "Sonatas and Interludes for Prepared Piano"; + const char title04[] = "never as tired as when i'm waking up"; + + const size_t N1 = sizeof(title01); + const size_t N2 = sizeof(title02); + const size_t N3 = sizeof(title03); + const size_t N4 = sizeof(title04); + + typedef multimap my_mmap; + my_mmap mmap01_ref; + for (size_t i = 0; i < N1; ++i) + mmap01_ref.insert(my_pair(title01[i], i)); + my_mmap mmap02_ref; + for (size_t i = 0; i < N2; ++i) + mmap02_ref.insert(my_pair(title02[i], i)); + my_mmap mmap03_ref; + for (size_t i = 0; i < N3; ++i) + mmap03_ref.insert(my_pair(title03[i], i)); + my_mmap mmap04_ref; + for (size_t i = 0; i < N4; ++i) + mmap04_ref.insert(my_pair(title04[i], i)); + + typedef map my_map; + + my_ummap::size_type size01, size02; + + my_alloc alloc01(1), alloc02(2); + int personality01, personality02; + + my_ummap ummap01(10, hash(), equal_to(), alloc01); + size01 = ummap01.size(); + personality01 = ummap01.get_allocator().get_personality(); + my_ummap ummap02(10, hash(), equal_to(), alloc02); + size02 = ummap02.size(); + personality02 = ummap02.get_allocator().get_personality(); + + ummap01.swap(ummap02); + VERIFY( ummap01.size() == size02 ); + VERIFY( ummap01.empty() ); + VERIFY( ummap02.size() == size01 ); + VERIFY( ummap02.empty() ); + VERIFY( ummap01.get_allocator().get_personality() == personality02 ); + VERIFY( ummap02.get_allocator().get_personality() == personality01 ); + + my_ummap ummap03(10, hash(), equal_to(), alloc02); + size01 = ummap03.size(); + personality01 = ummap03.get_allocator().get_personality(); + my_ummap ummap04(mmap02_ref.begin(), mmap02_ref.end(), 10, hash(), + equal_to(), alloc01); + size02 = ummap04.size(); + personality02 = ummap04.get_allocator().get_personality(); + + ummap03.swap(ummap04); + VERIFY( ummap03.size() == size02 ); + VERIFY( my_map(ummap03.begin(), ummap03.end()) + == my_map(mmap02_ref.begin(), mmap02_ref.end()) ); + VERIFY( ummap04.size() == size01 ); + VERIFY( ummap04.empty() ); + VERIFY( ummap03.get_allocator().get_personality() == personality02 ); + VERIFY( ummap04.get_allocator().get_personality() == personality01 ); + + my_ummap ummap05(mmap01_ref.begin(), mmap01_ref.end(), 10, hash(), + equal_to(), alloc01); + size01 = ummap05.size(); + personality01 = ummap05.get_allocator().get_personality(); + my_ummap ummap06(mmap02_ref.begin(), mmap02_ref.end(), 10, hash(), + equal_to(), alloc02); + size02 = ummap06.size(); + personality02 = ummap06.get_allocator().get_personality(); + + ummap05.swap(ummap06); + VERIFY( ummap05.size() == size02 ); + VERIFY( my_map(ummap05.begin(), ummap05.end()) + == my_map(mmap02_ref.begin(), mmap02_ref.end()) ); + VERIFY( ummap06.size() == size01 ); + VERIFY( my_map(ummap06.begin(), ummap06.end()) + == my_map(mmap01_ref.begin(), mmap01_ref.end()) ); + VERIFY( ummap05.get_allocator().get_personality() == personality02 ); + VERIFY( ummap06.get_allocator().get_personality() == personality01 ); + + my_ummap ummap07(mmap01_ref.begin(), mmap01_ref.end(), 10, hash(), + equal_to(), alloc02); + size01 = ummap07.size(); + personality01 = ummap07.get_allocator().get_personality(); + my_ummap ummap08(mmap03_ref.begin(), mmap03_ref.end(), 10, hash(), + equal_to(), alloc01); + size02 = ummap08.size(); + personality02 = ummap08.get_allocator().get_personality(); + + ummap07.swap(ummap08); + VERIFY( ummap07.size() == size02 ); + VERIFY( my_map(ummap07.begin(), ummap07.end()) + == my_map(mmap03_ref.begin(), mmap03_ref.end()) ); + VERIFY( ummap08.size() == size01 ); + VERIFY( my_map(ummap08.begin(), ummap08.end()) + == my_map(mmap01_ref.begin(), mmap01_ref.end()) ); + VERIFY( ummap07.get_allocator().get_personality() == personality02 ); + VERIFY( ummap08.get_allocator().get_personality() == personality01 ); + + my_ummap ummap09(mmap03_ref.begin(), mmap03_ref.end(), 10, hash(), + equal_to(), alloc01); + size01 = ummap09.size(); + personality01 = ummap09.get_allocator().get_personality(); + my_ummap ummap10(mmap04_ref.begin(), mmap04_ref.end(), 10, hash(), + equal_to(), alloc02); + size02 = ummap10.size(); + personality02 = ummap10.get_allocator().get_personality(); + + ummap09.swap(ummap10); + VERIFY( ummap09.size() == size02 ); + VERIFY( my_map(ummap09.begin(), ummap09.end()) + == my_map(mmap04_ref.begin(), mmap04_ref.end()) ); + VERIFY( ummap10.size() == size01 ); + VERIFY( my_map(ummap10.begin(), ummap10.end()) + == my_map(mmap03_ref.begin(), mmap03_ref.end()) ); + VERIFY( ummap09.get_allocator().get_personality() == personality02 ); + VERIFY( ummap10.get_allocator().get_personality() == personality01 ); + + my_ummap ummap11(mmap04_ref.begin(), mmap04_ref.end(), 10, hash(), + equal_to(), alloc02); + size01 = ummap11.size(); + personality01 = ummap11.get_allocator().get_personality(); + my_ummap ummap12(mmap01_ref.begin(), mmap01_ref.end(), 10, hash(), + equal_to(), alloc01); + size02 = ummap12.size(); + personality02 = ummap12.get_allocator().get_personality(); + + ummap11.swap(ummap12); + VERIFY( ummap11.size() == size02 ); + VERIFY( my_map(ummap11.begin(), ummap11.end()) + == my_map(mmap01_ref.begin(), mmap01_ref.end()) ); + VERIFY( ummap12.size() == size01 ); + VERIFY( my_map(ummap12.begin(), ummap12.end()) + == my_map(mmap04_ref.begin(), mmap04_ref.end()) ); + VERIFY( ummap11.get_allocator().get_personality() == personality02 ); + VERIFY( ummap12.get_allocator().get_personality() == personality01 ); + + my_ummap ummap13(mmap03_ref.begin(), mmap03_ref.end(), 10, hash(), + equal_to(), alloc01); + size01 = ummap13.size(); + personality01 = ummap13.get_allocator().get_personality(); + my_ummap ummap14(mmap03_ref.begin(), mmap03_ref.end(), 10, hash(), + equal_to(), alloc02); + size02 = ummap14.size(); + personality02 = ummap14.get_allocator().get_personality(); + + ummap13.swap(ummap14); + VERIFY( ummap13.size() == size02 ); + VERIFY( my_map(ummap13.begin(), ummap13.end()) + == my_map(mmap03_ref.begin(), mmap03_ref.end()) ); + VERIFY( ummap14.size() == size01 ); + VERIFY( my_map(ummap14.begin(), ummap14.end()) + == my_map(mmap03_ref.begin(), mmap03_ref.end()) ); + VERIFY( ummap13.get_allocator().get_personality() == personality02 ); + VERIFY( ummap14.get_allocator().get_personality() == personality01 ); +} + +int main() +{ + test01(); + return 0; +} -- cgit v1.2.3