Skip to content

Commit 5e94e26

Browse files
authored
[libc++] Improve test coverage for containers' scary.pass.cpp (llvm#131550)
1 parent 5b2fc2b commit 5e94e26

File tree

5 files changed

+61
-28
lines changed

5 files changed

+61
-28
lines changed

libcxx/test/std/containers/associative/multimap/scary.pass.cpp renamed to libcxx/test/libcxx/containers/associative/map/scary.compile.pass.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@
88

99
// <map>
1010

11-
// class map class multimap
11+
// class map
12+
// class multimap
1213

13-
// Extension: SCARY/N2913 iterator compatibility between map and multimap
14+
// Extension: SCARY/N2913 iterator compatibility between map and multimap
1415

1516
#include <map>
1617

1718
#include "test_macros.h"
1819

19-
int main(int, char**) {
20+
void test() {
2021
typedef std::map<int, int> M1;
2122
typedef std::multimap<int, int> M2;
22-
M2::iterator i;
23-
M1::iterator j = i;
24-
((void)j);
2523

26-
return 0;
24+
ASSERT_SAME_TYPE(M1::iterator, M2::iterator);
25+
ASSERT_SAME_TYPE(M1::const_iterator, M2::const_iterator);
2726
}

libcxx/test/std/containers/associative/multiset/scary.pass.cpp renamed to libcxx/test/libcxx/containers/associative/set/scary.compile.pass.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@
88

99
// <set>
1010

11-
// class set class multiset
11+
// class set
12+
// class multiset
1213

13-
// Extension: SCARY/N2913 iterator compatibility between set and multiset
14+
// Extension: SCARY/N2913 iterator compatibility between set and multiset
1415

1516
#include <set>
1617

1718
#include "test_macros.h"
1819

19-
int main(int, char**) {
20+
void test() {
2021
typedef std::set<int> M1;
2122
typedef std::multiset<int> M2;
22-
M2::iterator i;
23-
M1::iterator j = i;
24-
((void)j);
2523

26-
return 0;
24+
ASSERT_SAME_TYPE(M1::iterator, M2::iterator);
25+
ASSERT_SAME_TYPE(M1::const_iterator, M2::const_iterator);
2726
}

libcxx/test/std/containers/unord/unord.multimap/scary.pass.cpp renamed to libcxx/test/libcxx/containers/associative/unord.map/scary.compile.pass.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,21 @@
88

99
// <unordered_map>
1010

11-
// class unordered_map class unordered_multimap
11+
// class unordered_map
12+
// class unordered_multimap
1213

13-
// Extension: SCARY/N2913 iterator compatibility between unordered_map and unordered_multimap
14+
// Extension: SCARY/N2913 iterator compatibility between unordered_map and unordered_multimap
1415

1516
#include <unordered_map>
1617

1718
#include "test_macros.h"
1819

19-
int main(int, char**) {
20+
void test() {
2021
typedef std::unordered_map<int, int> M1;
2122
typedef std::unordered_multimap<int, int> M2;
22-
M2::iterator i;
23-
M1::iterator j = i;
24-
((void)j);
2523

26-
return 0;
24+
ASSERT_SAME_TYPE(M1::iterator, M2::iterator);
25+
ASSERT_SAME_TYPE(M1::const_iterator, M2::const_iterator);
26+
ASSERT_SAME_TYPE(M1::local_iterator, M2::local_iterator);
27+
ASSERT_SAME_TYPE(M1::const_local_iterator, M2::const_local_iterator);
2728
}

libcxx/test/std/containers/unord/unord.multiset/scary.pass.cpp renamed to libcxx/test/libcxx/containers/associative/unord.set/scary.compile.pass.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,21 @@
88

99
// <unordered_set>
1010

11-
// class unordered_set class unordered_multiset
11+
// class unordered_set
12+
// class unordered_multiset
1213

13-
// Extension: SCARY/N2913 iterator compatibility between unordered_set and unordered_multiset
14+
// Extension: SCARY/N2913 iterator compatibility between unordered_set and unordered_multiset
1415

1516
#include <unordered_set>
1617

1718
#include "test_macros.h"
1819

19-
int main(int, char**) {
20+
void test() {
2021
typedef std::unordered_set<int> M1;
2122
typedef std::unordered_multiset<int> M2;
22-
M2::iterator i;
23-
M1::iterator j = i;
24-
((void)j);
2523

26-
return 0;
24+
ASSERT_SAME_TYPE(M1::iterator, M2::iterator);
25+
ASSERT_SAME_TYPE(M1::const_iterator, M2::const_iterator);
26+
ASSERT_SAME_TYPE(M1::local_iterator, M2::local_iterator);
27+
ASSERT_SAME_TYPE(M1::const_local_iterator, M2::const_local_iterator);
2728
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
10+
11+
// <flat_map>
12+
13+
// class flat_map
14+
// class flat_multimap
15+
16+
// Extension: SCARY/N2913 iterator compatibility between flat_map and flat_multimap
17+
// Test for the absence of this feature
18+
19+
#include <flat_map>
20+
#include <type_traits>
21+
22+
#include "test_macros.h"
23+
24+
void test() {
25+
typedef std::flat_map<int, int> M1;
26+
typedef std::flat_multimap<int, int> M2;
27+
28+
static_assert(!std::is_convertible_v<M1::iterator, M2::iterator>);
29+
static_assert(!std::is_convertible_v<M2::iterator, M1::iterator>);
30+
31+
static_assert(!std::is_convertible_v<M1::const_iterator, M2::const_iterator>);
32+
static_assert(!std::is_convertible_v<M2::const_iterator, M1::const_iterator>);
33+
}

0 commit comments

Comments
 (0)