//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS -D_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT -D_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT // wstring_convert // size_t converted() const; // XFAIL: no-wide-characters #include #include #include #include "test_macros.h" template struct TestHelper; template struct TestHelper { static void test(); }; template struct TestHelper { static void test(); }; template void TestHelper::test() { static_assert((std::is_same::value), ""); { typedef std::codecvt_utf8 Codecvt; typedef std::wstring_convert Myconv; Myconv myconv; assert(myconv.converted() == 0); std::string bs = myconv.to_bytes(L"\u1005"); assert(myconv.converted() == 1); bs = myconv.to_bytes(L"\u1005e"); assert(myconv.converted() == 2); std::wstring ws = myconv.from_bytes("\xE1\x80\x85"); assert(myconv.converted() == 3); } } template void TestHelper::test() { static_assert((std::is_same::value), ""); { typedef std::codecvt_utf8 Codecvt; typedef std::wstring_convert Myconv; Myconv myconv; assert(myconv.converted() == 0); std::string bs = myconv.to_bytes(L"\U00040003"); assert(myconv.converted() == 1); bs = myconv.to_bytes(L"\U00040003e"); assert(myconv.converted() == 2); std::wstring ws = myconv.from_bytes("\xF1\x80\x80\x83"); assert(myconv.converted() == 4); } } int main(int, char**) { TestHelper::test(); return 0; }