test.pass.cpp revision b64f8b07c104c6cc986570ac8ee0ed16a9f23976
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// <locale>
11
12// wbuffer_convert<Codecvt, Elem, Tr>
13
14#include <fstream>
15#include <locale>
16#include <codecvt>
17#include <cassert>
18
19int main()
20{
21    {
22        std::ofstream bytestream("myfile.txt");
23        std::wbuffer_convert<std::codecvt_utf8<wchar_t> > mybuf(bytestream.rdbuf());
24        std::wostream mystr(&mybuf);
25        mystr << L"Hello" << std::endl;
26    }
27    {
28        std::ifstream bytestream("myfile.txt");
29        std::wbuffer_convert<std::codecvt_utf8<wchar_t> > mybuf(bytestream.rdbuf());
30        std::wistream mystr(&mybuf);
31        std::wstring ws;
32        mystr >> ws;
33        assert(ws == L"Hello");
34    }
35    std::remove("myfile.txt");
36}
37