public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-10838] libstdc++: Backport tests for associative container move constructors
@ 2022-06-15  8:14 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2022-06-15  8:14 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:884424353e3577b5f17b7dee4f01be4128943604

commit r10-10838-g884424353e3577b5f17b7dee4f01be4128943604
Author: Jonathan Wakely <jwakely@redhat.com>
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
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do run { target c++11 } }
+
+#include <map>
+#include <string>
+
+#include <testsuite_hooks.h>
+#include <testsuite_allocator.h>
+
+using Cmp = std::less<int>;
+
+using __gnu_test::uneq_allocator;
+
+void test01()
+{
+  typedef uneq_allocator<std::pair<const int, std::string>> alloc_type;
+  typedef std::map<int, std::string, Cmp, alloc_type> 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
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do run { target c++11 } }
+
+#include <map>
+#include <string>
+
+#include <testsuite_hooks.h>
+#include <testsuite_allocator.h>
+
+using Cmp = std::less<int>;
+
+using __gnu_test::uneq_allocator;
+
+void test01()
+{
+  typedef uneq_allocator<std::pair<const int, std::string>> alloc_type;
+  typedef std::multimap<int, std::string, Cmp, alloc_type> 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
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do run { target c++11 } }
+
+#include <set>
+#include <string>
+
+#include <testsuite_hooks.h>
+#include <testsuite_allocator.h>
+
+using Cmp = std::less<std::string>;
+
+using __gnu_test::uneq_allocator;
+
+void test01()
+{
+  typedef uneq_allocator<std::string> alloc_type;
+  typedef std::multiset<std::string, Cmp, alloc_type> 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
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do run { target c++11 } }
+
+#include <set>
+#include <string>
+
+#include <testsuite_hooks.h>
+#include <testsuite_allocator.h>
+
+using Cmp = std::less<std::string>;
+
+using __gnu_test::uneq_allocator;
+
+void test01()
+{
+  typedef uneq_allocator<std::string> alloc_type;
+  typedef std::set<std::string, Cmp, alloc_type> 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;
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-15  8:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-15  8:14 [gcc r10-10838] libstdc++: Backport tests for associative container move constructors Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).