[clang-format] Handle C-style cast of member function pointer type (#126340)
[llvm-project.git] / libcxx / test / std / localization / locales / locale.convenience / conversions / conversions.buffer / pbackfail.pass.cpp
blob28e54cec366e44cddc7808e0d8a7c5cd31092dde
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 // int_type pbackfail(int_type c = traits::eof());
17 // This test is not entirely portable
19 // XFAIL: no-wide-characters
21 #include <locale>
22 #include <cassert>
23 #include <codecvt>
24 #include <sstream>
26 struct test_buf
27 : public std::wbuffer_convert<std::codecvt_utf8<wchar_t> >
29 typedef std::wbuffer_convert<std::codecvt_utf8<wchar_t> > base;
30 typedef base::char_type char_type;
31 typedef base::int_type int_type;
32 typedef base::traits_type traits_type;
34 explicit test_buf(std::streambuf* sb) : base(sb) {}
36 char_type* eback() const {return base::eback();}
37 char_type* gptr() const {return base::gptr();}
38 char_type* egptr() const {return base::egptr();}
39 void gbump(int n) {base::gbump(n);}
41 virtual int_type pbackfail(int_type c = traits_type::eof()) {return base::pbackfail(c);}
44 int main(int, char**)
46 std::string const s = "123456789";
48 std::istringstream in(s);
49 test_buf f(in.rdbuf());
50 assert(f.sbumpc() == L'1');
51 assert(f.sgetc() == L'2');
52 assert(f.pbackfail(L'a') == test_buf::traits_type::eof());
55 std::istringstream in(s);
56 test_buf f(in.rdbuf());
57 assert(f.sbumpc() == L'1');
58 assert(f.sgetc() == L'2');
59 assert(f.pbackfail(L'a') == test_buf::traits_type::eof());
60 assert(f.sbumpc() == L'2');
61 assert(f.sgetc() == L'3');
64 return 0;