]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/experimental/string_view/literals/values.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / experimental / string_view / literals / values.cc
CommitLineData
be58e01d 1// { dg-do run { target c++14 } }
2fd2d470 2
fbd26352 3// Copyright (C) 2013-2019 Free Software Foundation, Inc.
2fd2d470 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#include <experimental/string_view>
21#include <testsuite_hooks.h>
22
23void
24test01()
25{
26 using namespace std::experimental::literals::string_view_literals;
27
28 std::experimental::string_view planet = "Mercury"sv;
e6f7df89 29#ifdef _GLIBCXX_USE_WCHAR_T
2fd2d470 30 std::experimental::wstring_view wplanet = L"Venus"sv;
e6f7df89 31#endif
2fd2d470 32 std::experimental::string_view u8planet = u8"Mars"sv;
e6f7df89 33 std::experimental::u16string_view u16planet = u"Jupiter"sv;
2fd2d470 34 std::experimental::u32string_view u32planet = U"Saturn"sv;
35
36 VERIFY( planet == std::experimental::string_view("Mercury") );
e6f7df89 37#ifdef _GLIBCXX_USE_WCHAR_T
2fd2d470 38 VERIFY( wplanet == std::experimental::wstring_view(L"Venus") );
e6f7df89 39#endif
2fd2d470 40 VERIFY( u8planet == std::experimental::string_view(u8"Mars") );
e6f7df89 41 VERIFY( u16planet == std::experimental::u16string_view(u"Jupiter") );
2fd2d470 42 VERIFY( u32planet == std::experimental::u32string_view(U"Saturn") );
43}
44
8503094a 45void
46test02()
47{
48 using namespace std::experimental::literals::string_view_literals;
49
50 std::experimental::string_view planet_cratered = "Mercury\0cratered"sv;
51#ifdef _GLIBCXX_USE_WCHAR_T
52 std::experimental::wstring_view wplanet_cratered = L"Venus\0cratered"sv;
53#endif
54 std::experimental::string_view u8planet_cratered = u8"Mars\0cratered"sv;
55 std::experimental::u16string_view u16planet_cratered = u"Jupiter\0cratered"sv;
56 std::experimental::u32string_view u32planet_cratered = U"Saturn\0cratered"sv;
57
58 VERIFY( planet_cratered ==
59 std::experimental::string_view("Mercury\0cratered", 16) );
60#ifdef _GLIBCXX_USE_WCHAR_T
61 VERIFY( wplanet_cratered ==
62 std::experimental::wstring_view(L"Venus\0cratered", 14) );
63#endif
64 VERIFY( u8planet_cratered ==
65 std::experimental::string_view(u8"Mars\0cratered", 13) );
66 VERIFY( u16planet_cratered ==
67 std::experimental::u16string_view(u"Jupiter\0cratered", 16) );
68 VERIFY( u32planet_cratered ==
69 std::experimental::u32string_view(U"Saturn\0cratered", 15) );
70}
71
2fd2d470 72int
73main()
74{
75 test01();
8503094a 76 test02();
2fd2d470 77}