Skip to content

Commit 2908eb2

Browse files
committed
[libc++] Split off debug tests that were missed by ce1365f into test/libcxx
Also, some tests had multiple death tests in them, so split them into separate tests instead. The second death test would obviously never get run, because the first one would kill the program before.
1 parent f85bcc2 commit 2908eb2

File tree

114 files changed

+1646
-894
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+1646
-894
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
// <unordered_map>
10+
11+
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
12+
// class Alloc = allocator<pair<const Key, T>>>
13+
// class unordered_map
14+
15+
// size_type bucket_size(size_type n) const
16+
17+
// UNSUPPORTED: libcxx-no-debug-mode
18+
19+
#define _LIBCPP_DEBUG 1
20+
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
21+
22+
#include <unordered_map>
23+
#include <string>
24+
#include <cassert>
25+
26+
#include "test_macros.h"
27+
28+
int main(int, char**) {
29+
typedef std::unordered_map<int, std::string> C;
30+
C c;
31+
(void) c.bucket_size(3);
32+
assert(false);
33+
34+
return 0;
35+
}

libcxx/test/libcxx/containers/unord/unord.map/db_bucket.pass.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,11 @@
2121

2222
#include "test_macros.h"
2323

24-
int main(int, char**)
25-
{
26-
{
27-
typedef std::unordered_map<int, std::string> C;
28-
C c;
29-
(void) c.bucket(3);
30-
assert(false);
31-
}
24+
int main(int, char**) {
25+
typedef std::unordered_map<int, std::string> C;
26+
C c;
27+
(void) c.bucket(3);
28+
assert(false);
3229

3330
return 0;
3431
}

libcxx/test/libcxx/containers/unord/unord.map/db_insert_hint_const_lvalue.pass.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,16 @@
2020

2121
#include "test_macros.h"
2222

23-
int main(int, char**)
24-
{
25-
{
26-
typedef std::unordered_map<double, int> C;
27-
typedef C::iterator R;
28-
typedef C::value_type P;
29-
C c;
30-
C c2;
31-
C::const_iterator e = c2.end();
32-
P v(3.5, 3);
33-
R r = c.insert(e, v);
34-
assert(false);
35-
}
23+
int main(int, char**) {
24+
typedef std::unordered_map<double, int> C;
25+
typedef C::iterator R;
26+
typedef C::value_type P;
27+
C c;
28+
C c2;
29+
C::const_iterator e = c2.end();
30+
P v(3.5, 3);
31+
R r = c.insert(e, v);
32+
assert(false);
3633

3734
return 0;
3835
}

libcxx/test/libcxx/containers/unord/unord.map/db_insert_hint_rvalue.pass.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,15 @@
2424

2525
#include "test_macros.h"
2626

27-
int main(int, char**)
28-
{
29-
{
30-
typedef std::unordered_map<double, int> C;
31-
typedef C::iterator R;
32-
typedef C::value_type P;
33-
C c;
34-
C c2;
35-
C::const_iterator e = c2.end();
36-
R r = c.insert(e, P(3.5, 3));
37-
assert(false);
38-
}
27+
int main(int, char**) {
28+
typedef std::unordered_map<double, int> C;
29+
typedef C::iterator R;
30+
typedef C::value_type P;
31+
C c;
32+
C c2;
33+
C::const_iterator e = c2.end();
34+
R r = c.insert(e, P(3.5, 3));
35+
assert(false);
3936

4037
return 0;
4138
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
// <unordered_map>
10+
11+
// Dereference non-dereferenceable iterator.
12+
13+
// UNSUPPORTED: libcxx-no-debug-mode
14+
// UNSUPPORTED: c++03
15+
16+
#define _LIBCPP_DEBUG 1
17+
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
18+
19+
#include <unordered_map>
20+
#include <cassert>
21+
#include <functional>
22+
#include <string>
23+
#include <utility>
24+
25+
#include "test_macros.h"
26+
#include "min_allocator.h"
27+
28+
int main(int, char**) {
29+
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
30+
min_allocator<std::pair<const int, std::string>>> C;
31+
C c;
32+
c.insert(std::make_pair(1, "one"));
33+
C::iterator i = c.end();
34+
C::value_type j = *i;
35+
assert(false);
36+
37+
return 0;
38+
}

libcxx/test/libcxx/containers/unord/unord.map/db_iterators_7.pass.cpp

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,13 @@
1616
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
1717

1818
#include <unordered_map>
19-
#include <string>
2019
#include <cassert>
21-
#include <iterator>
22-
#include <exception>
23-
#include <cstdlib>
20+
#include <string>
21+
#include <utility>
2422

2523
#include "test_macros.h"
26-
#include "min_allocator.h"
2724

28-
int main(int, char**)
29-
{
30-
{
25+
int main(int, char**) {
3126
typedef std::unordered_map<int, std::string> C;
3227
C c;
3328
c.insert(std::make_pair(1, "one"));
@@ -36,18 +31,6 @@ int main(int, char**)
3631
assert(i == c.end());
3732
++i;
3833
assert(false);
39-
}
40-
#if TEST_STD_VER >= 11
41-
{
42-
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
43-
min_allocator<std::pair<const int, std::string>>> C;
44-
C c;
45-
c.insert(std::make_pair(1, "one"));
46-
C::iterator i = c.begin();
47-
++i;
48-
assert(i == c.end());
49-
++i;
50-
assert(false);
51-
}
52-
#endif
34+
35+
return 0;
5336
}

libcxx/test/libcxx/containers/unord/unord.map/db_iterators_8.pass.cpp

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,19 @@
1616
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
1717

1818
#include <unordered_map>
19-
#include <string>
2019
#include <cassert>
21-
#include <iterator>
22-
#include <exception>
23-
#include <cstdlib>
20+
#include <string>
21+
#include <utility>
2422

2523
#include "test_macros.h"
26-
#include "min_allocator.h"
2724

28-
int main(int, char**)
29-
{
30-
{
25+
int main(int, char**) {
3126
typedef std::unordered_map<int, std::string> C;
3227
C c;
3328
c.insert(std::make_pair(1, "one"));
3429
C::iterator i = c.end();
3530
C::value_type j = *i;
3631
assert(false);
37-
}
38-
#if TEST_STD_VER >= 11
39-
{
40-
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
41-
min_allocator<std::pair<const int, std::string>>> C;
42-
C c;
43-
c.insert(std::make_pair(1, "one"));
44-
C::iterator i = c.end();
45-
C::value_type j = *i;
46-
assert(false);
47-
}
48-
#endif
32+
33+
return 0;
4934
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
// <unordered_map>
10+
11+
// Increment iterator past end.
12+
13+
// UNSUPPORTED: libcxx-no-debug-mode
14+
// UNSUPPORTED: c++03
15+
16+
#define _LIBCPP_DEBUG 1
17+
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
18+
19+
#include <unordered_map>
20+
#include <cassert>
21+
#include <functional>
22+
#include <string>
23+
#include <utility>
24+
25+
#include "test_macros.h"
26+
#include "min_allocator.h"
27+
28+
int main(int, char**) {
29+
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
30+
min_allocator<std::pair<const int, std::string>>> C;
31+
C c;
32+
c.insert(std::make_pair(1, "one"));
33+
C::iterator i = c.begin();
34+
++i;
35+
assert(i == c.end());
36+
++i;
37+
assert(false);
38+
39+
return 0;
40+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
// <unordered_map>
10+
11+
// Dereference non-dereferenceable iterator.
12+
13+
// UNSUPPORTED: libcxx-no-debug-mode
14+
// UNSUPPORTED: c++03
15+
16+
#define _LIBCPP_DEBUG 1
17+
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
18+
19+
#include <unordered_map>
20+
#include <cassert>
21+
#include <functional>
22+
#include <string>
23+
24+
#include "test_macros.h"
25+
#include "min_allocator.h"
26+
27+
int main(int, char**) {
28+
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
29+
min_allocator<std::pair<const int, std::string>>> C;
30+
C c(1);
31+
C::local_iterator i = c.end(0);
32+
C::value_type j = *i;
33+
assert(false);
34+
35+
return 0;
36+
}

libcxx/test/libcxx/containers/unord/unord.map/db_local_iterators_7.pass.cpp

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,16 @@
1818
#include <unordered_map>
1919
#include <string>
2020
#include <cassert>
21-
#include <iterator>
22-
#include <exception>
23-
#include <cstdlib>
2421

2522
#include "test_macros.h"
26-
#include "min_allocator.h"
2723

28-
int main(int, char**)
29-
{
30-
{
24+
int main(int, char**) {
3125
typedef std::unordered_map<int, std::string> C;
3226
C c(1);
3327
C::local_iterator i = c.begin(0);
3428
++i;
3529
++i;
3630
assert(false);
37-
}
38-
#if TEST_STD_VER >= 11
39-
{
40-
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
41-
min_allocator<std::pair<const int, std::string>>> C;
42-
C c(1);
43-
C::local_iterator i = c.begin(0);
44-
++i;
45-
++i;
46-
assert(false);
47-
}
48-
#endif
4931

32+
return 0;
5033
}

libcxx/test/libcxx/containers/unord/unord.map/db_local_iterators_8.pass.cpp

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,15 @@
1818
#include <unordered_map>
1919
#include <string>
2020
#include <cassert>
21-
#include <iterator>
22-
#include <exception>
23-
#include <cstdlib>
2421

2522
#include "test_macros.h"
26-
#include "min_allocator.h"
2723

28-
int main(int, char**)
29-
{
30-
{
24+
int main(int, char**) {
3125
typedef std::unordered_map<int, std::string> C;
3226
C c(1);
3327
C::local_iterator i = c.end(0);
3428
C::value_type j = *i;
3529
assert(false);
36-
}
37-
#if TEST_STD_VER >= 11
38-
{
39-
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
40-
min_allocator<std::pair<const int, std::string>>> C;
41-
C c(1);
42-
C::local_iterator i = c.end(0);
43-
C::value_type j = *i;
44-
assert(false);
45-
}
46-
#endif
30+
31+
return 0;
4732
}

0 commit comments

Comments
 (0)