From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id BA998385C33F; Wed, 15 Jun 2022 08:14:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA998385C33F MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r10-10838] libstdc++: Backport tests for associative container move constructors X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/releases/gcc-10 X-Git-Oldrev: d4fdb293004f2e104edf823d4820d4ee73aa2660 X-Git-Newrev: 884424353e3577b5f17b7dee4f01be4128943604 Message-Id: <20220615081444.BA998385C33F@sourceware.org> Date: Wed, 15 Jun 2022 08:14:44 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2022 08:14:44 -0000 https://gcc.gnu.org/g:884424353e3577b5f17b7dee4f01be4128943604 commit r10-10838-g884424353e3577b5f17b7dee4f01be4128943604 Author: Jonathan Wakely Date: Tue Jun 14 20:42:54 2022 +0100 libstdc++: Backport tests for associative container move constructors libstdc++-v3/ChangeLog: * testsuite/23_containers/map/allocator/move_cons.cc: New test. * testsuite/23_containers/multimap/allocator/move_cons.cc: New test. * testsuite/23_containers/multiset/allocator/move_cons.cc: New test. * testsuite/23_containers/set/allocator/move_cons.cc: New test. Diff: --- .../23_containers/map/allocator/move_cons.cc | 53 ++++++++++++++++++++++ .../23_containers/multimap/allocator/move_cons.cc | 53 ++++++++++++++++++++++ .../23_containers/multiset/allocator/move_cons.cc | 53 ++++++++++++++++++++++ .../23_containers/set/allocator/move_cons.cc | 53 ++++++++++++++++++++++ 4 files changed, 212 insertions(+) diff --git a/libstdc++-v3/testsuite/23_containers/map/allocator/move_cons.cc b/libstdc++-v3/testsuite/23_containers/map/allocator/move_cons.cc new file mode 100644 index 00000000000..b82d3532135 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/allocator/move_cons.cc @@ -0,0 +1,53 @@ +// Copyright (C) 2020-2021 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 run { target c++11 } } + +#include +#include + +#include +#include + +using Cmp = std::less; + +using __gnu_test::uneq_allocator; + +void test01() +{ + typedef uneq_allocator> alloc_type; + typedef std::map test_type; + test_type v1(alloc_type(1)); + const char* str = "A long enough string to require dynamic allocation"; + v1 = { { 1, str } }; + + alloc_type a2(2); + test_type v2(std::move(v1), a2); + + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); + + VERIFY( v1.empty() ); + VERIFY( v2[1] == str ); +} + + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/multimap/allocator/move_cons.cc b/libstdc++-v3/testsuite/23_containers/multimap/allocator/move_cons.cc new file mode 100644 index 00000000000..37db0f005d1 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/multimap/allocator/move_cons.cc @@ -0,0 +1,53 @@ +// Copyright (C) 2020-2021 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 run { target c++11 } } + +#include +#include + +#include +#include + +using Cmp = std::less; + +using __gnu_test::uneq_allocator; + +void test01() +{ + typedef uneq_allocator> alloc_type; + typedef std::multimap test_type; + test_type v1(alloc_type(1)); + const char* str = "A long enough string to require dynamic allocation"; + v1 = { { 1, str } }; + + alloc_type a2(2); + test_type v2(std::move(v1), a2); + + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); + + VERIFY( v1.empty() ); + VERIFY( v2.begin()->second == str ); +} + + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/multiset/allocator/move_cons.cc b/libstdc++-v3/testsuite/23_containers/multiset/allocator/move_cons.cc new file mode 100644 index 00000000000..82dfbc98581 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/multiset/allocator/move_cons.cc @@ -0,0 +1,53 @@ +// Copyright (C) 2020-2021 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 run { target c++11 } } + +#include +#include + +#include +#include + +using Cmp = std::less; + +using __gnu_test::uneq_allocator; + +void test01() +{ + typedef uneq_allocator alloc_type; + typedef std::multiset test_type; + test_type v1(alloc_type(1)); + const char* str = "A long enough string to require dynamic allocation"; + v1 = { str }; + + alloc_type a2(2); + test_type v2(std::move(v1), a2); + + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); + + VERIFY( v1.count(str) == 0 ); + VERIFY( v2.count(str) == 1 ); +} + + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/set/allocator/move_cons.cc b/libstdc++-v3/testsuite/23_containers/set/allocator/move_cons.cc new file mode 100644 index 00000000000..b9b42fcd75c --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/set/allocator/move_cons.cc @@ -0,0 +1,53 @@ +// Copyright (C) 2020-2021 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 run { target c++11 } } + +#include +#include + +#include +#include + +using Cmp = std::less; + +using __gnu_test::uneq_allocator; + +void test01() +{ + typedef uneq_allocator alloc_type; + typedef std::set test_type; + test_type v1(alloc_type(1)); + const char* str = "A long enough string to require dynamic allocation"; + v1 = { str }; + + alloc_type a2(2); + test_type v2(std::move(v1), a2); + + VERIFY(1 == v1.get_allocator().get_personality()); + VERIFY(2 == v2.get_allocator().get_personality()); + + VERIFY( v1.count(str) == 0 ); + VERIFY( v2.count(str) == 1 ); +} + + +int main() +{ + test01(); + return 0; +}