diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2015-06-08 14:03:45 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2015-06-08 14:03:45 +0100 |
commit | c00f4f5fb3f0b482cc50d459b0f89af4ddb0ec1a (patch) | |
tree | 1788fc16b7a5e41402b9ab33838a01415f361fa1 /libstdc++-v3/testsuite/22_locale | |
parent | 9b999e8c82296dc7acee8e74b49cab47004c47a5 (diff) | |
download | gcc-c00f4f5fb3f0b482cc50d459b0f89af4ddb0ec1a.zip gcc-c00f4f5fb3f0b482cc50d459b0f89af4ddb0ec1a.tar.gz gcc-c00f4f5fb3f0b482cc50d459b0f89af4ddb0ec1a.tar.bz2 |
re PR libstdc++/66441 (wstring_convert not working correctly)
PR libstdc++/66441
* testsuite/22_locale/conversions/string/66441.cc: New.
* include/bits/locale_conv.h (__do_str_codecvt): Reserve enough space
in the output string for BOM and complete result.
From-SVN: r224222
Diffstat (limited to 'libstdc++-v3/testsuite/22_locale')
-rw-r--r-- | libstdc++-v3/testsuite/22_locale/conversions/string/66441.cc | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/22_locale/conversions/string/66441.cc b/libstdc++-v3/testsuite/22_locale/conversions/string/66441.cc new file mode 100644 index 0000000..b72edc8 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/conversions/string/66441.cc @@ -0,0 +1,49 @@ +// Copyright (C) 2015 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++11" } + +// libstdc++/66441 + +#include <locale> +#include <codecvt> +#include <testsuite_hooks.h> + +void +test01() +{ + // convert from UCS-4 to UTF16BE with BOM. + using cvt = std::codecvt_utf16<char32_t, 0x10FFFF, std::generate_header>; + std::wstring_convert<cvt, char32_t> conv; + auto to = conv.to_bytes(U"ab\u00e7"); + + VERIFY( to.length() == 8 ); + VERIFY( (unsigned char)to[0] == 0xfe ); + VERIFY( (unsigned char)to[1] == 0xff ); + VERIFY( (unsigned char)to[2] == 0x00 ); + VERIFY( (unsigned char)to[3] == 0x61 ); + VERIFY( (unsigned char)to[4] == 0x00 ); + VERIFY( (unsigned char)to[5] == 0x62 ); + VERIFY( (unsigned char)to[6] == 0x00 ); + VERIFY( (unsigned char)to[7] == 0xe7 ); +} + +int +main() +{ + test01(); +} |