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 // <codecvt>
10 
11 // template <class Elem, unsigned long Maxcode = 0x10ffff,
12 //           codecvt_mode Mode = (codecvt_mode)0>
13 // class codecvt_utf8
14 //     : public codecvt<Elem, char, mbstate_t>
15 // {
16 //     // unspecified
17 // };
18 
19 // int max_length() const throw();
20 
21 #include <codecvt>
22 #include <cassert>
23 
24 int main(int, char**)
25 {
26     {
27         typedef std::codecvt_utf8<wchar_t> C;
28         C c;
29         int r = c.max_length();
30         assert(r == 4);
31     }
32     {
33         typedef std::codecvt_utf8<wchar_t, 0xFFFFFFFF, std::consume_header> C;
34         C c;
35         int r = c.max_length();
36         assert(r == 7);
37     }
38     {
39         typedef std::codecvt_utf8<char16_t> C;
40         C c;
41         int r = c.max_length();
42         assert(r == 3);
43     }
44     {
45         typedef std::codecvt_utf8<char16_t, 0xFFFFFFFF, std::consume_header> C;
46         C c;
47         int r = c.max_length();
48         assert(r == 6);
49     }
50     {
51         typedef std::codecvt_utf8<char32_t> C;
52         C c;
53         int r = c.max_length();
54         assert(r == 4);
55     }
56     {
57         typedef std::codecvt_utf8<char32_t, 0xFFFFFFFF, std::consume_header> C;
58         C c;
59         int r = c.max_length();
60         assert(r == 7);
61     }
62 
63   return 0;
64 }
65