[VPlan] Add and use debug location for VPScalarCastRecipe.
[llvm-project.git] / libcxx / test / std / strings / string.view / string.view.cons / from_ptr_len.pass.cpp
blobe59e2b2da067743acfef39c63002df65afc25baf
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: !stdlib=libc++ && (c++03 || c++11 || c++14)
11 // <string_view>
13 // constexpr basic_string_view(const _CharT* _s, size_type _len)
14 // : __data (_s), __size(_len) {}
16 #include <string_view>
17 #include <string>
18 #include <cassert>
20 #include "test_macros.h"
22 template <typename CharT>
23 void test(const CharT* s, std::size_t sz) {
25 typedef std::basic_string_view<CharT> SV;
26 LIBCPP_ASSERT_NOEXCEPT(SV(s, sz));
28 SV sv1(s, sz);
29 assert(sv1.size() == sz);
30 assert(sv1.data() == s);
34 int main(int, char**) {
35 test("QBCDE", 5);
36 test("QBCDE", 2);
37 test("", 0);
38 #if TEST_STD_VER > 11
40 constexpr const char* s = "QBCDE";
41 constexpr std::basic_string_view<char> sv1(s, 2);
42 static_assert(sv1.size() == 2, "");
43 static_assert(sv1.data() == s, "");
45 #endif
47 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
48 test(L"QBCDE", 5);
49 test(L"QBCDE", 2);
50 test(L"", 0);
51 # if TEST_STD_VER > 11
53 constexpr const wchar_t* s = L"QBCDE";
54 constexpr std::basic_string_view<wchar_t> sv1(s, 2);
55 static_assert(sv1.size() == 2, "");
56 static_assert(sv1.data() == s, "");
58 # endif
59 #endif // TEST_HAS_NO_WIDE_CHARACTERS
61 #if TEST_STD_VER >= 11
62 test(u"QBCDE", 5);
63 test(u"QBCDE", 2);
64 test(u"", 0);
65 # if TEST_STD_VER > 11
67 constexpr const char16_t* s = u"QBCDE";
68 constexpr std::basic_string_view<char16_t> sv1(s, 2);
69 static_assert(sv1.size() == 2, "");
70 static_assert(sv1.data() == s, "");
72 # endif
74 test(U"QBCDE", 5);
75 test(U"QBCDE", 2);
76 test(U"", 0);
77 # if TEST_STD_VER > 11
79 constexpr const char32_t* s = U"QBCDE";
80 constexpr std::basic_string_view<char32_t> sv1(s, 2);
81 static_assert(sv1.size() == 2, "");
82 static_assert(sv1.data() == s, "");
84 # endif
85 #endif
87 return 0;