Skip to content

Commit 3dbebae

Browse files
committed
Fix the test!!!
1 parent f9efc16 commit 3dbebae

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

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

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <cassert>
1616
#include <string>
1717

18-
#include "asan_testing.h"
1918
#include "constexpr_char_traits.h"
2019
#include "make_string.h"
2120
#include "min_allocator.h"
@@ -28,11 +27,30 @@ template <typename CharT, typename TraitsT, typename AllocT>
2827
constexpr void test() {
2928
std::basic_string<CharT, TraitsT, AllocT> s{CS("Hello cruel world!"), AllocT{}};
3029

31-
std::same_as<std::basic_string_view<CharT, TraitsT>> decltype(auto) sv = s.subview(6);
32-
assert(sv == CS("cruel world!"));
30+
{ // With a default position and a character length.
31+
std::same_as<std::basic_string_view<CharT, TraitsT>> decltype(auto) sv = s.subview();
32+
assert(sv == CS("Hello cruel world!"));
33+
}
3334

34-
std::same_as<std::basic_string_view<CharT, TraitsT>> decltype(auto) subsv = sv.subview(0, 5);
35-
assert(subsv == CS("cruel"));
35+
{ // With a explict position and a character length.
36+
std::same_as<std::basic_string_view<CharT, TraitsT>> decltype(auto) sv = s.subview(6, 5);
37+
assert(sv == CS("cruel"));
38+
}
39+
40+
{ // From the beginning of the string with a explicit character length.
41+
std::same_as<std::basic_string_view<CharT, TraitsT>> decltype(auto) sv = s.subview(0, 5);
42+
assert(sv == CS("Hello"));
43+
}
44+
45+
{ // To the end of string with the default character length.
46+
std::same_as<std::basic_string_view<CharT, TraitsT>> decltype(auto) sv = s.subview(12);
47+
assert(sv == CS("world!"));
48+
}
49+
50+
{ // From the beginning to the end of the string with explicit values.
51+
std::same_as<std::basic_string_view<CharT, TraitsT>> decltype(auto) sv = s.subview(0, s.size());
52+
assert(sv == CS("Hello cruel world!"));
53+
}
3654
}
3755

3856
template <typename CharT>

0 commit comments

Comments
 (0)