aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2024-10-28 13:05:53 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2024-10-28 13:52:53 +0000
commite320846fec00aaa3ca1f93790bc41dbc08503814 (patch)
treed43d0cacad108bece3bd47ab49b91a87bbd35f26 /libstdc++-v3
parenta9ec1bc06bd3ccf18f6c7b2f0255ce7878b418b7 (diff)
downloadgcc-e320846fec00aaa3ca1f93790bc41dbc08503814.zip
gcc-e320846fec00aaa3ca1f93790bc41dbc08503814.tar.gz
gcc-e320846fec00aaa3ca1f93790bc41dbc08503814.tar.bz2
libstdc++: Fix tests for std::vector range operations
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.
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/bool/cons/from_range.cc6
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/assign/assign_range.cc30
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/append_range.cc6
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/insert_range.cc10
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/cons/from_range.cc6
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/modifiers/append_range.cc4
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/modifiers/assign/assign_range.cc25
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/insert_range.cc8
8 files changed, 50 insertions, 45 deletions
diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/cons/from_range.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/cons/from_range.cc
index f5180e5..f531e7f 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/bool/cons/from_range.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/bool/cons/from_range.cc
@@ -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;
}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/assign/assign_range.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/assign/assign_range.cc
index a014dfe..7e58700 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/assign/assign_range.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/assign/assign_range.cc
@@ -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;
}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/append_range.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/append_range.cc
index e811a16..a35ed0f 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/append_range.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/append_range.cc
@@ -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;
}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/insert_range.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/insert_range.cc
index 82b67cd..4f48357 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/insert_range.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/insert_range.cc
@@ -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;
}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/from_range.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/from_range.cc
index d709c77..e91465f 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/cons/from_range.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/cons/from_range.cc
@@ -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;
}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/modifiers/append_range.cc b/libstdc++-v3/testsuite/23_containers/vector/modifiers/append_range.cc
index ff86cb7..24a5c7d 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/modifiers/append_range.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/modifiers/append_range.cc
@@ -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;
}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/modifiers/assign/assign_range.cc b/libstdc++-v3/testsuite/23_containers/vector/modifiers/assign/assign_range.cc
index c3302e9..4e8d8af 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/modifiers/assign/assign_range.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/modifiers/assign/assign_range.cc
@@ -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;
}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/insert_range.cc b/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/insert_range.cc
index 4cfab10..30219f5 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/insert_range.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/insert_range.cc
@@ -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;
}