Skip to content

Commit 21b948f

Browse files
committed
Shorten test
1 parent 5c44d08 commit 21b948f

File tree

1 file changed

+39
-54
lines changed

1 file changed

+39
-54
lines changed

libcxx/test/libcxx/diagnostics/array.nodiscard.verify.cpp

Lines changed: 39 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -15,72 +15,57 @@
1515

1616
#include <test_macros.h>
1717

18-
template <std::size_t N>
18+
template <typename ArrT>
1919
void test_members() {
20-
std::array<int, N> a;
21-
const std::array<int, N> ca{};
20+
ArrT a{};
2221

23-
a.begin(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
24-
ca.begin(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
25-
a.end(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
26-
ca.end(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
27-
a.rbegin(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
28-
ca.rbegin(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
29-
a.rend(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
30-
ca.rend(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
31-
a.cbegin(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
32-
ca.cbegin(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
33-
a.cend(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
34-
ca.cend(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
35-
a.crbegin(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
36-
ca.crbegin(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
37-
a.crend(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
38-
ca.crend(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
22+
a.begin(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
23+
a.end(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
24+
a.rbegin(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
25+
a.rend(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
26+
a.cbegin(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
27+
a.cend(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
28+
a.crbegin(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
29+
a.crend(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
3930

40-
a.size(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
41-
a.max_size(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
42-
a.empty(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
31+
a.size(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
32+
a.max_size(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
33+
a.empty(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
4334

44-
a[0]; // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
45-
ca[0]; // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
46-
a.at(0); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
47-
ca.at(0); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
35+
a[0]; // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
36+
a.at(0); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
4837

49-
a.front(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
50-
ca.front(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
51-
a.back(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
52-
ca.back(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
38+
a.front(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
39+
a.back(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
5340

54-
a.data(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
55-
ca.data(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
41+
a.data(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
5642
}
5743

58-
void test_nonmembers() {
59-
{
60-
std::array<int, 1> a;
61-
const std::array<int, 1> ca{};
44+
template <typename ArrT>
45+
void test_get() {
46+
ArrT a{};
6247

63-
// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
64-
std::get<0>(a);
65-
// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
66-
std::get<0>(ca);
67-
// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
68-
std::get<0>(std::move(a));
69-
// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
70-
std::get<0>(std::move(ca));
71-
}
48+
// expected-warning@+1 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
49+
std::get<0>(a);
50+
// expected-warning@+1 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
51+
std::get<0>(std::move(a));
52+
}
7253

73-
{
7454
#if TEST_STD_VER >= 20
75-
// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
76-
std::to_array("zmt");
77-
// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
78-
std::to_array({94, 82, 49});
79-
#endif
80-
}
55+
void test_to_array() {
56+
// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
57+
std::to_array("zmt");
58+
// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
59+
std::to_array({94, 82, 49});
8160
}
61+
#endif
8262

8363
void test() {
84-
test_members<0>();
85-
test_members<82>();
64+
test_members<std::array<int, 82>>();
65+
test_members<const std::array<int, 82>>();
66+
test_members<std::array<int, 0>>();
67+
test_members<const std::array<int, 0>>();
68+
69+
test_get<std::array<int, 82>>();
70+
test_get<const std::array<int, 82>>();
8671
}

0 commit comments

Comments
 (0)