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 // wbuffer_convert(streambuf *bytebuf = 0, Codecvt *pcvt = new Codecvt,
15 // state_type state = state_type());
16
17 #include <locale>
18 #include <codecvt>
19 #include <sstream>
20 #include <cassert>
21
22 #include "test_macros.h"
23 #include "count_new.hpp"
24
main()25 int main()
26 {
27 typedef std::wbuffer_convert<std::codecvt_utf8<wchar_t> > B;
28 #if TEST_STD_VER > 11
29 static_assert(!std::is_convertible<std::streambuf*, B>::value, "");
30 static_assert( std::is_constructible<B, std::streambuf*>::value, "");
31 #endif
32 {
33 B b;
34 assert(b.rdbuf() == nullptr);
35 assert(globalMemCounter.checkOutstandingNewNotEq(0));
36 }
37 assert(globalMemCounter.checkOutstandingNewEq(0));
38 {
39 std::stringstream s;
40 B b(s.rdbuf());
41 assert(b.rdbuf() == s.rdbuf());
42 assert(globalMemCounter.checkOutstandingNewNotEq(0));
43 }
44 assert(globalMemCounter.checkOutstandingNewEq(0));
45 {
46 std::stringstream s;
47 B b(s.rdbuf(), new std::codecvt_utf8<wchar_t>);
48 assert(b.rdbuf() == s.rdbuf());
49 assert(globalMemCounter.checkOutstandingNewNotEq(0));
50 }
51 assert(globalMemCounter.checkOutstandingNewEq(0));
52 {
53 std::stringstream s;
54 B b(s.rdbuf(), new std::codecvt_utf8<wchar_t>, std::mbstate_t());
55 assert(b.rdbuf() == s.rdbuf());
56 assert(globalMemCounter.checkOutstandingNewNotEq(0));
57 }
58 assert(globalMemCounter.checkOutstandingNewEq(0));
59 }
60