[libc++] Improve test coverage for containers' scary.pass.cpp (#131550)
diff --git a/libcxx/test/std/containers/associative/multimap/scary.pass.cpp b/libcxx/test/libcxx/containers/associative/map/scary.compile.pass.cpp
similarity index 68%
rename from libcxx/test/std/containers/associative/multimap/scary.pass.cpp
rename to libcxx/test/libcxx/containers/associative/map/scary.compile.pass.cpp
index 2390d8f..89e753f 100644
--- a/libcxx/test/std/containers/associative/multimap/scary.pass.cpp
+++ b/libcxx/test/libcxx/containers/associative/map/scary.compile.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/libcxx/containers/associative/set/scary.compile.pass.cpp
similarity index 67%
rename from libcxx/test/std/containers/associative/multiset/scary.pass.cpp
rename to libcxx/test/libcxx/containers/associative/set/scary.compile.pass.cpp
index 4d30c27..87ed05d 100644
--- a/libcxx/test/std/containers/associative/multiset/scary.pass.cpp
+++ b/libcxx/test/libcxx/containers/associative/set/scary.compile.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/libcxx/containers/associative/unord.map/scary.compile.pass.cpp b/libcxx/test/libcxx/containers/associative/unord.map/scary.compile.pass.cpp
new file mode 100644
index 0000000..db2ef33
--- /dev/null
+++ b/libcxx/test/libcxx/containers/associative/unord.map/scary.compile.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// class unordered_map
+// class unordered_multimap
+
+// Extension: SCARY/N2913 iterator compatibility between unordered_map and unordered_multimap
+
+#include <unordered_map>
+
+#include "test_macros.h"
+
+void test() {
+ typedef std::unordered_map<int, int> M1;
+ typedef std::unordered_multimap<int, int> M2;
+
+ 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/libcxx/containers/associative/unord.set/scary.compile.pass.cpp b/libcxx/test/libcxx/containers/associative/unord.set/scary.compile.pass.cpp
new file mode 100644
index 0000000..cd33e1a
--- /dev/null
+++ b/libcxx/test/libcxx/containers/associative/unord.set/scary.compile.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// class unordered_set
+// class unordered_multiset
+
+// Extension: SCARY/N2913 iterator compatibility between unordered_set and unordered_multiset
+
+#include <unordered_set>
+
+#include "test_macros.h"
+
+void test() {
+ typedef std::unordered_set<int> M1;
+ typedef std::unordered_multiset<int> M2;
+
+ 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/libcxx/containers/container.adaptors/flat.map/scary.compile.pass.cpp b/libcxx/test/libcxx/containers/container.adaptors/flat.map/scary.compile.pass.cpp
new file mode 100644
index 0000000..3fff89c
--- /dev/null
+++ b/libcxx/test/libcxx/containers/container.adaptors/flat.map/scary.compile.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_map>
+
+// class flat_map
+// class flat_multimap
+
+// Extension: SCARY/N2913 iterator compatibility between flat_map and flat_multimap
+// Test for the absence of this feature
+
+#include <flat_map>
+#include <type_traits>
+
+#include "test_macros.h"
+
+void test() {
+ typedef std::flat_map<int, int> M1;
+ typedef std::flat_multimap<int, int> M2;
+
+ static_assert(!std::is_convertible_v<M1::iterator, M2::iterator>);
+ static_assert(!std::is_convertible_v<M2::iterator, M1::iterator>);
+
+ static_assert(!std::is_convertible_v<M1::const_iterator, M2::const_iterator>);
+ static_assert(!std::is_convertible_v<M2::const_iterator, M1::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
deleted file mode 100644
index 59ade49..0000000
--- a/libcxx/test/std/containers/unord/unord.multimap/scary.pass.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <unordered_map>
-
-// class unordered_map class unordered_multimap
-
-// Extension: SCARY/N2913 iterator compatibility between unordered_map and unordered_multimap
-
-#include <unordered_map>
-
-#include "test_macros.h"
-
-int main(int, char**) {
- 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;
-}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/scary.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/scary.pass.cpp
deleted file mode 100644
index 89f575b..0000000
--- a/libcxx/test/std/containers/unord/unord.multiset/scary.pass.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <unordered_set>
-
-// class unordered_set class unordered_multiset
-
-// Extension: SCARY/N2913 iterator compatibility between unordered_set and unordered_multiset
-
-#include <unordered_set>
-
-#include "test_macros.h"
-
-int main(int, char**) {
- typedef std::unordered_set<int> M1;
- typedef std::unordered_multiset<int> M2;
- M2::iterator i;
- M1::iterator j = i;
- ((void)j);
-
- return 0;
-}