]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix tests for std::vector range operations
authorJonathan Wakely <jwakely@redhat.com>
Mon, 28 Oct 2024 13:05:53 +0000 (13:05 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 28 Oct 2024 13:52:53 +0000 (13:52 +0000)
The commit I pushed was not the one I'd tested, so it had older versions
of the tests, with bugs that I'd already fixed locally. This commit has
the fixed tests that I'd intended to push in the first place.

libstdc++-v3/ChangeLog:

* testsuite/23_containers/vector/bool/cons/from_range.cc: Use
dg-do run instead of compile.
(test_ranges): Use do_test instead of do_test_a for rvalue
range.
(test_constexpr): Call function template instead of just
instantiating it.
* testsuite/23_containers/vector/bool/modifiers/assign/assign_range.cc:
Use dg-do run instead of compile.
(do_test): Use same test logic for vector<bool> as for primary
template.
(test_constexpr): Call function template instead of just
instantiating it.
* testsuite/23_containers/vector/bool/modifiers/insert/append_range.cc:
Use dg-do run instead of compile.
(test_ranges): Use do_test instead of do_test_a for rvalue
range.
(test_constexpr): Call function template instead of just
instantiating it.
* testsuite/23_containers/vector/bool/modifiers/insert/insert_range.cc:
Use dg-do run instead of compile.
(do_test): Fix incorrect function arguments to match intended
results.
(test_ranges): Use do_test instead of do_test_a for rvalue
range.
(test_constexpr): Call function template instead of just
instantiating it.
* testsuite/23_containers/vector/cons/from_range.cc: Use dg-do
run instead of compile.
(test_ranges): Fix ill-formed call to do_test.
(test_constexpr): Call function template instead of just
instantiating it.
* testsuite/23_containers/vector/modifiers/append_range.cc:
Use dg-do run instead of compile.
(test_constexpr): Likewise.
* testsuite/23_containers/vector/modifiers/assign/assign_range.cc:
Use dg-do run instead of compile.
(do_test): Do not reuse input ranges.
(test_constexpr): Call function template instead of just
instantiating it.
* testsuite/23_containers/vector/modifiers/insert/insert_range.cc:
Use dg-do run instead of compile.
(do_test): Fix incorrect function arguments to match intended
results.
(test_constexpr): Call function template instead of just
instantiating it.

libstdc++-v3/testsuite/23_containers/vector/bool/cons/from_range.cc
libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/assign/assign_range.cc
libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/append_range.cc
libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/insert_range.cc
libstdc++-v3/testsuite/23_containers/vector/cons/from_range.cc
libstdc++-v3/testsuite/23_containers/vector/modifiers/append_range.cc
libstdc++-v3/testsuite/23_containers/vector/modifiers/assign/assign_range.cc
libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/insert_range.cc

index f5180e5a24333e214c92d30ee984068f28f32e42..f531e7f503961fa03e90982f31f5d9ef2b9732db 100644 (file)
@@ -1,4 +1,4 @@
-// { dg-do compile { target c++23 } }
+// { dg-do run { target c++23 } }
 
 #include <vector>
 #include <span>
@@ -71,7 +71,7 @@ test_ranges()
     bool val;
   };
   using rvalue_input_range = test_range<C, input_iterator_wrapper_rval>;
-  do_test_a<rvalue_input_range>();
+  do_test<rvalue_input_range>(std::allocator<int>());
 
   return true;
 }
@@ -80,7 +80,7 @@ constexpr bool
 test_constexpr()
 {
   // XXX: this doesn't test the non-forward_range code paths are constexpr.
-  do_test<std::span<bool>, std::allocator<bool>>;
+  do_test<std::span<bool>>(std::allocator<bool>());
   return true;
 }
 
index a014dfe90de7c2bcbe2b3f397a700daa5957bc2a..7e58700ff2bb20a94ea812a0740c678ea424a662 100644 (file)
@@ -1,4 +1,4 @@
-// { dg-do compile { target c++23 } }
+// { dg-do run { target c++23 } }
 
 #include <vector>
 #include <span>
@@ -22,29 +22,37 @@ do_test()
     return true;
   };
 
-  Range r4(a, a+4);
-  Range r9(a);
-
+  // assign to empty vector
   std::vector<bool, Alloc> v;
   v.assign_range(Range(a, a));
   VERIFY( v.empty() );
   VERIFY( v.capacity() == 0 );
-  v.assign_range(r4);
+  v.assign_range(Range(a, a+4));
   VERIFY( eq(v, {a, 4}) );
   v.clear();
-  v.assign_range(r9); // larger than v.capacity()
+  v.assign_range(Range(a)); // larger than v.capacity()
   VERIFY( eq(v, a) );
-  v.assign_range(r9); // equal to size() and equal to capacity()
+  v.clear();
+  v.assign_range(Range(a, a+4)); // smaller than v.capacity()
+  VERIFY( eq(v, {a, 4}) );
+  v.clear();
+  v.assign_range(Range(a)); // equal to v.capacity()
+  VERIFY( eq(v, a) );
+
+  // assign to non-empty vector
+  v.assign_range(Range(a, a+4)); // smaller than size()
+  VERIFY( eq(v, {a, 4}) );
+  v.assign_range(Range(a)); // larger than size(), equal to capacity()
   VERIFY( eq(v, a) );
   v.resize(1);
-  v.assign_range(r4); // larger than size(), smaller than capacity()
+  v.assign_range(Range(a, a+4)); // larger than size(), smaller than capacity()
   VERIFY( eq(v, {a, 4}) );
   v.clear();
   v.resize(4);
-  v.assign_range(r4); // equal to size(), smaller than capacity()
+  v.assign_range(Range(a, a+4)); // equal to size(), smaller than capacity()
   VERIFY( eq(v, {a, 4}) );
   v.shrink_to_fit();
-  v.assign_range(r9); // larger than capacity()
+  v.assign_range(Range(a)); // larger than capacity()
   VERIFY( eq(v, a) );
   v.assign_range(Range(a, a));
   VERIFY( v.empty() );
@@ -95,7 +103,7 @@ constexpr bool
 test_constexpr()
 {
   // XXX: this doesn't test the non-forward_range code paths are constexpr.
-  do_test<std::span<short>, std::allocator<bool>>;
+  do_test<std::span<short>, std::allocator<bool>>();
   return true;
 }
 
index e811a1697e028de459cbf552d2900e1c9035aef7..a35ed0f20266f6b613401983e357496d2248b6e3 100644 (file)
@@ -1,4 +1,4 @@
-// { dg-do compile { target c++23 } }
+// { dg-do run { target c++23 } }
 
 #include <vector>
 #include <span>
@@ -73,7 +73,7 @@ test_ranges()
     bool val;
   };
   using rvalue_input_range = test_range<C, input_iterator_wrapper_rval>;
-  do_test_a<rvalue_input_range>();
+  do_test<rvalue_input_range, std::allocator<bool>>();
 
   return true;
 }
@@ -82,7 +82,7 @@ constexpr bool
 test_constexpr()
 {
   // XXX: this doesn't test the non-forward_range code paths are constexpr.
-  do_test<std::span<short>, std::allocator<bool>>;
+  do_test<std::span<short>, std::allocator<bool>>();
   return true;
 }
 
index 82b67cdb8b9b0b88d624db2676b8a8d6375537e6..4f4835746ea44c1204d67617782f589a6773e7fb 100644 (file)
@@ -1,4 +1,4 @@
-// { dg-do compile { target c++23 } }
+// { dg-do run { target c++23 } }
 
 #include <vector>
 #include <span>
@@ -29,7 +29,7 @@ do_test()
   v.insert_range(v.begin(), Range(a, a+4));
   VERIFY( eq(v, {a, a+4}) );
   v.clear();
-  v.insert_range(v.begin(), Range(a, a+5));
+  v.insert_range(v.begin(), Range(a+4, a+9));
   VERIFY( eq(v, {a+4, a+9}) );
   v.insert_range(v.begin(), Range(a, a+4));
   VERIFY( eq(v, a) );
@@ -41,7 +41,7 @@ do_test()
   VERIFY( eq(v, a) );
   v.resize(3);
   v.insert_range(v.begin()+1, Range(a+4, a+9));
-  v.insert_range(v.begin()+1, Range(a+1, a+3));
+  v.insert_range(v.begin()+1, Range(a+1, a+4));
   v.resize(9);
   VERIFY( eq(v, a) );
   v.insert_range(v.begin(), Range(a, a));
@@ -84,7 +84,7 @@ test_ranges()
     bool val;
   };
   using rvalue_input_range = test_range<C, input_iterator_wrapper_rval>;
-  do_test_a<rvalue_input_range>();
+  do_test<rvalue_input_range, std::allocator<bool>>();
 
   return true;
 }
@@ -93,7 +93,7 @@ constexpr bool
 test_constexpr()
 {
   // XXX: this doesn't test the non-forward_range code paths are constexpr.
-  do_test<std::span<bool>, std::allocator<bool>>;
+  do_test<std::span<bool>, std::allocator<bool>>();
   return true;
 }
 
index d709c77720d2ac627516ddaaa04d617d53e9c831..e91465f5a711494b604ecf0d3c3b4a6a647b0e89 100644 (file)
@@ -1,4 +1,4 @@
-// { dg-do compile { target c++23 } }
+// { dg-do run { target c++23 } }
 
 #include <vector>
 #include <span>
@@ -88,7 +88,7 @@ test_ranges()
     int val;
   };
   using rvalue_input_range = test_range<C, input_iterator_wrapper_rval>;
-  do_test<rvalue_input_range, std::allocator<int>>();
+  do_test<rvalue_input_range>(std::allocator<int>());
 
   return true;
 }
@@ -97,7 +97,7 @@ constexpr bool
 test_constexpr()
 {
   // XXX: this doesn't test the non-forward_range code paths are constexpr.
-  do_test<std::span<short>, std::allocator<int>>;
+  do_test<std::span<short>>(std::allocator<int>());
   return true;
 }
 
index ff86cb745573a8cd2b99d4f30fc668d6ba00ea74..24a5c7d0e7cc325768c01868bf4fd287608336f3 100644 (file)
@@ -1,4 +1,4 @@
-// { dg-do compile { target c++23 } }
+// { dg-do run { target c++23 } }
 
 #include <vector>
 #include <span>
@@ -86,7 +86,7 @@ constexpr bool
 test_constexpr()
 {
   // XXX: this doesn't test the non-forward_range code paths are constexpr.
-  do_test<std::span<short>, std::allocator<int>>;
+  do_test<std::span<short>, std::allocator<int>>();
   return true;
 }
 
index c3302e988495a9ceab85e058bf9d4b9bba0374ac..4e8d8af1614acafec7a1b8f2387be87a7e679af4 100644 (file)
@@ -1,4 +1,4 @@
-// { dg-do compile { target c++23 } }
+// { dg-do run { target c++23 } }
 
 #include <vector>
 #include <span>
@@ -26,40 +26,37 @@ do_test()
     return true;
   };
 
-  Range r4(a, a+4);
-  Range r9(a);
-
   // assign to empty vector
   std::vector<V, Alloc> v;
   v.assign_range(Range(a, a));
   VERIFY( v.empty() );
   VERIFY( v.capacity() == 0 );
-  v.assign_range(r4);
+  v.assign_range(Range(a, a+4));
   VERIFY( eq(v, {a, 4}) );
   v.clear();
-  v.assign_range(r9); // larger than v.capacity()
+  v.assign_range(Range(a)); // larger than v.capacity()
   VERIFY( eq(v, a) );
   v.clear();
-  v.assign_range(r4); // smaller than v.capacity()
+  v.assign_range(Range(a, a+4)); // smaller than v.capacity()
   VERIFY( eq(v, {a, 4}) );
   v.clear();
-  v.assign_range(r9); // equal to v.capacity()
+  v.assign_range(Range(a)); // equal to v.capacity()
   VERIFY( eq(v, a) );
 
   // assign to non-empty vector
-  v.assign_range(r4); // smaller than size()
+  v.assign_range(Range(a, a+4)); // smaller than size()
   VERIFY( eq(v, {a, 4}) );
-  v.assign_range(r9); // larger than size(), equal to capacity()
+  v.assign_range(Range(a)); // larger than size(), equal to capacity()
   VERIFY( eq(v, a) );
   v.resize(1);
-  v.assign_range(r4); // larger than size(), smaller than capacity()
+  v.assign_range(Range(a, a+4)); // larger than size(), smaller than capacity()
   VERIFY( eq(v, {a, 4}) );
   v.clear();
   v.resize(4);
-  v.assign_range(r4); // equal to size(), smaller than capacity()
+  v.assign_range(Range(a, a+4)); // equal to size(), smaller than capacity()
   VERIFY( eq(v, {a, 4}) );
   v.shrink_to_fit();
-  v.assign_range(r9); // larger than capacity()
+  v.assign_range(Range(a)); // larger than capacity()
   VERIFY( eq(v, a) );
   v.assign_range(Range(a, a));
   VERIFY( v.empty() );
@@ -110,7 +107,7 @@ constexpr bool
 test_constexpr()
 {
   // XXX: this doesn't test the non-forward_range code paths are constexpr.
-  do_test<std::span<short>, std::allocator<int>>;
+  do_test<std::span<short>, std::allocator<int>>();
   return true;
 }
 
index 4cfab10eb4c9520202c6fa41db81151f40d56d1a..30219f5da02fcb6e119dda52841b73570cc710af 100644 (file)
@@ -1,4 +1,4 @@
-// { dg-do compile { target c++23 } }
+// { dg-do run { target c++23 } }
 
 #include <vector>
 #include <span>
@@ -33,7 +33,7 @@ do_test()
   v.insert_range(v.begin(), Range(a, a+4));
   VERIFY( eq(v, {a, a+4}) );
   v.clear();
-  v.insert_range(v.begin(), Range(a, a+5));
+  v.insert_range(v.begin(), Range(a+4, a+9));
   VERIFY( eq(v, {a+4, a+9}) );
   v.insert_range(v.begin(), Range(a, a+4));
   VERIFY( eq(v, a) );
@@ -45,7 +45,7 @@ do_test()
   VERIFY( eq(v, a) );
   v.resize(3);
   v.insert_range(v.begin()+1, Range(a+4, a+9));
-  v.insert_range(v.begin()+1, Range(a+1, a+3));
+  v.insert_range(v.begin()+1, Range(a+1, a+4));
   v.resize(9);
   VERIFY( eq(v, a) );
   v.insert_range(v.begin() + 6, Range(a, a));
@@ -97,7 +97,7 @@ constexpr bool
 test_constexpr()
 {
   // XXX: this doesn't test the non-forward_range code paths are constexpr.
-  do_test<std::span<short>, std::allocator<int>>;
+  do_test<std::span<short>, std::allocator<int>>();
   return true;
 }