+2019-02-19 Jonathan Wakely <jwakely@redhat.com>
+
+ * testsuite/21_strings/basic_string/literals/types.cc
+ [_GLIBCXX_USE_CHAR8_T]: Adjust expected string type for u8 literal.
+ * testsuite/21_strings/basic_string/literals/values.cc
+ [_GLIBCXX_USE_CHAR8_T]: Likewise.
+ * testsuite/22_locale/codecvt/char16_t.cc: Adjust for u8 literals
+ potentially having different type.
+ * testsuite/22_locale/codecvt/char32_t.cc: Likewise.
+ * testsuite/22_locale/codecvt/codecvt_utf8/79980.cc: Cast u8 literal
+ to char.
+ * testsuite/22_locale/codecvt/codecvt_utf8/wchar_t/1.cc: Likewise.
+ * testsuite/22_locale/codecvt/utf8.cc: Likewise.
+ * testsuite/22_locale/conversions/string/2.cc: Remove u8 prefix from
+ string literals only using basic character set.
+ * testsuite/22_locale/conversions/string/3.cc: Likewise. Cast other
+ u8 literals to char.
+ * testsuite/29_atomics/headers/atomic/macros.cc [_GLIBCXX_USE_CHAR8_T]:
+ Test ATOMIC_CHAR8_T_LOCK_FREE.
+ Add missing #error to ATOMIC_CHAR16_T_LOCK_FREE test.
+ * testsuite/29_atomics/headers/atomic/types_std_c++0x.cc
+ [_GLIBCXX_USE_CHAR8_T]: Check for std::atomic_char8_t.
+ * testsuite/experimental/string_view/literals/types.cc
+ [_GLIBCXX_USE_CHAR8_T]: Adjust expected string_view type for u8
+ literal.
+ * testsuite/experimental/string_view/literals/values.cc
+ [_GLIBCXX_USE_CHAR8_T]: Likewise.
+
2019-02-19 Tom Honermann <tom@honermann.net>
* testsuite/18_support/numeric_limits/char8_t.cc: New test cloned
#include <string>
#include <type_traits>
+#ifdef _GLIBCXX_USE_CHAR8_T
+using std::u8string;
+#else
+using u8string = std::string;
+#endif
+
void
test01()
{
static_assert(std::is_same<decltype("Hello"s), std::string>::value,
"\"Hello\"s is std::string");
- static_assert(std::is_same<decltype(u8"Hello"s), std::string>::value,
+ static_assert(std::is_same<decltype(u8"Hello"s), u8string>::value,
"u8\"Hello\"s is std::string");
#ifdef _GLIBCXX_USE_WCHAR_T
#include <string>
#include <testsuite_hooks.h>
+#ifdef _GLIBCXX_USE_CHAR8_T
+using std::u8string;
+#else
+using u8string = std::string;
+#endif
+
void
test01()
{
#ifdef _GLIBCXX_USE_WCHAR_T
std::wstring wplanet = L"Venus"s;
#endif
- std::string u8planet = u8"Mars"s;
+ u8string u8planet = u8"Mars"s;
std::u16string u16planet = u"Jupiter"s;
std::u32string u32planet = U"Saturn"s;
#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( wplanet == std::wstring(L"Venus") );
#endif
- VERIFY( u8planet == std::string(u8"Mars") );
+ VERIFY( u8planet == u8string(u8"Mars") );
VERIFY( u16planet == std::u16string(u"Jupiter") );
VERIFY( u32planet == std::u32string(U"Saturn") );
}
#include <string_view>
#include <type_traits>
+#ifdef _GLIBCXX_USE_CHAR8_T
+using std::u8string_view;
+#else
+using u8string_view = std::string_view;
+#endif
+
void
test01()
{
static_assert(std::is_same<decltype("Hello"sv), std::string_view>::value,
"\"Hello\"s is std::string_view");
- static_assert(std::is_same<decltype(u8"Hello"sv), std::string_view>::value,
+ static_assert(std::is_same<decltype(u8"Hello"sv), u8string_view>::value,
"u8\"Hello\"s is std::string_view");
#ifdef _GLIBCXX_USE_WCHAR_T
#include <string_view>
#include <testsuite_hooks.h>
+#ifdef _GLIBCXX_USE_CHAR8_T
+using std::u8string_view;
+#else
+using u8string_view = std::string_view;
+#endif
+
void
test01()
{
#ifdef _GLIBCXX_USE_WCHAR_T
std::wstring_view wplanet = L"Venus"sv;
#endif
- std::string_view u8planet = u8"Mars"sv;
+ u8string_view u8planet = u8"Mars"sv;
std::u16string_view u16planet = u"Jupiter"sv;
std::u32string_view u32planet = U"Saturn"sv;
#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( wplanet == std::wstring_view(L"Venus") );
#endif
- VERIFY( u8planet == std::string_view(u8"Mars") );
+ VERIFY( u8planet == u8string_view(u8"Mars") );
VERIFY( u16planet == std::u16string_view(u"Jupiter") );
VERIFY( u32planet == std::u32string_view(U"Saturn") );
}
#ifdef _GLIBCXX_USE_WCHAR_T
std::wstring_view wplanet_cratered = L"Venus\0cratered"sv;
#endif
- std::string_view u8planet_cratered = u8"Mars\0cratered"sv;
+ u8string_view u8planet_cratered = u8"Mars\0cratered"sv;
std::u16string_view u16planet_cratered = u"Jupiter\0cratered"sv;
std::u32string_view u32planet_cratered = U"Saturn\0cratered"sv;
#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( wplanet_cratered == std::wstring_view(L"Venus\0cratered", 14) );
#endif
- VERIFY( u8planet_cratered == std::string_view(u8"Mars\0cratered", 13) );
+ VERIFY( u8planet_cratered == u8string_view(u8"Mars\0cratered", 13) );
VERIFY( u16planet_cratered == std::u16string_view(u"Jupiter\0cratered", 16) );
VERIFY( u32planet_cratered == std::u32string_view(U"Saturn\0cratered", 15) );
}
VERIFY(cvt->max_length() == 4);
VERIFY(cvt->encoding() == 0);
- const char u8dat[] = u8"H\U000000E4ll\U000000F6 \U0001F63F \U000056FD "
+#ifndef _GLIBCXX_USE_CHAR8_T
+ using char8_t = char;
+#endif
+ 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 char* const u8dat_end = std::end(u8dat);
+ const char* const u8dat = (const char*)u8dat_;
+ const char* const u8dat_end = (const char*)std::end(u8dat_);
const char16_t u16dat[] = u"H\U000000E4ll\U000000F6 \U0001F63F \U000056FD "
u"\U0000222B f(\U000003BA) exp(-2\U000003C0\U000003C9) d\U000003BA "
VERIFY(res == codecvt_base::ok);
VERIFY(from_next == u16dat_end);
- VERIFY(std::memcmp((void*)buffer, (void*)u8dat, sizeof(u8dat)) == 0);
+ VERIFY(std::memcmp((void*)buffer, (void*)u8dat_, sizeof(u8dat_)) == 0);
delete[] buffer;
}
VERIFY(cvt->max_length() == 4);
VERIFY(cvt->encoding() == 0);
- const char u8dat[] = u8"H\U000000E4ll\U000000F6 \U0001F63F \U000056FD "
+#ifndef _GLIBCXX_USE_CHAR8_T
+ using char8_t = char;
+#endif
+ 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 char* const u8dat_end = std::end(u8dat);
+ const char* const u8dat = (const char*)u8dat_;
+ const char* const u8dat_end = (const char*)std::end(u8dat_);
const char32_t u32dat[] = U"H\U000000E4ll\U000000F6 \U0001F63F \U000056FD "
U"\U0000222B f(\U000003BA) exp(-2\U000003C0\U000003C9) d\U000003BA "
VERIFY(res == codecvt_base::ok);
VERIFY(from_next == u32dat_end);
- VERIFY(std::memcmp((void*)buffer, (void*)u8dat, sizeof(u8dat)) == 0);
+ VERIFY(std::memcmp((void*)buffer, (void*)u8dat_, sizeof(u8dat_)) == 0);
delete[] buffer;
}
void
test01()
{
- std::string src = u8"1234\U00001111\U0001ffff";
+ std::string src = (const char*)u8"1234\U00001111\U0001ffff";
wstring_convert<codecvt_utf8<char16_t>, char16_t> c("bad", u"BAD");
// utf-8 to ucs2 conversion should fail on character outside BMP
void
test02()
{
- std::string src = u8"1234\U00001111\U0001ffff";
+ std::string src = (const char*)u8"1234\U00001111\U0001ffff";
wstring_convert<codecvt_utf8<char16_t, 0x1000>, char16_t> c("bad", u"BAD");
// utf-8 to ucs2 conversion should fail on character above Maxcode=0x1000
void
test03()
{
- std::string src = u8"1234\U00001111\U0001ffff";
+ std::string src = (const char*)u8"1234\U00001111\U0001ffff";
wstring_convert<codecvt_utf8<char32_t, 0x10000>, char32_t> c("bad", U"BAD");
// utf-8 to ucs4 conversion should fail on character above Maxcode=0x10000
void
test04()
{
- std::string src = u8"1234\U00001111\U0001ffff";
+ std::string src = (const char*)u8"1234\U00001111\U0001ffff";
wstring_convert<codecvt_utf8<char32_t, 0x1000>, char32_t> c("bad", U"BAD");
// utf-8 to ucs4 conversion should fail on character above Maxcode=0x1000
void
test01()
{
- const char out[] = u8"\u00A33.50";
+ const auto out = (const char*)u8"\u00A33.50";
wchar_t in[8] = {};
std::codecvt_utf8<wchar_t> cvt;
std::mbstate_t st;
#include <string>
#include <testsuite_hooks.h>
-const char expected[] = u8"£¥€";
+const auto expected = (const char*)u8"£¥€";
const std::size_t expected_len = std::char_traits<char>::length(expected);
template<typename C>
typedef str_conv<char> sc;
const sc::byte_string berr = "invalid wide string";
- const sc::wide_string werr = u8"invalid byte string";
+ const sc::wide_string werr = "invalid byte string";
sc c(berr, werr);
string input = "Stop";
input += char(0xFF);
string woutput = c.from_bytes(input);
VERIFY( input == woutput ); // noconv case doesn't detect invalid input
- string winput = u8"Stop";
+ string winput = "Stop";
winput += char(0xFF);
string output = c.to_bytes(winput);
VERIFY( winput == output ); // noconv case doesn't detect invalid input
typedef str_conv<char> wsc;
wsc c;
- string input = u8"\u00a3 shillings pence";
+ string input = (const char*)u8"\u00a3 shillings pence";
string woutput = c.from_bytes(input.substr(0, 1));
auto partial_state = c.state();
auto partial_count = c.converted();
- auto woutput2 = c.from_bytes(u8"state reset on next conversion");
- VERIFY( woutput2 == u8"state reset on next conversion" );
+ auto woutput2 = c.from_bytes("state reset on next conversion");
+ VERIFY( woutput2 == "state reset on next conversion" );
wsc c2(new cvt<char>, partial_state);
woutput += c2.from_bytes(input.substr(partial_count));
- VERIFY( u8"\u00a3 shillings pence" == woutput );
+ VERIFY( (const char*)u8"\u00a3 shillings pence" == woutput );
string roundtrip = c2.to_bytes(woutput);
VERIFY( input == roundtrip );
typedef str_conv<char16_t> wsc;
wsc c;
- string input = u8"\u00a3 shillings pence";
+ string input = (const char*)u8"\u00a3 shillings pence";
u16string woutput = c.from_bytes(input.substr(0, 1));
auto partial_state = c.state();
auto partial_count = c.converted();
- auto woutput2 = c.from_bytes(u8"state reset on next conversion");
+ auto woutput2 = c.from_bytes("state reset on next conversion");
VERIFY( woutput2 == u"state reset on next conversion" );
wsc c2(new cvt<char16_t>, partial_state);
typedef str_conv<char32_t> wsc;
wsc c;
- string input = u8"\u00a3 shillings pence";
+ string input = (const char*)u8"\u00a3 shillings pence";
u32string woutput = c.from_bytes(input.substr(0, 1));
auto partial_state = c.state();
auto partial_count = c.converted();
- auto woutput2 = c.from_bytes(u8"state reset on next conversion");
+ auto woutput2 = c.from_bytes("state reset on next conversion");
VERIFY( woutput2 == U"state reset on next conversion" );
wsc c2(new cvt<char32_t>, partial_state);
# error "ATOMIC_CHAR_LOCK_FREE must be 1 or 2"
#endif
+#ifdef _GLIBCXX_USE_CHAR8_T
+# ifndef ATOMIC_CHAR8_T_LOCK_FREE
+# error "ATOMIC_CHAR8_T_LOCK_FREE must be a macro"
+# elif ATOMIC_CHAR8_T_LOCK_FREE != 1 && ATOMIC_CHAR8_T_LOCK_FREE != 2
+# error "ATOMIC_CHAR8_T_LOCK_FREE must be 1 or 2"
+# endif
+#endif
+
#ifndef ATOMIC_CHAR16_T_LOCK_FREE
# error "ATOMIC_CHAR16_T_LOCK_FREE must be a macro"
#elif ATOMIC_CHAR16_T_LOCK_FREE != 1 && ATOMIC_CHAR16_T_LOCK_FREE != 2
+# error "ATOMIC_CHAR16_T_LOCK_FREE must be 1 or 2"
#endif
#ifndef ATOMIC_CHAR32_T_LOCK_FREE
using std::atomic_llong;
using std::atomic_ullong;
using std::atomic_wchar_t;
+#ifdef _GLIBCXX_USE_CHAR8_T
+ using std::atomic_char8_t;
+#endif
using std::atomic_char16_t;
using std::atomic_char32_t;
#include <experimental/string_view>
#include <type_traits>
+#ifdef _GLIBCXX_USE_CHAR8_T
+using std::experimental::u8string_view;
+#else
+using u8string_view = std::experimental::string_view;
+#endif
+
void
test01()
{
static_assert(std::is_same<decltype("Hello"sv), std::experimental::string_view>::value,
"\"Hello\"s is std::string_view");
- static_assert(std::is_same<decltype(u8"Hello"sv), std::experimental::string_view>::value,
+ static_assert(std::is_same<decltype(u8"Hello"sv), u8string_view>::value,
"u8\"Hello\"s is std::string_view");
#ifdef _GLIBCXX_USE_WCHAR_T
#include <experimental/string_view>
#include <testsuite_hooks.h>
+#ifdef _GLIBCXX_USE_CHAR8_T
+using std::experimental::u8string_view;
+#else
+using u8string_view = std::experimental::string_view;
+#endif
+
void
test01()
{
#ifdef _GLIBCXX_USE_WCHAR_T
std::experimental::wstring_view wplanet = L"Venus"sv;
#endif
- std::experimental::string_view u8planet = u8"Mars"sv;
+ u8string_view u8planet = u8"Mars"sv;
std::experimental::u16string_view u16planet = u"Jupiter"sv;
std::experimental::u32string_view u32planet = U"Saturn"sv;
#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( wplanet == std::experimental::wstring_view(L"Venus") );
#endif
- VERIFY( u8planet == std::experimental::string_view(u8"Mars") );
+ VERIFY( u8planet == u8string_view(u8"Mars") );
VERIFY( u16planet == std::experimental::u16string_view(u"Jupiter") );
VERIFY( u32planet == std::experimental::u32string_view(U"Saturn") );
}
#ifdef _GLIBCXX_USE_WCHAR_T
std::experimental::wstring_view wplanet_cratered = L"Venus\0cratered"sv;
#endif
- std::experimental::string_view u8planet_cratered = u8"Mars\0cratered"sv;
+ u8string_view u8planet_cratered = u8"Mars\0cratered"sv;
std::experimental::u16string_view u16planet_cratered = u"Jupiter\0cratered"sv;
std::experimental::u32string_view u32planet_cratered = U"Saturn\0cratered"sv;
VERIFY( wplanet_cratered ==
std::experimental::wstring_view(L"Venus\0cratered", 14) );
#endif
- VERIFY( u8planet_cratered ==
- std::experimental::string_view(u8"Mars\0cratered", 13) );
+ VERIFY( u8planet_cratered == u8string_view(u8"Mars\0cratered", 13) );
VERIFY( u16planet_cratered ==
std::experimental::u16string_view(u"Jupiter\0cratered", 16) );
VERIFY( u32planet_cratered ==