//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // wstring_convert // size_t converted() const; #include #include #include 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"\x1005"); assert(myconv.converted() == 1); bs = myconv.to_bytes(L"\x1005\x65"); 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"\x40003"); assert(myconv.converted() == 1); bs = myconv.to_bytes(L"\x40003\x65"); assert(myconv.converted() == 2); std::wstring ws = myconv.from_bytes("\xF1\x80\x80\x83"); assert(myconv.converted() == 4); } } int main() { TestHelper::test(); }