]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/experimental/string_view/cons/wchar_t/1.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / experimental / string_view / cons / wchar_t / 1.cc
CommitLineData
52066eae 1// { dg-do run { target c++14 } }
77cba5af 2
7adcbafe 3// Copyright (C) 2013-2022 Free Software Foundation, Inc.
77cba5af
ESR
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 3, or (at your option)
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License along
17// with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
19
20// basic_string_view constructors.
21
22#include <experimental/string_view>
23#include <string>
24#include <cwchar>
25#include <testsuite_hooks.h>
26
27void
28test01()
29{
77cba5af
ESR
30 typedef std::experimental::wstring_view::size_type csize_type;
31
32 // basic_string_view()
33 const std::experimental::wstring_view str00{};
34 VERIFY( str00.length() == 0 );
16545743 35 VERIFY( str00.data() == nullptr );
77cba5af
ESR
36
37 // basic_string_view(const char*)
38 const wchar_t str_lit01[] = L"rodeo beach, marin";
39 const std::experimental::wstring_view str01{str_lit01};
40 VERIFY( str01.length() == 18 );
41 VERIFY( str01.data() == str_lit01 );
42 const std::experimental::wstring_view str02{L"baker beach, san francisco"};
43 VERIFY( str02.length() == 26 );
44
45 // basic_string_view(const string_view&)
46 std::experimental::wstring_view str04{str01};
47 VERIFY( str04.length() == str01.length() );
48 VERIFY( str04.data() == str01.data() );
49
50 // basic_string_view(const char* s)
51 csize_type len_lit01 = wcslen(str_lit01);
52 std::experimental::wstring_view str05{str_lit01, len_lit01};
53 VERIFY( str05.length() == len_lit01 );
54 VERIFY( str05.data() == str_lit01 );
32f9be16 55
77cba5af
ESR
56 // basic_string_view(basic_string& s)
57 std::wstring istr07(10, L'z');
58 std::experimental::wstring_view str07{istr07};
59 VERIFY( str07.length() == 10 );
60}
61
62int
63main()
64{
65 test01();
66
67 return 0;
68}