Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[libc++][test] Fix test not relying on MinSequenceContainer #140372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
Loading
from

Conversation

huixie90
Copy link
Contributor

@huixie90 huixie90 commented May 17, 2025

The affected tests are replying on the fact that MinSequenceContainer does not have insert_range. This prevents landing of #140287

This PR creates a new helper class to allow the change in MinSequenceContainer

@huixie90 huixie90 requested a review from a team as a code owner May 17, 2025 11:30
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label May 17, 2025
@llvmbot
Copy link
Member

llvmbot commented May 17, 2025

@llvm/pr-subscribers-libcxx

Author: Hui (huixie90)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/140372.diff

3 Files Affected:

  • (modified) libcxx/test/libcxx/containers/container.adaptors/flat.multiset/insert_range.pass.cpp (+6-3)
  • (modified) libcxx/test/libcxx/containers/container.adaptors/flat.set/insert_range.pass.cpp (+6-3)
  • (modified) libcxx/test/libcxx/containers/container.adaptors/flat_helpers.h (+8)
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(
-      ![](auto& t) { return requires { t.insert_range(r); }; }(v),
+      ![](auto& t) { 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(
-      ![](auto& t) { return requires { t.insert_range(r); }; }(v),
+      ![](auto& t) { 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.