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 //===----------------------------------------------------------------------===//
8 
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
10 
11 // This test relies on P0482 being fixed, which isn't in
12 // older Apple dylibs
13 //
14 // XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13|14|15}}
15 
16 // <locale>
17 
18 // template <> class codecvt<char32_t, char8_t, mbstate_t>
19 
20 // result in(stateT& state,
21 //           const externT* from, const externT* from_end, const externT*& from_next,
22 //           internT* to, internT* to_end, internT*& to_next) const;
23 
24 #include <cassert>
25 #include <locale>
26 
main(int,char **)27 int main(int, char**) {
28   using F = std::codecvt<char32_t, char8_t, std::mbstate_t>;
29   const F::extern_type from[] = u8"some text";
30   F::intern_type to[9];
31   const F& f = std::use_facet<F>(std::locale::classic());
32   std::mbstate_t mbs = {};
33   const F::extern_type* from_next = nullptr;
34   F::intern_type* to_next = nullptr;
35   assert(f.in(mbs, from, from + 9, from_next, to, to + 9, to_next) == F::ok);
36   assert(from_next - from == 9);
37   assert(to_next - to == 9);
38   for (unsigned i = 0; i < 9; ++i)
39     assert(to[i] == from[i]);
40   return 0;
41 }
42