[TableGen] Split DAGISelMatcherOpt FactorNodes into 2 functions. NFC (#125330)
[llvm-project.git] / libcxx / test / std / localization / locales / locale.convenience / conversions / conversions.buffer / ctor.pass.cpp
blobfbc0bb4ace3acf42a040e1ada0047bd1f9f8e3d3
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 -D_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT -D_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT
13 // wbuffer_convert<Codecvt, Elem, Tr>
15 // wbuffer_convert(streambuf* bytebuf = 0, Codecvt* pcvt = new Codecvt,
16 // state_type state = state_type()); // before C++14
17 // explicit wbuffer_convert(streambuf* bytebuf = nullptr, Codecvt* pcvt = new Codecvt,
18 // state_type state = state_type()); // before C++20
19 // wbuffer_convert() : wbuffer_convert(nullptr) {} // C++20
20 // explicit wbuffer_convert(streambuf* bytebuf, Codecvt* pcvt = new Codecvt,
21 // state_type state = state_type()); // C++20
23 // XFAIL: no-wide-characters
25 #include <locale>
26 #include <codecvt>
27 #include <sstream>
28 #include <cassert>
30 #include "test_macros.h"
31 #include "count_new.h"
32 #if TEST_STD_VER >= 11
33 #include "test_convertible.h"
34 #endif
36 int main(int, char**)
38 globalMemCounter.reset();
39 typedef std::wbuffer_convert<std::codecvt_utf8<wchar_t> > B;
40 #if TEST_STD_VER > 11
41 static_assert(!std::is_convertible<std::streambuf*, B>::value, "");
42 static_assert( std::is_constructible<B, std::streambuf*>::value, "");
43 #endif
45 B b;
46 assert(b.rdbuf() == nullptr);
47 assert(globalMemCounter.checkOutstandingNewNotEq(0));
49 assert(globalMemCounter.checkOutstandingNewEq(0));
51 std::stringstream s;
52 B b(s.rdbuf());
53 assert(b.rdbuf() == s.rdbuf());
54 assert(globalMemCounter.checkOutstandingNewNotEq(0));
56 assert(globalMemCounter.checkOutstandingNewEq(0));
58 std::stringstream s;
59 B b(s.rdbuf(), new std::codecvt_utf8<wchar_t>);
60 assert(b.rdbuf() == s.rdbuf());
61 assert(globalMemCounter.checkOutstandingNewNotEq(0));
63 assert(globalMemCounter.checkOutstandingNewEq(0));
65 std::stringstream s;
66 B b(s.rdbuf(), new std::codecvt_utf8<wchar_t>, std::mbstate_t());
67 assert(b.rdbuf() == s.rdbuf());
68 assert(globalMemCounter.checkOutstandingNewNotEq(0));
70 assert(globalMemCounter.checkOutstandingNewEq(0));
72 #if TEST_STD_VER >= 11
74 static_assert(test_convertible<B>(), "");
75 static_assert(!test_convertible<B, std::streambuf*>(), "");
77 #endif
79 return 0;