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 // int length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
14 
15 #include <locale>
16 #include <cassert>
17 
18 #include "test_macros.h"
19 
20 typedef std::codecvt<char16_t, char, std::mbstate_t> F;
21 
main(int,char **)22 int main(int, char**)
23 {
24     std::locale l = std::locale::classic();
25     const F& f = std::use_facet<F>(l);
26     std::mbstate_t mbs = {};
27     const char from[] = "some text";
28     assert(f.length(mbs, from, from+10, 0) == 0);
29     assert(f.length(mbs, from, from+10, 8) == 8);
30     assert(f.length(mbs, from, from+10, 9) == 9);
31     assert(f.length(mbs, from, from+10, 10) == 10);
32     assert(f.length(mbs, from, from+10, 100) == 10);
33 
34   return 0;
35 }
36