mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-08 20:52:05 +08:00
P0482R5 char8_t: New standard library tests
2019-02-19 Tom Honermann <tom@honermann.net> * testsuite/18_support/numeric_limits/char8_t.cc: New test cloned from char16_32_t.cc; validates numeric_limits<char8_t>. * testsuite/21_strings/basic_string/literals/types-char8_t.cc: New test cloned from types.cc; validates operator""s for char8_t returns u8string. * testsuite/21_strings/basic_string/literals/values-char8_t.cc: New test cloned from values.cc; validates construction and comparison of u8string values. * testsuite/21_strings/basic_string/requirements/ /explicit_instantiation/char8_t/1.cc: New test cloned from char16_t/1.cc; validates explicit instantiation of basic_string<char8_t>. * testsuite/21_strings/basic_string_view/literals/types-char8_t.cc: New test cloned from types.cc; validates operator""sv for char8_t returns u8string_view. * testsuite/21_strings/basic_string_view/literals/ values-char8_t.cc: New test cloned from values.cc; validates construction and comparison of u8string_view values. * testsuite/21_strings/basic_string_view/requirements/ explicit_instantiation/char8_t/1.cc: New test cloned from char16_t/1.cc; validates explicit instantiation of basic_string_view<char8_t>. * testsuite/21_strings/char_traits/requirements/char8_t/65049.cc: New test cloned from char16_t/65049.cc; validates that char_traits<char8_t> is not vulnerable to the concerns in PR65049. * testsuite/21_strings/char_traits/requirements/char8_t/ typedefs.cc: New test cloned from char16_t/typedefs.cc; validates that char_traits<char8_t> member typedefs are present and correct. * testsuite/21_strings/char_traits/requirements/ explicit_instantiation/char8_t/1.cc: New test cloned from char16_t/1.cc; validates explicit instantiation of char_traits<char8_t>. * testsuite/22_locale/codecvt/char16_t-char8_t.cc: New test cloned from char16_t.cc: validates codecvt<char16_t, char8_t, mbstate_t>. * testsuite/22_locale/codecvt/char32_t-char8_t.cc: New test cloned from char32_t.cc: validates codecvt<char32_t, char8_t, mbstate_t>. * testsuite/22_locale/codecvt/utf8-char8_t.cc: New test cloned from utf8.cc; validates codecvt<char16_t, char8_t, std::mbstate_t> and codecvt<char32_t, char8_t, std::mbstate_t>. * testsuite/27_io/filesystem/path/native/string-char8_t.cc: New test cloned from string.cc; validates filesystem::path construction from char8_t input. * testsuite/experimental/feat-char8_t.cc: New test; validates that the __cpp_lib_char8_t feature test macro is defined with the correct value. * testsuite/experimental/filesystem/path/native/string-char8_t.cc: New test cloned from string.cc; validates filesystem::path construction from char8_t input. * testsuite/experimental/string_view/literals/types-char8_t.cc: New test cloned from types.cc; validates operator""sv for char8_t returns u8string_view. * testsuite/experimental/string_view/literals/values-char8_t.cc: New test cloned from values.cc; validates construction and comparison of u8string_view values. * testsuite/experimental/string_view/requirements/ explicit_instantiation/char8_t/1.cc: New test cloned from char16_t/1.cc; validates explicit instantiation of basic_string_view<char8_t>. * testsuite/ext/char8_t/atomic-1.cc: New test; validates that ATOMIC_CHAR8_T_LOCK_FREE is not defined if char8_t support is not enabled. From-SVN: r269005
This commit is contained in:
parent
c124af936b
commit
46ca1dd73c
@ -1,3 +1,69 @@
|
||||
2019-02-19 Tom Honermann <tom@honermann.net>
|
||||
|
||||
* testsuite/18_support/numeric_limits/char8_t.cc: New test cloned
|
||||
from char16_32_t.cc; validates numeric_limits<char8_t>.
|
||||
* testsuite/21_strings/basic_string/literals/types-char8_t.cc: New
|
||||
test cloned from types.cc; validates operator""s for char8_t
|
||||
returns u8string.
|
||||
* testsuite/21_strings/basic_string/literals/values-char8_t.cc: New
|
||||
test cloned from values.cc; validates construction and comparison
|
||||
of u8string values.
|
||||
* testsuite/21_strings/basic_string/requirements/
|
||||
/explicit_instantiation/char8_t/1.cc: New test cloned from
|
||||
char16_t/1.cc; validates explicit instantiation of
|
||||
basic_string<char8_t>.
|
||||
* testsuite/21_strings/basic_string_view/literals/types-char8_t.cc:
|
||||
New test cloned from types.cc; validates operator""sv for char8_t
|
||||
returns u8string_view.
|
||||
* testsuite/21_strings/basic_string_view/literals/
|
||||
values-char8_t.cc: New test cloned from values.cc; validates
|
||||
construction and comparison of u8string_view values.
|
||||
* testsuite/21_strings/basic_string_view/requirements/
|
||||
explicit_instantiation/char8_t/1.cc: New test cloned from
|
||||
char16_t/1.cc; validates explicit instantiation of
|
||||
basic_string_view<char8_t>.
|
||||
* testsuite/21_strings/char_traits/requirements/char8_t/65049.cc:
|
||||
New test cloned from char16_t/65049.cc; validates that
|
||||
char_traits<char8_t> is not vulnerable to the concerns in PR65049.
|
||||
* testsuite/21_strings/char_traits/requirements/char8_t/
|
||||
typedefs.cc: New test cloned from char16_t/typedefs.cc; validates
|
||||
that char_traits<char8_t> member typedefs are present and correct.
|
||||
* testsuite/21_strings/char_traits/requirements/
|
||||
explicit_instantiation/char8_t/1.cc: New test cloned from
|
||||
char16_t/1.cc; validates explicit instantiation of
|
||||
char_traits<char8_t>.
|
||||
* testsuite/22_locale/codecvt/char16_t-char8_t.cc: New test cloned
|
||||
from char16_t.cc: validates
|
||||
codecvt<char16_t, char8_t, mbstate_t>.
|
||||
* testsuite/22_locale/codecvt/char32_t-char8_t.cc: New test cloned
|
||||
from char32_t.cc: validates
|
||||
codecvt<char32_t, char8_t, mbstate_t>.
|
||||
* testsuite/22_locale/codecvt/utf8-char8_t.cc: New test cloned from
|
||||
utf8.cc; validates codecvt<char16_t, char8_t, std::mbstate_t> and
|
||||
codecvt<char32_t, char8_t, std::mbstate_t>.
|
||||
* testsuite/27_io/filesystem/path/native/string-char8_t.cc: New
|
||||
test cloned from string.cc; validates filesystem::path construction
|
||||
from char8_t input.
|
||||
* testsuite/experimental/feat-char8_t.cc: New test; validates that
|
||||
the __cpp_lib_char8_t feature test macro is defined with the
|
||||
correct value.
|
||||
* testsuite/experimental/filesystem/path/native/string-char8_t.cc:
|
||||
New test cloned from string.cc; validates filesystem::path
|
||||
construction from char8_t input.
|
||||
* testsuite/experimental/string_view/literals/types-char8_t.cc: New
|
||||
test cloned from types.cc; validates operator""sv for char8_t
|
||||
returns u8string_view.
|
||||
* testsuite/experimental/string_view/literals/values-char8_t.cc:
|
||||
New test cloned from values.cc; validates construction and
|
||||
comparison of u8string_view values.
|
||||
* testsuite/experimental/string_view/requirements/
|
||||
explicit_instantiation/char8_t/1.cc: New test cloned from
|
||||
char16_t/1.cc; validates explicit instantiation of
|
||||
basic_string_view<char8_t>.
|
||||
* testsuite/ext/char8_t/atomic-1.cc: New test; validates that
|
||||
ATOMIC_CHAR8_T_LOCK_FREE is not defined if char8_t support is not
|
||||
enabled.
|
||||
|
||||
2019-02-19 Tom Honermann <tom@honermann.net>
|
||||
|
||||
P0482R5 char8_t: Standard library support
|
||||
|
71
libstdc++-v3/testsuite/18_support/numeric_limits/char8_t.cc
Normal file
71
libstdc++-v3/testsuite/18_support/numeric_limits/char8_t.cc
Normal file
@ -0,0 +1,71 @@
|
||||
// { dg-do run { target c++11 } }
|
||||
// { dg-require-cstdint "" }
|
||||
// { dg-options "-fchar8_t" }
|
||||
|
||||
// Copyright (C) 2017 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <limits>
|
||||
#include <cstdint>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// Test specializations for char8_t.
|
||||
template<typename T, typename R>
|
||||
void
|
||||
do_test()
|
||||
{
|
||||
typedef std::numeric_limits<T> char_type;
|
||||
typedef std::numeric_limits<R> impl_type;
|
||||
|
||||
VERIFY( char_type::is_specialized == impl_type::is_specialized );
|
||||
VERIFY( char_type::min() == impl_type::min() );
|
||||
VERIFY( char_type::max() == impl_type::max() );
|
||||
VERIFY( char_type::digits == impl_type::digits );
|
||||
VERIFY( char_type::digits10 == impl_type::digits10 );
|
||||
VERIFY( char_type::is_signed == impl_type::is_signed );
|
||||
VERIFY( char_type::is_integer == impl_type::is_integer );
|
||||
VERIFY( char_type::is_exact == impl_type::is_exact );
|
||||
VERIFY( char_type::radix == impl_type::radix );
|
||||
VERIFY( char_type::epsilon() == impl_type::epsilon() );
|
||||
VERIFY( char_type::round_error() == impl_type::round_error() );
|
||||
VERIFY( char_type::min_exponent == impl_type::min_exponent );
|
||||
VERIFY( char_type::min_exponent10 == impl_type::min_exponent10 );
|
||||
VERIFY( char_type::max_exponent == impl_type::max_exponent );
|
||||
VERIFY( char_type::max_exponent10 == impl_type::max_exponent10 );
|
||||
VERIFY( char_type::has_infinity == impl_type::has_infinity );
|
||||
VERIFY( char_type::has_quiet_NaN == impl_type::has_quiet_NaN );
|
||||
VERIFY( char_type::has_signaling_NaN == impl_type::has_signaling_NaN );
|
||||
VERIFY( char_type::has_denorm == impl_type::has_denorm );
|
||||
VERIFY( char_type::has_denorm_loss == impl_type::has_denorm_loss );
|
||||
VERIFY( char_type::infinity() == impl_type::infinity() );
|
||||
VERIFY( char_type::quiet_NaN() == impl_type::quiet_NaN() );
|
||||
VERIFY( char_type::signaling_NaN() == impl_type::signaling_NaN() );
|
||||
VERIFY( char_type::denorm_min() == impl_type::denorm_min() );
|
||||
VERIFY( char_type::is_iec559 == impl_type::is_iec559 );
|
||||
VERIFY( char_type::is_bounded == impl_type::is_bounded );
|
||||
VERIFY( char_type::is_modulo == impl_type::is_modulo );
|
||||
VERIFY( char_type::traps == impl_type::traps );
|
||||
VERIFY( char_type::tinyness_before == impl_type::tinyness_before );
|
||||
VERIFY( char_type::round_style == impl_type::round_style );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
do_test<char8_t, unsigned char>();
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
// { dg-do compile { target c++14 } }
|
||||
// { dg-options "-fchar8_t" }
|
||||
|
||||
// Copyright (C) 2013-2017 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
void
|
||||
test01()
|
||||
{
|
||||
using namespace std::literals::string_literals;
|
||||
|
||||
static_assert(std::is_same<decltype("Hello"s), std::string>::value,
|
||||
"\"Hello\"s is std::string");
|
||||
|
||||
#ifdef _GLIBCXX_USE_CHAR8_T
|
||||
static_assert(std::is_same<decltype(u8"Hello"s), std::u8string>::value,
|
||||
"u8\"Hello\"s is std::u8string");
|
||||
#else
|
||||
static_assert(std::is_same<decltype(u8"Hello"s), std::string>::value,
|
||||
"u8\"Hello\"s is std::string");
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
||||
static_assert(std::is_same<decltype(L"Hello"s), std::wstring>::value,
|
||||
"L\"Hello\"s is std::wstring");
|
||||
#endif
|
||||
|
||||
static_assert(std::is_same<decltype(u"Hello"s), std::u16string>::value,
|
||||
"u\"Hello\"s is std::u16string");
|
||||
|
||||
static_assert(std::is_same<decltype(U"Hello"s), std::u32string>::value,
|
||||
"U\"Hello\"s is std::u32string");
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
// { dg-do run { target c++14 } }
|
||||
// { dg-options "-fchar8_t" }
|
||||
|
||||
// Copyright (C) 2013-2017 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <string>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
void
|
||||
test01()
|
||||
{
|
||||
using namespace std::literals::string_literals;
|
||||
|
||||
std::string planet = "Mercury"s;
|
||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
||||
std::wstring wplanet = L"Venus"s;
|
||||
#endif
|
||||
#ifdef _GLIBCXX_USE_CHAR8_T
|
||||
std::u8string u8planet = u8"Mars"s;
|
||||
#else
|
||||
std::string u8planet = u8"Mars"s;
|
||||
#endif
|
||||
std::u16string u16planet = u"Jupiter"s;
|
||||
std::u32string u32planet = U"Saturn"s;
|
||||
|
||||
VERIFY( planet == std::string("Mercury") );
|
||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
||||
VERIFY( wplanet == std::wstring(L"Venus") );
|
||||
#endif
|
||||
#ifdef _GLIBCXX_USE_CHAR8_T
|
||||
VERIFY( u8planet == std::u8string(u8"Mars") );
|
||||
#else
|
||||
VERIFY( u8planet == std::string(u8"Mars") );
|
||||
#endif
|
||||
VERIFY( u16planet == std::u16string(u"Jupiter") );
|
||||
VERIFY( u32planet == std::u32string(U"Saturn") );
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
// { dg-do compile { target c++11 } }
|
||||
// { dg-options "-fchar8_t" }
|
||||
|
||||
// Copyright (C) 2008-2017 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <string>
|
||||
|
||||
template class std::basic_string<char8_t>;
|
@ -0,0 +1,50 @@
|
||||
// { dg-options "-std=gnu++17 -fchar8_t" }
|
||||
// { dg-do compile }
|
||||
|
||||
// Copyright (C) 2013-2017 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
|
||||
void
|
||||
test01()
|
||||
{
|
||||
using namespace std::literals::string_view_literals;
|
||||
|
||||
static_assert(std::is_same<decltype("Hello"sv), std::string_view>::value,
|
||||
"\"Hello\"sv is std::string_view");
|
||||
|
||||
#ifdef _GLIBCXX_USE_CHAR8_T
|
||||
static_assert(std::is_same<decltype(u8"Hello"sv), std::u8string_view>::value,
|
||||
"u8\"Hello\"sv is std::u8string_view");
|
||||
#else
|
||||
static_assert(std::is_same<decltype(u8"Hello"sv), std::string_view>::value,
|
||||
"u8\"Hello\"sv is std::string_view");
|
||||
#endif
|
||||
|
||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
||||
static_assert(std::is_same<decltype(L"Hello"sv), std::wstring_view>::value,
|
||||
"L\"Hello\"sv is std::wstring_view");
|
||||
#endif
|
||||
|
||||
static_assert(std::is_same<decltype(u"Hello"sv), std::u16string_view>::value,
|
||||
"u\"Hello\"sv is std::u16string_view");
|
||||
|
||||
static_assert(std::is_same<decltype(U"Hello"sv), std::u32string_view>::value,
|
||||
"U\"Hello\"sv is std::u32string_view");
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
// { dg-options "-std=gnu++17 -fchar8_t" }
|
||||
|
||||
// Copyright (C) 2013-2017 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <string_view>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
void
|
||||
test01()
|
||||
{
|
||||
using namespace std::literals::string_view_literals;
|
||||
|
||||
std::string_view planet = "Mercury"sv;
|
||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
||||
std::wstring_view wplanet = L"Venus"sv;
|
||||
#endif
|
||||
#ifdef _GLIBCXX_USE_CHAR8_T
|
||||
std::u8string_view u8planet = u8"Mars"sv;
|
||||
#else
|
||||
std::string_view u8planet = u8"Mars"sv;
|
||||
#endif
|
||||
std::u16string_view u16planet = u"Jupiter"sv;
|
||||
std::u32string_view u32planet = U"Saturn"sv;
|
||||
|
||||
VERIFY( planet == std::string_view("Mercury") );
|
||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
||||
VERIFY( wplanet == std::wstring_view(L"Venus") );
|
||||
#endif
|
||||
#ifdef _GLIBCXX_USE_CHAR8_T
|
||||
VERIFY( u8planet == std::u8string_view(u8"Mars") );
|
||||
#else
|
||||
VERIFY( u8planet == std::string_view(u8"Mars") );
|
||||
#endif
|
||||
VERIFY( u16planet == std::u16string_view(u"Jupiter") );
|
||||
VERIFY( u32planet == std::u32string_view(U"Saturn") );
|
||||
}
|
||||
|
||||
void
|
||||
test02()
|
||||
{
|
||||
using namespace std::literals::string_view_literals;
|
||||
|
||||
std::string_view planet_cratered = "Mercury\0cratered"sv;
|
||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
||||
std::wstring_view wplanet_cratered = L"Venus\0cratered"sv;
|
||||
#endif
|
||||
#ifdef _GLIBCXX_USE_CHAR8_T
|
||||
std::u8string_view u8planet_cratered = u8"Mars\0cratered"sv;
|
||||
#else
|
||||
std::string_view u8planet_cratered = u8"Mars\0cratered"sv;
|
||||
#endif
|
||||
std::u16string_view u16planet_cratered = u"Jupiter\0cratered"sv;
|
||||
std::u32string_view u32planet_cratered = U"Saturn\0cratered"sv;
|
||||
|
||||
VERIFY( planet_cratered == std::string_view("Mercury\0cratered", 16) );
|
||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
||||
VERIFY( wplanet_cratered == std::wstring_view(L"Venus\0cratered", 14) );
|
||||
#endif
|
||||
#ifdef _GLIBCXX_USE_CHAR8_T
|
||||
VERIFY( u8planet_cratered == std::u8string_view(u8"Mars\0cratered", 13) );
|
||||
#else
|
||||
VERIFY( u8planet_cratered == std::string_view(u8"Mars\0cratered", 13) );
|
||||
#endif
|
||||
VERIFY( u16planet_cratered == std::u16string_view(u"Jupiter\0cratered", 16) );
|
||||
VERIFY( u32planet_cratered == std::u32string_view(U"Saturn\0cratered", 15) );
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++17 -fchar8_t" }
|
||||
|
||||
// Copyright (C) 2013-2017 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <string_view>
|
||||
|
||||
template class std::basic_string_view<char8_t>;
|
@ -0,0 +1,49 @@
|
||||
// Copyright (C) 2015-2017 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do run { target c++11 } }
|
||||
// { dg-options "-fchar8_t" }
|
||||
|
||||
// libstdc++/65049
|
||||
|
||||
#include <string>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
using C = char8_t;
|
||||
|
||||
void
|
||||
test01()
|
||||
{
|
||||
const C* p = 0;
|
||||
C* q = 0;
|
||||
auto c = std::char_traits<C>::compare(p, q, 0);
|
||||
VERIFY( c == 0 );
|
||||
auto r = std::char_traits<C>::find(p, 0, '0');
|
||||
VERIFY( r == nullptr );
|
||||
r = std::char_traits<C>::move(q, p, 0);
|
||||
VERIFY( r == q );
|
||||
r = std::char_traits<C>::copy(q, p, 0);
|
||||
VERIFY( r == q );
|
||||
r = std::char_traits<C>::assign(q, 0, '0');
|
||||
VERIFY( r == q );
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
// { dg-do compile { target c++11 } }
|
||||
// { dg-options "-fchar8_t" }
|
||||
|
||||
// Copyright (C) 2008-2017 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <string>
|
||||
|
||||
int main()
|
||||
{
|
||||
// Check for required typedefs.
|
||||
typedef std::char_traits<char8_t> test_type;
|
||||
typedef test_type::char_type char_type;
|
||||
typedef test_type::int_type int_type;
|
||||
typedef test_type::off_type off_type;
|
||||
typedef test_type::pos_type pos_type;
|
||||
typedef test_type::state_type state_type;
|
||||
|
||||
// char_traits<char8_t>::int_type == unsigned int
|
||||
test_type::int_type* p = 0;
|
||||
unsigned int* q __attribute__((unused)) = p;
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
// { dg-do compile { target c++11 } }
|
||||
// { dg-options "-fchar8_t" }
|
||||
|
||||
// Copyright (C) 2008-2017 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <string>
|
||||
|
||||
template class std::char_traits<char8_t>;
|
98
libstdc++-v3/testsuite/22_locale/codecvt/char16_t-char8_t.cc
Normal file
98
libstdc++-v3/testsuite/22_locale/codecvt/char16_t-char8_t.cc
Normal file
@ -0,0 +1,98 @@
|
||||
// Copyright (C) 2015-2017 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do run { target c++11 } }
|
||||
// { dg-require-cstdint "" }
|
||||
// { dg-options "-fchar8_t" }
|
||||
|
||||
// [locale.codecvt], C++11 22.4.1.4. specialization.
|
||||
|
||||
#include <locale>
|
||||
#include <cstring>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
void
|
||||
test01()
|
||||
{
|
||||
using namespace std;
|
||||
typedef codecvt<char16_t, char8_t, mbstate_t> codecvt_c16;
|
||||
locale loc_c = locale::classic();
|
||||
VERIFY(has_facet<codecvt_c16>(loc_c));
|
||||
const codecvt_c16* const cvt = &use_facet<codecvt_c16>(loc_c);
|
||||
|
||||
VERIFY(!cvt->always_noconv());
|
||||
VERIFY(cvt->max_length() == 4);
|
||||
VERIFY(cvt->encoding() == 0);
|
||||
|
||||
const char8_t u8dat[] = u8"H\U000000E4ll\U000000F6 \U0001F63F \U000056FD "
|
||||
u8"\U0000222B f(\U000003BA) exp(-2\U000003C0\U000003C9) d\U000003BA "
|
||||
u8"\U0001F6BF \U0001F6BF \U0001F648 \U00000413\U00000435\U0000043E"
|
||||
u8"\U00000433\U00000440\U00000430\U00000444\U00000438\U0000044F \U0000FB05";
|
||||
const char8_t* const u8dat_end = std::end(u8dat);
|
||||
|
||||
const char16_t u16dat[] = u"H\U000000E4ll\U000000F6 \U0001F63F \U000056FD "
|
||||
u"\U0000222B f(\U000003BA) exp(-2\U000003C0\U000003C9) d\U000003BA "
|
||||
u"\U0001F6BF \U0001F6BF \U0001F648 \U00000413\U00000435\U0000043E"
|
||||
u"\U00000433\U00000440\U00000430\U00000444\U00000438\U0000044F \U0000FB05";
|
||||
const char16_t* const u16dat_end = std::end(u16dat);
|
||||
|
||||
{
|
||||
const size_t len = u16dat_end - u16dat + 1;
|
||||
char16_t* const buffer = new char16_t[len];
|
||||
char16_t* const buffer_end = buffer + len;
|
||||
|
||||
const char8_t* from_next;
|
||||
char16_t* to_next;
|
||||
|
||||
codecvt_c16::state_type state01;
|
||||
state01 = {};
|
||||
codecvt_base::result res = cvt->in(state01, u8dat, u8dat_end, from_next,
|
||||
buffer, buffer_end, to_next);
|
||||
|
||||
VERIFY(res == codecvt_base::ok);
|
||||
VERIFY(from_next == u8dat_end);
|
||||
VERIFY(std::memcmp((void*)buffer, (void*)u16dat, sizeof(u16dat)) == 0);
|
||||
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
{
|
||||
const size_t len = u8dat_end - u8dat + 1;
|
||||
char8_t* const buffer = new char8_t[len];
|
||||
char8_t* const buffer_end = buffer + len;
|
||||
|
||||
const char16_t* from_next;
|
||||
char8_t* to_next;
|
||||
|
||||
codecvt_c16::state_type state01;
|
||||
state01 = {};
|
||||
codecvt_base::result res = cvt->out(state01, u16dat, u16dat_end, from_next,
|
||||
buffer, buffer_end, to_next);
|
||||
|
||||
VERIFY(res == codecvt_base::ok);
|
||||
VERIFY(from_next == u16dat_end);
|
||||
VERIFY(std::memcmp((void*)buffer, (void*)u8dat, sizeof(u8dat)) == 0);
|
||||
|
||||
delete[] buffer;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
}
|
100
libstdc++-v3/testsuite/22_locale/codecvt/char32_t-char8_t.cc
Normal file
100
libstdc++-v3/testsuite/22_locale/codecvt/char32_t-char8_t.cc
Normal file
@ -0,0 +1,100 @@
|
||||
// { dg-do run { target c++11 } }
|
||||
// { dg-require-cstdint "" }
|
||||
// { dg-options "-fchar8_t" }
|
||||
|
||||
// 2014-04-24 Rüdiger Sonderfeld
|
||||
|
||||
// Copyright (C) 2015-2017 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// [locale.codecvt], C++11 22.4.1.4. specialization.
|
||||
|
||||
#include <locale>
|
||||
#include <cstring>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
void
|
||||
test01()
|
||||
{
|
||||
using namespace std;
|
||||
typedef codecvt<char32_t, char8_t, mbstate_t> codecvt_c32;
|
||||
locale loc_c = locale::classic();
|
||||
VERIFY(has_facet<codecvt_c32>(loc_c));
|
||||
const codecvt_c32* const cvt = &use_facet<codecvt_c32>(loc_c);
|
||||
|
||||
VERIFY(!cvt->always_noconv());
|
||||
VERIFY(cvt->max_length() == 4);
|
||||
VERIFY(cvt->encoding() == 0);
|
||||
|
||||
const char8_t u8dat[] = u8"H\U000000E4ll\U000000F6 \U0001F63F \U000056FD "
|
||||
u8"\U0000222B f(\U000003BA) exp(-2\U000003C0\U000003C9) d\U000003BA "
|
||||
u8"\U0001F6BF \U0001F6BF \U0001F648 \U00000413\U00000435\U0000043E"
|
||||
u8"\U00000433\U00000440\U00000430\U00000444\U00000438\U0000044F \U0000FB05";
|
||||
const char8_t* const u8dat_end = std::end(u8dat);
|
||||
|
||||
const char32_t u32dat[] = U"H\U000000E4ll\U000000F6 \U0001F63F \U000056FD "
|
||||
U"\U0000222B f(\U000003BA) exp(-2\U000003C0\U000003C9) d\U000003BA "
|
||||
U"\U0001F6BF \U0001F6BF \U0001F648 \U00000413\U00000435\U0000043E"
|
||||
U"\U00000433\U00000440\U00000430\U00000444\U00000438\U0000044F \U0000FB05";
|
||||
const char32_t* const u32dat_end = std::end(u32dat);
|
||||
|
||||
{
|
||||
const size_t len = u32dat_end - u32dat + 1;
|
||||
char32_t* const buffer = new char32_t[len];
|
||||
char32_t* const buffer_end = buffer + len;
|
||||
|
||||
const char8_t* from_next;
|
||||
char32_t* to_next;
|
||||
|
||||
codecvt_c32::state_type state01;
|
||||
state01 = {};
|
||||
codecvt_base::result res = cvt->in(state01, u8dat, u8dat_end, from_next,
|
||||
buffer, buffer_end, to_next);
|
||||
|
||||
VERIFY(res == codecvt_base::ok);
|
||||
VERIFY(from_next == u8dat_end);
|
||||
VERIFY(std::memcmp((void*)buffer, (void*)u32dat, sizeof(u32dat)) == 0);
|
||||
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
{
|
||||
const size_t len = u8dat_end - u8dat + 1;
|
||||
char8_t* const buffer = new char8_t[len];
|
||||
char8_t* const buffer_end = buffer + len;
|
||||
|
||||
const char32_t* from_next;
|
||||
char8_t* to_next;
|
||||
|
||||
codecvt_c32::state_type state01;
|
||||
state01 = {};
|
||||
codecvt_base::result res = cvt->out(state01, u32dat, u32dat_end, from_next,
|
||||
buffer, buffer_end, to_next);
|
||||
|
||||
VERIFY(res == codecvt_base::ok);
|
||||
VERIFY(from_next == u32dat_end);
|
||||
VERIFY(std::memcmp((void*)buffer, (void*)u8dat, sizeof(u8dat)) == 0);
|
||||
|
||||
delete[] buffer;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
}
|
77
libstdc++-v3/testsuite/22_locale/codecvt/utf8-char8_t.cc
Normal file
77
libstdc++-v3/testsuite/22_locale/codecvt/utf8-char8_t.cc
Normal file
@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2015-2017 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do run { target c++11 } }
|
||||
// { dg-require-cstdint "" }
|
||||
// { dg-options "-fchar8_t" }
|
||||
|
||||
#include <locale>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
const char8_t expected[] = u8"£¥€";
|
||||
const std::size_t expected_len = std::char_traits<char8_t>::length(expected);
|
||||
|
||||
template<typename C>
|
||||
void test(const C* from)
|
||||
{
|
||||
auto len = std::char_traits<C>::length(from);
|
||||
std::mbstate_t state{};
|
||||
char8_t buf[16] = { };
|
||||
using test_type = std::codecvt<C, char8_t, std::mbstate_t>;
|
||||
const test_type& cvt = std::use_facet<test_type>(std::locale::classic());
|
||||
auto from_end = from + len;
|
||||
auto from_next = from;
|
||||
auto buf_end = std::end(buf);
|
||||
auto buf_next = buf;
|
||||
auto res = cvt.out(state, from, from_end, from_next, buf, buf_end, buf_next);
|
||||
VERIFY( res == std::codecvt_base::ok );
|
||||
VERIFY( from_next == from_end );
|
||||
VERIFY( (buf_next - buf) == expected_len );
|
||||
VERIFY( 0 == std::char_traits<char8_t>::compare(buf, expected, expected_len) );
|
||||
|
||||
C buf2[16];
|
||||
auto exp_end = expected + expected_len;
|
||||
auto exp_next = expected;
|
||||
auto buf2_end = std::end(buf2);
|
||||
auto buf2_next = buf2;
|
||||
res = cvt.in(state, expected, exp_end, exp_next, buf2, buf2_end, buf2_next);
|
||||
VERIFY( res == std::codecvt_base::ok );
|
||||
VERIFY( exp_next == exp_end );
|
||||
VERIFY( (buf2_next - buf2) == len );
|
||||
VERIFY( 0 == std::char_traits<C>::compare(buf2, from, len) );
|
||||
}
|
||||
|
||||
void
|
||||
test01()
|
||||
{
|
||||
test(u"£¥€");
|
||||
}
|
||||
|
||||
void
|
||||
test02()
|
||||
{
|
||||
test(U"£¥€");
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
// Copyright (C) 2016-2017 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-std=gnu++17 -lstdc++fs -fchar8_t" }
|
||||
// { dg-do run { target c++17 } }
|
||||
// { dg-require-filesystem-ts "" }
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
void
|
||||
test01()
|
||||
{
|
||||
using namespace std::filesystem;
|
||||
const std::string s = "abc";
|
||||
path p(s);
|
||||
|
||||
VERIFY( p.native() == s );
|
||||
VERIFY( p.c_str() == s );
|
||||
VERIFY( static_cast<std::string>(p) == s );
|
||||
|
||||
std::string s2 = p; // implicit conversion
|
||||
VERIFY( s2 == p.native() );
|
||||
}
|
||||
|
||||
void
|
||||
test02()
|
||||
{
|
||||
using namespace std::filesystem;
|
||||
const char* s = "abc";
|
||||
path p(s);
|
||||
|
||||
auto str = p.string<char>();
|
||||
VERIFY( str == u"abc" );
|
||||
VERIFY( str == p.string() );
|
||||
|
||||
auto strw = p.string<wchar_t>();
|
||||
VERIFY( strw == L"abc" );
|
||||
VERIFY( strw == p.wstring() );
|
||||
|
||||
#ifdef _GLIBCXX_USE_CHAR8_T
|
||||
auto str8 = p.string<char8_t>();
|
||||
VERIFY( str8 == u8"abc" );
|
||||
VERIFY( str8 == p.u8string() );
|
||||
#endif
|
||||
|
||||
auto str16 = p.string<char16_t>();
|
||||
VERIFY( str16 == u"abc" );
|
||||
VERIFY( str16 == p.u16string() );
|
||||
|
||||
auto str32 = p.string<char32_t>();
|
||||
VERIFY( str32 == U"abc" );
|
||||
VERIFY( str32 == p.u32string() );
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
}
|
17
libstdc++-v3/testsuite/experimental/feat-char8_t.cc
Normal file
17
libstdc++-v3/testsuite/experimental/feat-char8_t.cc
Normal file
@ -0,0 +1,17 @@
|
||||
// { dg-do preprocess { target c++11 } }
|
||||
// { dg-options "-fchar8_t" }
|
||||
|
||||
#include <atomic>
|
||||
#include <filesystem>
|
||||
#include <istream>
|
||||
#include <limits>
|
||||
#include <locale>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#ifndef __cpp_lib_char8_t
|
||||
# error "__cpp_lib_char8_t"
|
||||
#elif __cpp_lib_char8_t != 201811
|
||||
# error "__cpp_lib_char8_t != 201811"
|
||||
#endif
|
@ -0,0 +1,76 @@
|
||||
// Copyright (C) 2016-2017 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-lstdc++fs -fchar8_t" }
|
||||
// { dg-do run { target c++11 } }
|
||||
// { dg-require-filesystem-ts "" }
|
||||
|
||||
#include <experimental/filesystem>
|
||||
#include <string>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
void
|
||||
test01()
|
||||
{
|
||||
using namespace std::experimental::filesystem;
|
||||
const std::string s = "abc";
|
||||
path p(s);
|
||||
|
||||
VERIFY( p.native() == s );
|
||||
VERIFY( p.c_str() == s );
|
||||
VERIFY( static_cast<std::string>(p) == s );
|
||||
|
||||
std::string s2 = p; // implicit conversion
|
||||
VERIFY( s2 == p.native() );
|
||||
}
|
||||
|
||||
void
|
||||
test02()
|
||||
{
|
||||
using namespace std::experimental::filesystem;
|
||||
const char* s = "abc";
|
||||
path p(s);
|
||||
|
||||
auto str = p.string<char>();
|
||||
VERIFY( str == u"abc" );
|
||||
VERIFY( str == p.string() );
|
||||
|
||||
auto strw = p.string<wchar_t>();
|
||||
VERIFY( strw == L"abc" );
|
||||
VERIFY( strw == p.wstring() );
|
||||
|
||||
#ifdef _GLIBCXX_USE_CHAR8_T
|
||||
auto str8 = p.string<char8_t>();
|
||||
VERIFY( str8 == u8"abc" );
|
||||
VERIFY( str8 == p.u8string() );
|
||||
#endif
|
||||
|
||||
auto str16 = p.string<char16_t>();
|
||||
VERIFY( str16 == u"abc" );
|
||||
VERIFY( str16 == p.u16string() );
|
||||
|
||||
auto str32 = p.string<char32_t>();
|
||||
VERIFY( str32 == U"abc" );
|
||||
VERIFY( str32 == p.u32string() );
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
// { dg-options "-fchar8_t" }
|
||||
// { dg-do compile { target c++14 } }
|
||||
|
||||
// Copyright (C) 2013-2017 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <experimental/string_view>
|
||||
#include <type_traits>
|
||||
|
||||
void
|
||||
test01()
|
||||
{
|
||||
using namespace std::experimental::literals::string_view_literals;
|
||||
|
||||
static_assert(std::is_same<decltype("Hello"sv), std::experimental::string_view>::value,
|
||||
"\"Hello\"sv is std::string_view");
|
||||
|
||||
#ifdef _GLIBCXX_USE_CHAR8_T
|
||||
static_assert(std::is_same<decltype(u8"Hello"sv), std::experimental::u8string_view>::value,
|
||||
"u8\"Hello\"sv is std::u8string_view");
|
||||
#else
|
||||
static_assert(std::is_same<decltype(u8"Hello"sv), std::experimental::string_view>::value,
|
||||
"u8\"Hello\"sv is std::string_view");
|
||||
#endif
|
||||
|
||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
||||
static_assert(std::is_same<decltype(L"Hello"sv), std::experimental::wstring_view>::value,
|
||||
"L\"Hello\"sv is std::wstring_view");
|
||||
#endif
|
||||
|
||||
static_assert(std::is_same<decltype(u"Hello"sv), std::experimental::u16string_view>::value,
|
||||
"u\"Hello\"sv is std::u16string_view");
|
||||
|
||||
static_assert(std::is_same<decltype(U"Hello"sv), std::experimental::u32string_view>::value,
|
||||
"U\"Hello\"sv is std::u32string_view");
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
// { dg-options "-fchar8_t" }
|
||||
// { dg-do run { target c++14 } }
|
||||
|
||||
// Copyright (C) 2013-2017 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <experimental/string_view>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
void
|
||||
test01()
|
||||
{
|
||||
using namespace std::experimental::literals::string_view_literals;
|
||||
|
||||
std::experimental::string_view planet = "Mercury"sv;
|
||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
||||
std::experimental::wstring_view wplanet = L"Venus"sv;
|
||||
#endif
|
||||
#ifdef _GLIBCXX_USE_CHAR8_T
|
||||
std::experimental::u8string_view u8planet = u8"Mars"sv;
|
||||
#else
|
||||
std::experimental::string_view u8planet = u8"Mars"sv;
|
||||
#endif
|
||||
std::experimental::u16string_view u16planet = u"Jupiter"sv;
|
||||
std::experimental::u32string_view u32planet = U"Saturn"sv;
|
||||
|
||||
VERIFY( planet == std::experimental::string_view("Mercury") );
|
||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
||||
VERIFY( wplanet == std::experimental::wstring_view(L"Venus") );
|
||||
#endif
|
||||
#ifdef _GLIBCXX_USE_CHAR8_T
|
||||
VERIFY( u8planet == std::experimental::u8string_view(u8"Mars") );
|
||||
#else
|
||||
VERIFY( u8planet == std::experimental::string_view(u8"Mars") );
|
||||
#endif
|
||||
VERIFY( u16planet == std::experimental::u16string_view(u"Jupiter") );
|
||||
VERIFY( u32planet == std::experimental::u32string_view(U"Saturn") );
|
||||
}
|
||||
|
||||
void
|
||||
test02()
|
||||
{
|
||||
using namespace std::experimental::literals::string_view_literals;
|
||||
|
||||
std::experimental::string_view planet_cratered = "Mercury\0cratered"sv;
|
||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
||||
std::experimental::wstring_view wplanet_cratered = L"Venus\0cratered"sv;
|
||||
#endif
|
||||
#ifdef _GLIBCXX_USE_CHAR8_T
|
||||
std::experimental::u8string_view u8planet_cratered = u8"Mars\0cratered"sv;
|
||||
#else
|
||||
std::experimental::string_view u8planet_cratered = u8"Mars\0cratered"sv;
|
||||
#endif
|
||||
std::experimental::u16string_view u16planet_cratered = u"Jupiter\0cratered"sv;
|
||||
std::experimental::u32string_view u32planet_cratered = U"Saturn\0cratered"sv;
|
||||
|
||||
VERIFY( planet_cratered ==
|
||||
std::experimental::string_view("Mercury\0cratered", 16) );
|
||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
||||
VERIFY( wplanet_cratered ==
|
||||
std::experimental::wstring_view(L"Venus\0cratered", 14) );
|
||||
#endif
|
||||
#ifdef _GLIBCXX_USE_CHAR8_T
|
||||
VERIFY( u8planet_cratered ==
|
||||
std::experimental::u8string_view(u8"Mars\0cratered", 13) );
|
||||
#else
|
||||
VERIFY( u8planet_cratered ==
|
||||
std::experimental::string_view(u8"Mars\0cratered", 13) );
|
||||
#endif
|
||||
VERIFY( u16planet_cratered ==
|
||||
std::experimental::u16string_view(u"Jupiter\0cratered", 16) );
|
||||
VERIFY( u32planet_cratered ==
|
||||
std::experimental::u32string_view(U"Saturn\0cratered", 15) );
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
// { dg-do compile { target c++14 } }
|
||||
// { dg-options "-fchar8_t" }
|
||||
// { dg-require-cstdint "" }
|
||||
|
||||
// Copyright (C) 2013-2017 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <experimental/string_view>
|
||||
|
||||
template class std::experimental::basic_string_view<char8_t>;
|
12
libstdc++-v3/testsuite/ext/char8_t/atomic-1.cc
Normal file
12
libstdc++-v3/testsuite/ext/char8_t/atomic-1.cc
Normal file
@ -0,0 +1,12 @@
|
||||
// Test that char8_t related atomic types and macros are not present when
|
||||
// -fchar8_t is not enabled.
|
||||
// { dg-do compile }
|
||||
// { dg-options "-fno-char8_t" }
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#if defined(ATOMIC_CHAR8_T_LOCK_FREE)
|
||||
#error ATOMIC_CHAR8_T_LOCK_FREE is defined!
|
||||
#endif
|
||||
|
||||
std::atomic_char8_t x1; // { dg-error "error: .atomic_char8_t. in namespace .std. does not name a type" "char8_t" }
|
Loading…
x
Reference in New Issue
Block a user