1053d81ceSMarshall Clow //===----------------------------------------------------------------------===//
2053d81ceSMarshall Clow //
3053d81ceSMarshall Clow //                     The LLVM Compiler Infrastructure
4053d81ceSMarshall Clow //
5053d81ceSMarshall Clow // This file is dual licensed under the MIT and the University of Illinois Open
6053d81ceSMarshall Clow // Source Licenses. See LICENSE.TXT for details.
7053d81ceSMarshall Clow //
8053d81ceSMarshall Clow //===----------------------------------------------------------------------===//
9053d81ceSMarshall Clow 
10053d81ceSMarshall Clow 
11053d81ceSMarshall Clow // <string_view>
12053d81ceSMarshall Clow 
13053d81ceSMarshall Clow // constexpr const _CharT* data() const noexcept;
14053d81ceSMarshall Clow 
15053d81ceSMarshall Clow #include <string_view>
16053d81ceSMarshall Clow #include <cassert>
17053d81ceSMarshall Clow 
18053d81ceSMarshall Clow #include "test_macros.h"
19053d81ceSMarshall Clow 
20053d81ceSMarshall Clow template <typename CharT>
21053d81ceSMarshall Clow void test ( const CharT *s, size_t len ) {
22053d81ceSMarshall Clow     std::basic_string_view<CharT> sv ( s, len );
23053d81ceSMarshall Clow     assert ( sv.length() == len );
24053d81ceSMarshall Clow     assert ( sv.data() == s );
25*aafb3151SMarshall Clow #if TEST_STD_VER > 14
26*aafb3151SMarshall Clow //  make sure we pick up std::data, too!
27*aafb3151SMarshall Clow     assert ( sv.data() == std::data(sv));
28*aafb3151SMarshall Clow #endif
29053d81ceSMarshall Clow     }
30053d81ceSMarshall Clow 
31053d81ceSMarshall Clow int main () {
32053d81ceSMarshall Clow     test ( "ABCDE", 5 );
33053d81ceSMarshall Clow     test ( "a", 1 );
34053d81ceSMarshall Clow 
35053d81ceSMarshall Clow     test ( L"ABCDE", 5 );
36053d81ceSMarshall Clow     test ( L"a", 1 );
37053d81ceSMarshall Clow 
38053d81ceSMarshall Clow #if TEST_STD_VER >= 11
39053d81ceSMarshall Clow     test ( u"ABCDE", 5 );
40053d81ceSMarshall Clow     test ( u"a", 1 );
41053d81ceSMarshall Clow 
42053d81ceSMarshall Clow     test ( U"ABCDE", 5 );
43053d81ceSMarshall Clow     test ( U"a", 1 );
44053d81ceSMarshall Clow #endif
45053d81ceSMarshall Clow 
460f901c7eSStephan T. Lavavej #if TEST_STD_VER > 11
47053d81ceSMarshall Clow     {
48053d81ceSMarshall Clow     constexpr const char *s = "ABC";
49053d81ceSMarshall Clow     constexpr std::basic_string_view<char> sv( s, 2 );
50053d81ceSMarshall Clow     static_assert( sv.length() ==  2,  "" );
51053d81ceSMarshall Clow     static_assert( sv.data() == s, "" );
52053d81ceSMarshall Clow     }
53053d81ceSMarshall Clow #endif
54053d81ceSMarshall Clow }
55