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 // <locale>
10 
11 // template <> class codecvt<char32_t, char, mbstate_t>
12 
13 // result in(stateT& state,
14 //           const externT* from, const externT* from_end, const externT*& from_next,
15 //           internT* to, internT* to_end, internT*& to_next) const;
16 
17 #include <locale>
18 #include <string>
19 #include <vector>
20 #include <cassert>
21 
22 #include "test_macros.h"
23 
24 typedef std::codecvt<char32_t, char, std::mbstate_t> F;
25 
main(int,char **)26 int main(int, char**)
27 {
28     std::locale l = std::locale::classic();
29     const char from[] = "some text";
30     F::intern_type to[9];
31     const F& f = std::use_facet<F>(l);
32     std::mbstate_t mbs = {};
33     const char* from_next = 0;
34     F::intern_type* to_next = 0;
35     assert(f.in(mbs, from, from + 9, from_next,
36                      to, to + 9, to_next) == 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] == static_cast<char32_t>(from[i]));
41 
42   return 0;
43 }
44