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<char16_t, char, mbstate_t>
12
13 // result out(stateT& state,
14 // const internT* from, const internT* from_end, const internT*& from_next,
15 // externT* to, externT* to_end, externT*& to_next) const;
16
17 #include <locale>
18 #include <string>
19 #include <vector>
20 #include <cassert>
21
22 #include <stdio.h>
23
24 #include "test_macros.h"
25
26 typedef std::codecvt<char16_t, char, std::mbstate_t> F;
27
main(int,char **)28 int main(int, char**)
29 {
30 std::locale l = std::locale::classic();
31 const F& f = std::use_facet<F>(l);
32 {
33 F::intern_type from[9] = {'s', 'o', 'm', 'e', ' ', 't', 'e', 'x', 't'};
34 char to[9] = {0};
35 std::mbstate_t mbs = {};
36 const F::intern_type* from_next = 0;
37 char* to_next = 0;
38 F::result r = f.out(mbs, from, from + 9, from_next,
39 to, to + 9, to_next);
40 assert(r == F::ok);
41 assert(from_next - from == 9);
42 assert(to_next - to == 9);
43 for (unsigned i = 0; i < 9; ++i)
44 assert(to[i] == from[i]);
45 }
46
47 return 0;
48 }
49