[libc++][test] Fix test not relying on MinSequenceContainer#140372
Merged
[libc++][test] Fix test not relying on MinSequenceContainer#140372
Conversation
Member
|
@llvm/pr-subscribers-libcxx Author: Hui (huixie90) ChangesFull diff: https://github.com/llvm/llvm-project/pull/140372.diff 3 Files Affected:
diff --git a/libcxx/test/libcxx/containers/container.adaptors/flat.multiset/insert_range.pass.cpp b/libcxx/test/libcxx/containers/container.adaptors/flat.multiset/insert_range.pass.cpp
index 3ca021c2ac650..d69b05a4dee5d 100644
--- a/libcxx/test/libcxx/containers/container.adaptors/flat.multiset/insert_range.pass.cpp
+++ b/libcxx/test/libcxx/containers/container.adaptors/flat.multiset/insert_range.pass.cpp
@@ -16,24 +16,27 @@
// out there are in that situation.
// https://github.com/llvm/llvm-project/issues/136656
+#include <algorithm>
+#include <cassert>
#include <flat_set>
#include <ranges>
#include <sstream>
#include <vector>
-#include "MinSequenceContainer.h"
+#include "../flat_helpers.h"
#include "test_macros.h"
void test() {
- MinSequenceContainer<int> v;
+ NotQuiteSequenceContainer<int> v;
std::flat_multiset s(v);
std::istringstream ints("0 1 1 0");
auto r = std::ranges::subrange(std::istream_iterator<int>(ints), std::istream_iterator<int>()) |
std::views::transform([](int i) { return i * i; });
static_assert(
-  { return requires { t.insert_range(r); }; }(v),
+  { return requires { t.insert_range(t.end(), r); }; }(v),
"This test is to test the case where the underlying container does not provide insert_range");
s.insert_range(r);
+ assert(std::ranges::equal(s, std::vector<int>{0, 0, 1, 1}));
}
int main(int, char**) {
diff --git a/libcxx/test/libcxx/containers/container.adaptors/flat.set/insert_range.pass.cpp b/libcxx/test/libcxx/containers/container.adaptors/flat.set/insert_range.pass.cpp
index 8023e251ccb17..35b9737e85106 100644
--- a/libcxx/test/libcxx/containers/container.adaptors/flat.set/insert_range.pass.cpp
+++ b/libcxx/test/libcxx/containers/container.adaptors/flat.set/insert_range.pass.cpp
@@ -16,24 +16,27 @@
// out there are in that situation.
// https://github.com/llvm/llvm-project/issues/136656
+#include <algorithm>
+#include <cassert>
#include <flat_set>
#include <ranges>
#include <sstream>
#include <vector>
-#include "MinSequenceContainer.h"
+#include "../flat_helpers.h"
#include "test_macros.h"
void test() {
- MinSequenceContainer<int> v;
+ NotQuiteSequenceContainer<int> v;
std::flat_set s(v);
std::istringstream ints("0 1 1 0");
auto r = std::ranges::subrange(std::istream_iterator<int>(ints), std::istream_iterator<int>()) |
std::views::transform([](int i) { return i * i; });
static_assert(
-  { return requires { t.insert_range(r); }; }(v),
+  { return requires { t.insert_range(t.end(), r); }; }(v),
"This test is to test the case where the underlying container does not provide insert_range");
s.insert_range(r);
+ assert(std::ranges::equal(s, std::vector<int>{0, 1}));
}
int main(int, char**) {
diff --git a/libcxx/test/libcxx/containers/container.adaptors/flat_helpers.h b/libcxx/test/libcxx/containers/container.adaptors/flat_helpers.h
index 1242c29715daa..cc59f59cc4ecc 100644
--- a/libcxx/test/libcxx/containers/container.adaptors/flat_helpers.h
+++ b/libcxx/test/libcxx/containers/container.adaptors/flat_helpers.h
@@ -9,6 +9,8 @@
#ifndef TEST_LIBCXX_CONTAINERS_CONTAINER_ADAPTORS_FLAT_HELPERS_H
#define TEST_LIBCXX_CONTAINERS_CONTAINER_ADAPTORS_FLAT_HELPERS_H
+#include <vector>
+
struct TrackCopyMove {
mutable int copy_count = 0;
int move_count = 0;
@@ -37,4 +39,10 @@ struct TrackCopyMove {
constexpr bool operator<(const TrackCopyMove&) const { return false; }
};
+template <class T>
+struct NotQuiteSequenceContainer : std::vector<T> {
+ // hide the name insert_range
+ void insert_range() = delete;
+};
+
#endif // TEST_LIBCXX_CONTAINERS_CONTAINER_ADAPTORS_FLAT_HELPERS_H
|
ldionne
approved these changes
May 27, 2025
Member
|
Ignoring CI since these are infra issues. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The affected tests are relying on the fact that
MinSequenceContainerdoes not haveinsert_range. This prevents landing of #140287This PR creates a new helper class to allow the change in
MinSequenceContainer