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 out(stateT& state,
21 //            const internT* from, const internT* from_end, const internT*& from_next,
22 //            externT* to, externT* to_end, externT*& 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& f = std::use_facet<F>(std::locale::classic());
30   F::intern_type from[9] = {u's', u'o', u'm', u'e', u' ', u't', u'e', u'x', u't'};
31   F::extern_type to[9] = {0};
32   std::mbstate_t mbs = {};
33   const F::intern_type* from_next = nullptr;
34   F::extern_type* to_next = nullptr;
35   F::result r = f.out(mbs, from, from + 9, from_next, to, to + 9, to_next);
36   assert(r == F::ok);
37   assert(from_next - from == 9);
38   assert(to_next - to == 9);
39   for (unsigned i = 0; i < 9; ++i)
40     assert(to[i] == from[i]);
41   return 0;
42 }
43