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 "count_new.hpp"
23
main()24 int main()
25 {
26 typedef std::wbuffer_convert<std::codecvt_utf8<wchar_t> > B;
27 #if _LIBCPP_STD_VER > 11
28 static_assert(!std::is_convertible<std::streambuf*, B>::value, "");
29 static_assert( std::is_constructible<B, std::streambuf*>::value, "");
30 #endif
31 {
32 B b;
33 assert(b.rdbuf() == nullptr);
34 assert(globalMemCounter.checkOutstandingNewNotEq(0));
35 }
36 assert(globalMemCounter.checkOutstandingNewEq(0));
37 {
38 std::stringstream s;
39 B b(s.rdbuf());
40 assert(b.rdbuf() == s.rdbuf());
41 assert(globalMemCounter.checkOutstandingNewNotEq(0));
42 }
43 assert(globalMemCounter.checkOutstandingNewEq(0));
44 {
45 std::stringstream s;
46 B b(s.rdbuf(), new std::codecvt_utf8<wchar_t>);
47 assert(b.rdbuf() == s.rdbuf());
48 assert(globalMemCounter.checkOutstandingNewNotEq(0));
49 }
50 assert(globalMemCounter.checkOutstandingNewEq(0));
51 {
52 std::stringstream s;
53 B b(s.rdbuf(), new std::codecvt_utf8<wchar_t>, std::mbstate_t());
54 assert(b.rdbuf() == s.rdbuf());
55 assert(globalMemCounter.checkOutstandingNewNotEq(0));
56 }
57 assert(globalMemCounter.checkOutstandingNewEq(0));
58 }
59