Skip to content

Commit a7b1544

Browse files
committed
Fix tests
1 parent a553bc5 commit a7b1544

File tree

4 files changed

+26
-46
lines changed

4 files changed

+26
-46
lines changed

libcxx/test/std/strings/basic.string/string.ops/string_substr/nodiscard.verify.cpp

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,17 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// #include <allocator>
10-
#include <string>
9+
// REQUIRES: std-at-least-c++26
1110

12-
#include "constexpr_char_traits.h"
13-
#include "test_macros.h"
14-
#include "type_algorithms.h"
11+
// <string>
1512

16-
template <typename CharT, typename TraitsT, typename AllocT>
17-
constexpr void test() {
18-
#if TEST_STD_VER >= 26
19-
std::basic_string<CharT, TraitsT, AllocT> s;
13+
// constexpr basic_string_view<charT, traits> subview(size_type pos = 0,
14+
// size_type n = npos) const;
2015

21-
s.subview(); // expected-warning {{ignoring return value of function}}
22-
#endif
23-
}
16+
#include <string>
2417

25-
class Test {
26-
public:
27-
template <typename CharT>
28-
constexpr void operator()() const {
29-
test<CharT, std::char_traits<CharT>, std::allocator<CharT>>();
30-
}
31-
};
18+
void test() {
19+
std::string s;
3220

33-
void test() { types::for_each(types::character_types(), Test{}); }
21+
s.subview(); // expected-warning {{ignoring return value of function}}
22+
}

libcxx/test/std/strings/basic.string/string.ops/string_substr/subview.pass.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
// <string>
1212

13-
// constexpr basic_string_view<_CharT, _Traits> subview(size_type __pos = 0, size_type __n = npos) const;
13+
// constexpr basic_string_view<charT, traits> subview(size_type pos = 0,
14+
// size_type n = npos) const;
1415

1516
#include <cassert>
1617
#include <concepts>
@@ -61,7 +62,7 @@ constexpr void test() {
6162
if (!std::is_constant_evaluated()) {
6263
{ // With a position that is out of range.
6364
try {
64-
s.subview(s.size() + 1);
65+
std::ignore = s.subview(s.size() + 1);
6566
assert(false);
6667
} catch ([[maybe_unused]] const std::out_of_range& ex) {
6768
LIBCPP_ASSERT(std::string(ex.what()) == "string_view::substr");
@@ -72,7 +73,7 @@ constexpr void test() {
7273

7374
{ // With a position that is out of range and a 0 character length.
7475
try {
75-
s.subview(s.size() + 1, 0);
76+
std::ignore = s.subview(s.size() + 1, 0);
7677
assert(false);
7778
} catch ([[maybe_unused]] const std::out_of_range& ex) {
7879
LIBCPP_ASSERT(std::string(ex.what()) == "string_view::substr");
@@ -83,7 +84,7 @@ constexpr void test() {
8384

8485
{ // With a position that is out of range and a some character length.
8586
try {
86-
s.subview(s.size() + 1, 1);
87+
std::ignore = s.subview(s.size() + 1, 1);
8788
assert(false);
8889
} catch ([[maybe_unused]] const std::out_of_range& ex) {
8990
LIBCPP_ASSERT(std::string(ex.what()) == "string_view::substr");

libcxx/test/std/strings/string.view/string.view.ops/nodiscard.verify.cpp

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,17 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include <string_view>
9+
// REQUIRES: std-at-least-c++26
1010

11-
#include "constexpr_char_traits.h"
12-
#include "test_macros.h"
13-
#include "type_algorithms.h"
11+
// <string>
1412

15-
template <typename CharT, typename TraitsT, typename AllocT>
16-
constexpr void test() {
17-
#if TEST_STD_VER >= 26
18-
std::basic_string_view<CharT, TraitsT> sv;
13+
// constexpr basic_string_view subview(size_type pos = 0,
14+
// size_type n = npos) const; // freestanding-deleted
1915

20-
sv.subview(); // expected-warning {{ignoring return value of function}}
21-
#endif
22-
}
16+
#include <string>
2317

24-
class Test {
25-
public:
26-
template <typename CharT>
27-
constexpr void operator()() const {
28-
test<CharT, std::char_traits<CharT>>();
29-
}
30-
};
18+
void test() {
19+
std::string_view sv;
3120

32-
void test() { types::for_each(types::character_types(), Test{}); }
21+
sv.subview(); // expected-warning {{ignoring return value of function}}
22+
}

libcxx/test/std/strings/string.view/string.view.ops/subview.pass.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ constexpr void test() {
5959
if (!std::is_constant_evaluated()) {
6060
{ // With a position that is out of range.
6161
try {
62-
sv.subview(sv.size() + 1);
62+
std::ignore = sv.subview(sv.size() + 1);
6363
assert(false);
6464
} catch ([[maybe_unused]] const std::out_of_range& ex) {
6565
LIBCPP_ASSERT(std::string(ex.what()) == "string_view::substr");
@@ -70,7 +70,7 @@ constexpr void test() {
7070

7171
{ // With a position that is out of range and a 0 character length.
7272
try {
73-
sv.subview(sv.size() + 1, 0);
73+
std::ignore = sv.subview(sv.size() + 1, 0);
7474
assert(false);
7575
} catch ([[maybe_unused]] const std::out_of_range& ex) {
7676
LIBCPP_ASSERT(std::string(ex.what()) == "string_view::substr");
@@ -81,7 +81,7 @@ constexpr void test() {
8181

8282
{ // With a position that is out of range and a some character length.
8383
try {
84-
sv.subview(sv.size() + 1, 1);
84+
std::ignore = sv.subview(sv.size() + 1, 1);
8585
assert(false);
8686
} catch ([[maybe_unused]] const std::out_of_range& ex) {
8787
LIBCPP_ASSERT(std::string(ex.what()) == "string_view::substr");

0 commit comments

Comments
 (0)