Skip to content

[libc++] [test] Improve test coverage for containers' scary.pass.cpp #131550

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

Merged
merged 2 commits into from
May 12, 2025

Conversation

halbi2
Copy link
Contributor

@halbi2 halbi2 commented Mar 17, 2025

No description provided.

@halbi2 halbi2 requested a review from a team as a code owner March 17, 2025 01:42
Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Mar 17, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 17, 2025

@llvm/pr-subscribers-libcxx

Author: None (halbi2)

Changes

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

5 Files Affected:

  • (modified) libcxx/test/std/containers/associative/multimap/scary.pass.cpp (+6-7)
  • (modified) libcxx/test/std/containers/associative/multiset/scary.pass.cpp (+6-7)
  • (added) libcxx/test/std/containers/container.adaptors/flat.multimap/scary.pass.cpp (+26)
  • (modified) libcxx/test/std/containers/unord/unord.multimap/scary.pass.cpp (+8-7)
  • (modified) libcxx/test/std/containers/unord/unord.multiset/scary.pass.cpp (+8-7)
diff --git a/libcxx/test/std/containers/associative/multimap/scary.pass.cpp b/libcxx/test/std/containers/associative/multimap/scary.pass.cpp
index 2390d8fed3350..89e753f854926 100644
--- a/libcxx/test/std/containers/associative/multimap/scary.pass.cpp
+++ b/libcxx/test/std/containers/associative/multimap/scary.pass.cpp
@@ -8,20 +8,19 @@
 
 // <map>
 
-// class map class multimap
+// class map
+// class multimap
 
-// Extension:  SCARY/N2913 iterator compatibility between map and multimap
+// Extension: SCARY/N2913 iterator compatibility between map and multimap
 
 #include <map>
 
 #include "test_macros.h"
 
-int main(int, char**) {
+void test() {
   typedef std::map<int, int> M1;
   typedef std::multimap<int, int> M2;
-  M2::iterator i;
-  M1::iterator j = i;
-  ((void)j);
 
-  return 0;
+  ASSERT_SAME_TYPE(M1::iterator, M2::iterator);
+  ASSERT_SAME_TYPE(M1::const_iterator, M2::const_iterator);
 }
diff --git a/libcxx/test/std/containers/associative/multiset/scary.pass.cpp b/libcxx/test/std/containers/associative/multiset/scary.pass.cpp
index 4d30c27733647..87ed05d84cdd7 100644
--- a/libcxx/test/std/containers/associative/multiset/scary.pass.cpp
+++ b/libcxx/test/std/containers/associative/multiset/scary.pass.cpp
@@ -8,20 +8,19 @@
 
 // <set>
 
-// class set class multiset
+// class set
+// class multiset
 
-// Extension:  SCARY/N2913 iterator compatibility between set and multiset
+// Extension: SCARY/N2913 iterator compatibility between set and multiset
 
 #include <set>
 
 #include "test_macros.h"
 
-int main(int, char**) {
+void test() {
   typedef std::set<int> M1;
   typedef std::multiset<int> M2;
-  M2::iterator i;
-  M1::iterator j = i;
-  ((void)j);
 
-  return 0;
+  ASSERT_SAME_TYPE(M1::iterator, M2::iterator);
+  ASSERT_SAME_TYPE(M1::const_iterator, M2::const_iterator);
 }
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/scary.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/scary.pass.cpp
new file mode 100644
index 0000000000000..e9ee28f790aaa
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/scary.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <flat_map>
+
+// class flat_map
+// class flat_multimap
+
+// Extension: SCARY/N2913 iterator compatibility between flat_map and flat_multimap
+
+#include <flat_map>
+
+#include "test_macros.h"
+
+void test() {
+  typedef std::flat_map<int, int> M1;
+  typedef std::flat_multimap<int, int> M2;
+
+  ASSERT_SAME_TYPE(M1::iterator, M2::iterator);
+  ASSERT_SAME_TYPE(M1::const_iterator, M2::const_iterator);
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/scary.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/scary.pass.cpp
index 59ade49434ca9..db2ef33b6ebf8 100644
--- a/libcxx/test/std/containers/unord/unord.multimap/scary.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.multimap/scary.pass.cpp
@@ -8,20 +8,21 @@
 
 // <unordered_map>
 
-// class unordered_map class unordered_multimap
+// class unordered_map
+// class unordered_multimap
 
-// Extension:  SCARY/N2913 iterator compatibility between unordered_map and unordered_multimap
+// Extension: SCARY/N2913 iterator compatibility between unordered_map and unordered_multimap
 
 #include <unordered_map>
 
 #include "test_macros.h"
 
-int main(int, char**) {
+void test() {
   typedef std::unordered_map<int, int> M1;
   typedef std::unordered_multimap<int, int> M2;
-  M2::iterator i;
-  M1::iterator j = i;
-  ((void)j);
 
-  return 0;
+  ASSERT_SAME_TYPE(M1::iterator, M2::iterator);
+  ASSERT_SAME_TYPE(M1::const_iterator, M2::const_iterator);
+  ASSERT_SAME_TYPE(M1::local_iterator, M2::local_iterator);
+  ASSERT_SAME_TYPE(M1::const_local_iterator, M2::const_local_iterator);
 }
diff --git a/libcxx/test/std/containers/unord/unord.multiset/scary.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/scary.pass.cpp
index 89f575bc2d790..cd33e1a91ec16 100644
--- a/libcxx/test/std/containers/unord/unord.multiset/scary.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.multiset/scary.pass.cpp
@@ -8,20 +8,21 @@
 
 // <unordered_set>
 
-// class unordered_set class unordered_multiset
+// class unordered_set
+// class unordered_multiset
 
-// Extension:  SCARY/N2913 iterator compatibility between unordered_set and unordered_multiset
+// Extension: SCARY/N2913 iterator compatibility between unordered_set and unordered_multiset
 
 #include <unordered_set>
 
 #include "test_macros.h"
 
-int main(int, char**) {
+void test() {
   typedef std::unordered_set<int> M1;
   typedef std::unordered_multiset<int> M2;
-  M2::iterator i;
-  M1::iterator j = i;
-  ((void)j);
 
-  return 0;
+  ASSERT_SAME_TYPE(M1::iterator, M2::iterator);
+  ASSERT_SAME_TYPE(M1::const_iterator, M2::const_iterator);
+  ASSERT_SAME_TYPE(M1::local_iterator, M2::local_iterator);
+  ASSERT_SAME_TYPE(M1::const_local_iterator, M2::const_local_iterator);
 }

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@huixie90 Can you chime in on your preferred way of checking this if we don't already?

@ldionne ldionne merged commit 5e94e26 into llvm:main May 12, 2025
85 checks passed
Copy link

@halbi2 Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

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.

5 participants