blob: 7b2350923bb6cbcb0ef31cb248cf3ab55d70d76a [file] [log] [blame]
Marshall Clow053d81c2016-07-21 05:31:24 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10
11// <string_view>
12
13// constexpr const _CharT* data() const noexcept;
14
15#include <string_view>
16#include <cassert>
17
18#include "test_macros.h"
19
20template <typename CharT>
21void test ( const CharT *s, size_t len ) {
22 std::basic_string_view<CharT> sv ( s, len );
23 assert ( sv.length() == len );
24 assert ( sv.data() == s );
25 }
26
27int main () {
28 test ( "ABCDE", 5 );
29 test ( "a", 1 );
30
31 test ( L"ABCDE", 5 );
32 test ( L"a", 1 );
33
34#if TEST_STD_VER >= 11
35 test ( u"ABCDE", 5 );
36 test ( u"a", 1 );
37
38 test ( U"ABCDE", 5 );
39 test ( U"a", 1 );
40#endif
41
Stephan T. Lavavej0f901c72016-11-04 20:26:59 +000042#if TEST_STD_VER > 11
Marshall Clow053d81c2016-07-21 05:31:24 +000043 {
44 constexpr const char *s = "ABC";
45 constexpr std::basic_string_view<char> sv( s, 2 );
46 static_assert( sv.length() == 2, "" );
47 static_assert( sv.data() == s, "" );
48 }
49#endif
50}