81 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// <codecvt>10 11// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS -D_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT12 13// template <class Elem, unsigned long Maxcode = 0x10ffff,14// codecvt_mode Mode = (codecvt_mode)0>15// class codecvt_utf1616// : public codecvt<Elem, char, mbstate_t>17// {18// // unspecified19// };20 21// int max_length() const throw();22 23#include <codecvt>24#include <cassert>25 26#include "test_macros.h"27 28template <class CharT, std::size_t = sizeof(CharT)>29struct TestHelper;30 31template <class CharT>32struct TestHelper<CharT, 2> {33 static void test();34};35 36template <class CharT>37struct TestHelper<CharT, 4> {38 static void test();39};40 41template <class CharT>42void TestHelper<CharT, 2>::test() {43 {44 typedef std::codecvt_utf16<CharT> C;45 C c;46 int r = c.max_length();47 assert(r == 2);48 }49 {50 typedef std::codecvt_utf16<CharT, 0xFFFFFFFF, std::consume_header> C;51 C c;52 int r = c.max_length();53 assert(r == 4);54 }55}56 57template <class CharT>58void TestHelper<CharT, 4>::test() {59 {60 typedef std::codecvt_utf16<CharT> C;61 C c;62 int r = c.max_length();63 assert(r == 4);64 }65 {66 typedef std::codecvt_utf16<CharT, 0xFFFFFFFF, std::consume_header> C;67 C c;68 int r = c.max_length();69 assert(r == 6);70 }71}72 73int main(int, char**) {74#ifndef TEST_HAS_NO_WIDE_CHARACTERS75 TestHelper<wchar_t>::test();76#endif77 TestHelper<char16_t>::test();78 TestHelper<char32_t>::test();79 return 0;80}81