Home | History | Annotate | Download | only in conversions.string
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // 'do_bytes' throws a std::range_error unexpectedly
     11 // XFAIL: LIBCXX-WINDOWS-FIXME
     12 
     13 // UNSUPPORTED: c++98, c++03
     14 
     15 // <locale>
     16 
     17 // wstring_convert<Codecvt, Elem, Wide_alloc, Byte_alloc>
     18 
     19 // wstring_convert(wstring_convert&& other); // EXTENSION
     20 
     21 #include <locale>
     22 #include <codecvt>
     23 #include <cassert>
     24 
     25 int main()
     26 {
     27     typedef std::codecvt_utf8<wchar_t> Codecvt;
     28     typedef std::wstring_convert<Codecvt> Myconv;
     29     // create a converter and perform some conversions to generate some
     30     // interesting state.
     31     Myconv myconv;
     32     myconv.from_bytes("\xF1\x80\x80\x83");
     33     const auto old_converted = myconv.converted();
     34     assert(myconv.converted() == 4);
     35     // move construct a new converter and make sure the state is the same.
     36     Myconv myconv2(std::move(myconv));
     37     assert(myconv2.converted() == old_converted);
     38 }
     39