Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / localization / locales / locale.convenience / conversions / conversions.buffer / test.pass.cpp
blobb37424bb5595eed53c9b61e8a6878e51b4bf0439
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // <locale>
11 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
13 // wbuffer_convert<Codecvt, Elem, Tr>
15 // XFAIL: no-wide-characters
17 #include <cassert>
18 #include <codecvt>
19 #include <locale>
20 #include <sstream>
22 int main(int, char**) {
23 std::string storage;
25 std::ostringstream bytestream;
26 std::wbuffer_convert<std::codecvt_utf8<wchar_t> > mybuf(bytestream.rdbuf());
27 std::wostream mystr(&mybuf);
28 mystr << L"Hello" << std::endl;
29 storage = bytestream.str();
32 std::istringstream bytestream(storage);
33 std::wbuffer_convert<std::codecvt_utf8<wchar_t> > mybuf(bytestream.rdbuf());
34 std::wistream mystr(&mybuf);
35 std::wstring ws;
36 mystr >> ws;
37 assert(ws == L"Hello");
40 return 0;