brintos

brintos / llvm-project-archived public Read only

0
0
Text · 29.3 KiB · 63ead5c Raw
582 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// UNSUPPORTED: c++03, c++11, c++14, c++1710// UNSUPPORTED: no-localization11// UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME12 13// TODO FMT This test should not require std::to_chars(floating-point)14// XFAIL: availability-fp_to_chars-missing15 16// TODO FMT Investigate Windows issues.17// XFAIL: msvc18 19// REQUIRES: locale.fr_FR.UTF-820// REQUIRES: locale.ja_JP.UTF-821 22// <chrono>23 24// template<class charT> struct formatter<chrono::month_day, charT>;25 26#include <chrono>27#include <format>28 29#include <cassert>30#include <concepts>31#include <locale>32#include <iostream>33#include <type_traits>34 35#include "formatter_tests.h"36#include "make_string.h"37#include "platform_support.h" // locale name macros38#include "string_literal.h"39#include "test_macros.h"40 41template <class CharT>42static void test_no_chrono_specs() {43  // Valid month "valid" day44  check(SV("Feb/31"), SV("{}"), std::chrono::month_day{std::chrono::month{2}, std::chrono::day{31}});45  check(SV("*Feb/31*"), SV("{:*^8}"), std::chrono::month_day{std::chrono::month{2}, std::chrono::day{31}});46  check(SV("*Feb/31"), SV("{:*>7}"), std::chrono::month_day{std::chrono::month{2}, std::chrono::day{31}});47 48  // Invalid month "valid" day49  check(SV("0 is not a valid month/31"), SV("{}"), std::chrono::month_day{std::chrono::month{0}, std::chrono::day{31}});50  check(SV("*0 is not a valid month/31*"),51        SV("{:*^27}"),52        std::chrono::month_day{std::chrono::month{0}, std::chrono::day{31}});53 54  // Valid month invalid day55  check(SV("Feb/32 is not a valid day"), SV("{}"), std::chrono::month_day{std::chrono::month{2}, std::chrono::day{32}});56  check(SV("*Feb/32 is not a valid day*"),57        SV("{:*^27}"),58        std::chrono::month_day{std::chrono::month{2}, std::chrono::day{32}});59  check(SV("*Feb/32 is not a valid day"),60        SV("{:*>26}"),61        std::chrono::month_day{std::chrono::month{2}, std::chrono::day{32}});62 63  // Invalid month invalid day64  check(SV("0 is not a valid month/32 is not a valid day"),65        SV("{}"),66        std::chrono::month_day{std::chrono::month{0}, std::chrono::day{32}});67  check(SV("*0 is not a valid month/32 is not a valid day*"),68        SV("{:*^46}"),69        std::chrono::month_day{std::chrono::month{0}, std::chrono::day{32}});70}71 72template <class CharT>73static void test_valid_values() {74  // Test that %b, %h, and %B throw an exception.75  check_exception("Formatting a month name from an invalid month number",76                  SV("{:%b}"),77                  std::chrono::month_day{std::chrono::month{200}, std::chrono::day{31}});78  check_exception("Formatting a month name from an invalid month number",79                  SV("{:%b}"),80                  std::chrono::month_day{std::chrono::month{13}, std::chrono::day{31}});81  check_exception("Formatting a month name from an invalid month number",82                  SV("{:%b}"),83                  std::chrono::month_day{std::chrono::month{255}, std::chrono::day{31}});84 85  check_exception("Formatting a month name from an invalid month number",86                  SV("{:%h}"),87                  std::chrono::month_day{std::chrono::month{0}, std::chrono::day{31}});88  check_exception("Formatting a month name from an invalid month number",89                  SV("{:%h}"),90                  std::chrono::month_day{std::chrono::month{13}, std::chrono::day{31}});91  check_exception("Formatting a month name from an invalid month number",92                  SV("{:%h}"),93                  std::chrono::month_day{std::chrono::month{255}, std::chrono::day{31}});94 95  check_exception("Formatting a month name from an invalid month number",96                  SV("{:%B}"),97                  std::chrono::month_day{std::chrono::month{0}, std::chrono::day{31}});98  check_exception("Formatting a month name from an invalid month number",99                  SV("{:%B}"),100                  std::chrono::month_day{std::chrono::month{13}, std::chrono::day{31}});101  check_exception("Formatting a month name from an invalid month number",102                  SV("{:%B}"),103                  std::chrono::month_day{std::chrono::month{255}, std::chrono::day{31}});104 105  constexpr std::basic_string_view<CharT> fmt =106      SV("{:%%b='%b'%t%%B='%B'%t%%h='%h'%t%%m='%m'%t%%Om='%Om'%t%%d='%d'%t%%e='%e'%t%%Od='%Od'%t%%Oe='%Oe'%n}");107  constexpr std::basic_string_view<CharT> lfmt =108      SV("{:L%%b='%b'%t%%B='%B'%t%%h='%h'%t%%m='%m'%t%%Om='%Om'%t%%d='%d'%t%%e='%e'%t%%Od='%Od'%t%%Oe='%Oe'%n}");109 110  const std::locale loc(LOCALE_ja_JP_UTF_8);111  std::locale::global(std::locale(LOCALE_fr_FR_UTF_8));112 113  // Non localized output using C-locale114#ifdef _WIN32115  check(SV("%b='Jan'\t%B='January'\t%h='Jan'\t%m='01'\t%Om='01'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"),116        fmt,117        std::chrono::month_day{std::chrono::January, std::chrono::day{0}});118#else119  check(SV("%b='Jan'\t%B='January'\t%h='Jan'\t%m='01'\t%Om='01'\t%d='00'\t%e=' 0'\t%Od='00'\t%Oe=' 0'\n"),120        fmt,121        std::chrono::month_day{std::chrono::January, std::chrono::day{0}});122#endif123  check(SV("%b='Feb'\t%B='February'\t%h='Feb'\t%m='02'\t%Om='02'\t%d='01'\t%e=' 1'\t%Od='01'\t%Oe=' 1'\n"),124        fmt,125        std::chrono::month_day{std::chrono::February, std::chrono::day{1}});126  check(SV("%b='Mar'\t%B='March'\t%h='Mar'\t%m='03'\t%Om='03'\t%d='09'\t%e=' 9'\t%Od='09'\t%Oe=' 9'\n"),127        fmt,128        std::chrono::month_day{std::chrono::March, std::chrono::day{9}});129  check(SV("%b='Apr'\t%B='April'\t%h='Apr'\t%m='04'\t%Om='04'\t%d='10'\t%e='10'\t%Od='10'\t%Oe='10'\n"),130        fmt,131        std::chrono::month_day{std::chrono::April, std::chrono::day{10}});132  check(SV("%b='May'\t%B='May'\t%h='May'\t%m='05'\t%Om='05'\t%d='28'\t%e='28'\t%Od='28'\t%Oe='28'\n"),133        fmt,134        std::chrono::month_day{std::chrono::May, std::chrono::day{28}});135  check(SV("%b='Jun'\t%B='June'\t%h='Jun'\t%m='06'\t%Om='06'\t%d='29'\t%e='29'\t%Od='29'\t%Oe='29'\n"),136        fmt,137        std::chrono::month_day{std::chrono::June, std::chrono::day{29}});138  check(SV("%b='Jul'\t%B='July'\t%h='Jul'\t%m='07'\t%Om='07'\t%d='30'\t%e='30'\t%Od='30'\t%Oe='30'\n"),139        fmt,140        std::chrono::month_day{std::chrono::July, std::chrono::day{30}});141  check(SV("%b='Aug'\t%B='August'\t%h='Aug'\t%m='08'\t%Om='08'\t%d='31'\t%e='31'\t%Od='31'\t%Oe='31'\n"),142        fmt,143        std::chrono::month_day{std::chrono::August, std::chrono::day{31}});144#ifdef _WIN32145  check(SV("%b='Sep'\t%B='September'\t%h='Sep'\t%m='09'\t%Om='09'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"),146        fmt,147        std::chrono::month_day{std::chrono::September, std::chrono::day{32}});148  check(SV("%b='Oct'\t%B='October'\t%h='Oct'\t%m='10'\t%Om='10'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"),149        fmt,150        std::chrono::month_day{std::chrono::October, std::chrono::day{99}});151  check(SV("%b='Nov'\t%B='November'\t%h='Nov'\t%m='11'\t%Om='11'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"),152        fmt,153        std::chrono::month_day{std::chrono::November, std::chrono::day{100}});154  check(SV("%b='Dec'\t%B='December'\t%h='Dec'\t%m='12'\t%Om='12'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"),155        fmt,156        std::chrono::month_day{std::chrono::December, std::chrono::day{255}});157#else // _WIN32158  check(SV("%b='Sep'\t%B='September'\t%h='Sep'\t%m='09'\t%Om='09'\t%d='32'\t%e='32'\t%Od='32'\t%Oe='32'\n"),159        fmt,160        std::chrono::month_day{std::chrono::September, std::chrono::day{32}});161  check(SV("%b='Oct'\t%B='October'\t%h='Oct'\t%m='10'\t%Om='10'\t%d='99'\t%e='99'\t%Od='99'\t%Oe='99'\n"),162        fmt,163        std::chrono::month_day{std::chrono::October, std::chrono::day{99}});164#  if defined(_AIX)165  check(SV("%b='Nov'\t%B='November'\t%h='Nov'\t%m='11'\t%Om='11'\t%d='00'\t%e=' 0'\t%Od='00'\t%Oe=' 0'\n"),166        fmt,167        std::chrono::month_day{std::chrono::November, std::chrono::day{100}});168  check(SV("%b='Dec'\t%B='December'\t%h='Dec'\t%m='12'\t%Om='12'\t%d='55'\t%e='55'\t%Od='55'\t%Oe='55'\n"),169        fmt,170        std::chrono::month_day{std::chrono::December, std::chrono::day{255}});171#  else  //  defined(_AIX)172  check(SV("%b='Nov'\t%B='November'\t%h='Nov'\t%m='11'\t%Om='11'\t%d='100'\t%e='100'\t%Od='100'\t%Oe='100'\n"),173        fmt,174        std::chrono::month_day{std::chrono::November, std::chrono::day{100}});175  check(SV("%b='Dec'\t%B='December'\t%h='Dec'\t%m='12'\t%Om='12'\t%d='255'\t%e='255'\t%Od='255'\t%Oe='255'\n"),176        fmt,177        std::chrono::month_day{std::chrono::December, std::chrono::day{255}});178#  endif //  defined(_AIX)179#endif   // _WIN32180 181  // Use the global locale (fr_FR)182#if defined(__APPLE__)183  check(SV("%b='jan'\t%B='janvier'\t%h='jan'\t%m='01'\t%Om='01'\t%d='00'\t%e=' 0'\t%Od='00'\t%Oe=' 0'\n"),184        lfmt,185        std::chrono::month_day{std::chrono::January, std::chrono::day{0}});186  check(SV("%b='fév'\t%B='février'\t%h='fév'\t%m='02'\t%Om='02'\t%d='01'\t%e=' 1'\t%Od='01'\t%Oe=' 1'\n"),187        lfmt,188        std::chrono::month_day{std::chrono::February, std::chrono::day{1}});189  check(SV("%b='mar'\t%B='mars'\t%h='mar'\t%m='03'\t%Om='03'\t%d='09'\t%e=' 9'\t%Od='09'\t%Oe=' 9'\n"),190        lfmt,191        std::chrono::month_day{std::chrono::March, std::chrono::day{9}});192  check(SV("%b='avr'\t%B='avril'\t%h='avr'\t%m='04'\t%Om='04'\t%d='10'\t%e='10'\t%Od='10'\t%Oe='10'\n"),193        lfmt,194        std::chrono::month_day{std::chrono::April, std::chrono::day{10}});195  check(SV("%b='mai'\t%B='mai'\t%h='mai'\t%m='05'\t%Om='05'\t%d='28'\t%e='28'\t%Od='28'\t%Oe='28'\n"),196        lfmt,197        std::chrono::month_day{std::chrono::May, std::chrono::day{28}});198  check(SV("%b='jui'\t%B='juin'\t%h='jui'\t%m='06'\t%Om='06'\t%d='29'\t%e='29'\t%Od='29'\t%Oe='29'\n"),199        lfmt,200        std::chrono::month_day{std::chrono::June, std::chrono::day{29}});201  check(SV("%b='jul'\t%B='juillet'\t%h='jul'\t%m='07'\t%Om='07'\t%d='30'\t%e='30'\t%Od='30'\t%Oe='30'\n"),202        lfmt,203        std::chrono::month_day{std::chrono::July, std::chrono::day{30}});204  check(SV("%b='aoû'\t%B='août'\t%h='aoû'\t%m='08'\t%Om='08'\t%d='31'\t%e='31'\t%Od='31'\t%Oe='31'\n"),205        lfmt,206        std::chrono::month_day{std::chrono::August, std::chrono::day{31}});207  check(SV("%b='sep'\t%B='septembre'\t%h='sep'\t%m='09'\t%Om='09'\t%d='32'\t%e='32'\t%Od='32'\t%Oe='32'\n"),208        lfmt,209        std::chrono::month_day{std::chrono::September, std::chrono::day{32}});210  check(SV("%b='oct'\t%B='octobre'\t%h='oct'\t%m='10'\t%Om='10'\t%d='99'\t%e='99'\t%Od='99'\t%Oe='99'\n"),211        lfmt,212        std::chrono::month_day{std::chrono::October, std::chrono::day{99}});213  check(SV("%b='nov'\t%B='novembre'\t%h='nov'\t%m='11'\t%Om='11'\t%d='100'\t%e='100'\t%Od='100'\t%Oe='100'\n"),214        lfmt,215        std::chrono::month_day{std::chrono::November, std::chrono::day{100}});216  check(SV("%b='déc'\t%B='décembre'\t%h='déc'\t%m='12'\t%Om='12'\t%d='255'\t%e='255'\t%Od='255'\t%Oe='255'\n"),217        lfmt,218        std::chrono::month_day{std::chrono::December, std::chrono::day{255}});219#else // defined(__APPLE__)220#  if defined(_WIN32)221  check(SV("%b='janv.'\t%B='janvier'\t%h='janv.'\t%m='01'\t%Om='01'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"),222        lfmt,223        std::chrono::month_day{std::chrono::January, std::chrono::day{0}});224#  else225  check(SV("%b='janv.'\t%B='janvier'\t%h='janv.'\t%m='01'\t%Om='01'\t%d='00'\t%e=' 0'\t%Od='00'\t%Oe=' 0'\n"),226        lfmt,227        std::chrono::month_day{std::chrono::January, std::chrono::day{0}});228#  endif229  check(SV("%b='févr.'\t%B='février'\t%h='févr.'\t%m='02'\t%Om='02'\t%d='01'\t%e=' 1'\t%Od='01'\t%Oe=' 1'\n"),230        lfmt,231        std::chrono::month_day{std::chrono::February, std::chrono::day{1}});232  check(SV("%b='mars'\t%B='mars'\t%h='mars'\t%m='03'\t%Om='03'\t%d='09'\t%e=' 9'\t%Od='09'\t%Oe=' 9'\n"),233        lfmt,234        std::chrono::month_day{std::chrono::March, std::chrono::day{9}});235  check(236#  if defined(_WIN32) || defined(_AIX) || defined(__FreeBSD__)237      SV("%b='avr.'\t%B='avril'\t%h='avr.'\t%m='04'\t%Om='04'\t%d='10'\t%e='10'\t%Od='10'\t%Oe='10'\n"),238#  else  // defined(_WIN32) || defined(_AIX) || defined(__FreeBSD__)239      SV("%b='avril'\t%B='avril'\t%h='avril'\t%m='04'\t%Om='04'\t%d='10'\t%e='10'\t%Od='10'\t%Oe='10'\n"),240#  endif // defined(_WIN32) || defined(_AIX) || defined(__FreeBSD__)241      lfmt,242      std::chrono::month_day{std::chrono::April, std::chrono::day{10}});243  check(SV("%b='mai'\t%B='mai'\t%h='mai'\t%m='05'\t%Om='05'\t%d='28'\t%e='28'\t%Od='28'\t%Oe='28'\n"),244        lfmt,245        std::chrono::month_day{std::chrono::May, std::chrono::day{28}});246  check(SV("%b='juin'\t%B='juin'\t%h='juin'\t%m='06'\t%Om='06'\t%d='29'\t%e='29'\t%Od='29'\t%Oe='29'\n"),247        lfmt,248        std::chrono::month_day{std::chrono::June, std::chrono::day{29}});249  check(SV("%b='juil.'\t%B='juillet'\t%h='juil.'\t%m='07'\t%Om='07'\t%d='30'\t%e='30'\t%Od='30'\t%Oe='30'\n"),250        lfmt,251        std::chrono::month_day{std::chrono::July, std::chrono::day{30}});252  check(SV("%b='août'\t%B='août'\t%h='août'\t%m='08'\t%Om='08'\t%d='31'\t%e='31'\t%Od='31'\t%Oe='31'\n"),253        lfmt,254        std::chrono::month_day{std::chrono::August, std::chrono::day{31}});255#  if defined(_WIN32)256  check(SV("%b='sept.'\t%B='septembre'\t%h='sept.'\t%m='09'\t%Om='09'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"),257        lfmt,258        std::chrono::month_day{std::chrono::September, std::chrono::day{32}});259  check(SV("%b='oct.'\t%B='octobre'\t%h='oct.'\t%m='10'\t%Om='10'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"),260        lfmt,261        std::chrono::month_day{std::chrono::October, std::chrono::day{99}});262  check(SV("%b='nov.'\t%B='novembre'\t%h='nov.'\t%m='11'\t%Om='11'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"),263        lfmt,264        std::chrono::month_day{std::chrono::November, std::chrono::day{100}});265  check(SV("%b='déc.'\t%B='décembre'\t%h='déc.'\t%m='12'\t%Om='12'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"),266        lfmt,267        std::chrono::month_day{std::chrono::December, std::chrono::day{255}});268#  else // defined(_WIN32)269  check(SV("%b='sept.'\t%B='septembre'\t%h='sept.'\t%m='09'\t%Om='09'\t%d='32'\t%e='32'\t%Od='32'\t%Oe='32'\n"),270        lfmt,271        std::chrono::month_day{std::chrono::September, std::chrono::day{32}});272  check(SV("%b='oct.'\t%B='octobre'\t%h='oct.'\t%m='10'\t%Om='10'\t%d='99'\t%e='99'\t%Od='99'\t%Oe='99'\n"),273        lfmt,274        std::chrono::month_day{std::chrono::October, std::chrono::day{99}});275#    if defined(_AIX)276  check(SV("%b='nov.'\t%B='novembre'\t%h='nov.'\t%m='11'\t%Om='11'\t%d='00'\t%e=' 0'\t%Od='00'\t%Oe=' 0'\n"),277        lfmt,278        std::chrono::month_day{std::chrono::November, std::chrono::day{100}});279  check(SV("%b='déc.'\t%B='décembre'\t%h='déc.'\t%m='12'\t%Om='12'\t%d='55'\t%e='55'\t%Od='55'\t%Oe='55'\n"),280        lfmt,281        std::chrono::month_day{std::chrono::December, std::chrono::day{255}});282#    else  //   defined(_AIX)283  check(SV("%b='nov.'\t%B='novembre'\t%h='nov.'\t%m='11'\t%Om='11'\t%d='100'\t%e='100'\t%Od='100'\t%Oe='100'\n"),284        lfmt,285        std::chrono::month_day{std::chrono::November, std::chrono::day{100}});286  check(SV("%b='déc.'\t%B='décembre'\t%h='déc.'\t%m='12'\t%Om='12'\t%d='255'\t%e='255'\t%Od='255'\t%Oe='255'\n"),287        lfmt,288        std::chrono::month_day{std::chrono::December, std::chrono::day{255}});289#    endif //   defined(_AIX)290#  endif   //   defined(_WIN32)291#endif     // defined(__APPLE__)292 293  // Use supplied locale (ja_JP)294#if defined(_WIN32)295  check(loc,296        SV("%b='1'\t%B='1月'\t%h='1'\t%m='01'\t%Om='01'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"),297        lfmt,298        std::chrono::month_day{std::chrono::January, std::chrono::day{0}});299  check(loc,300        SV("%b='2'\t%B='2月'\t%h='2'\t%m='02'\t%Om='02'\t%d='01'\t%e=' 1'\t%Od='01'\t%Oe=' 1'\n"),301        lfmt,302        std::chrono::month_day{std::chrono::February, std::chrono::day{1}});303  check(loc,304        SV("%b='3'\t%B='3月'\t%h='3'\t%m='03'\t%Om='03'\t%d='09'\t%e=' 9'\t%Od='09'\t%Oe=' 9'\n"),305        lfmt,306        std::chrono::month_day{std::chrono::March, std::chrono::day{9}});307  check(loc,308        SV("%b='4'\t%B='4月'\t%h='4'\t%m='04'\t%Om='04'\t%d='10'\t%e='10'\t%Od='10'\t%Oe='10'\n"),309        lfmt,310        std::chrono::month_day{std::chrono::April, std::chrono::day{10}});311  check(loc,312        SV("%b='5'\t%B='5月'\t%h='5'\t%m='05'\t%Om='05'\t%d='28'\t%e='28'\t%Od='28'\t%Oe='28'\n"),313        lfmt,314        std::chrono::month_day{std::chrono::May, std::chrono::day{28}});315  check(loc,316        SV("%b='6'\t%B='6月'\t%h='6'\t%m='06'\t%Om='06'\t%d='29'\t%e='29'\t%Od='29'\t%Oe='29'\n"),317        lfmt,318        std::chrono::month_day{std::chrono::June, std::chrono::day{29}});319  check(loc,320        SV("%b='7'\t%B='7月'\t%h='7'\t%m='07'\t%Om='07'\t%d='30'\t%e='30'\t%Od='30'\t%Oe='30'\n"),321        lfmt,322        std::chrono::month_day{std::chrono::July, std::chrono::day{30}});323  check(loc,324        SV("%b='8'\t%B='8月'\t%h='8'\t%m='08'\t%Om='08'\t%d='31'\t%e='31'\t%Od='31'\t%Oe='31'\n"),325        lfmt,326        std::chrono::month_day{std::chrono::August, std::chrono::day{31}});327  check(loc,328        SV("%b='9'\t%B='9月'\t%h='9'\t%m='09'\t%Om='09'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"),329        lfmt,330        std::chrono::month_day{std::chrono::September, std::chrono::day{32}});331  check(loc,332        SV("%b='10'\t%B='10月'\t%h='10'\t%m='10'\t%Om='10'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"),333        lfmt,334        std::chrono::month_day{std::chrono::October, std::chrono::day{99}});335  check(loc,336        SV("%b='11'\t%B='11月'\t%h='11'\t%m='11'\t%Om='11'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"),337        lfmt,338        std::chrono::month_day{std::chrono::November, std::chrono::day{100}});339  check(loc,340        SV("%b='12'\t%B='12月'\t%h='12'\t%m='12'\t%Om='12'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"),341        lfmt,342        std::chrono::month_day{std::chrono::December, std::chrono::day{255}});343#elif defined(_AIX)      // defined(_WIN32)344  check(loc,345        SV("%b='1月'\t%B='1月'\t%h='1月'\t%m='01'\t%Om='01'\t%d='00'\t%e=' 0'\t%Od='00'\t%Oe=' 0'\n"),346        lfmt,347        std::chrono::month_day{std::chrono::January, std::chrono::day{0}});348  check(loc,349        SV("%b='2月'\t%B='2月'\t%h='2月'\t%m='02'\t%Om='02'\t%d='01'\t%e=' 1'\t%Od='01'\t%Oe=' 1'\n"),350        lfmt,351        std::chrono::month_day{std::chrono::February, std::chrono::day{1}});352  check(loc,353        SV("%b='3月'\t%B='3月'\t%h='3月'\t%m='03'\t%Om='03'\t%d='09'\t%e=' 9'\t%Od='09'\t%Oe=' 9'\n"),354        lfmt,355        std::chrono::month_day{std::chrono::March, std::chrono::day{9}});356  check(loc,357        SV("%b='4月'\t%B='4月'\t%h='4月'\t%m='04'\t%Om='04'\t%d='10'\t%e='10'\t%Od='10'\t%Oe='10'\n"),358        lfmt,359        std::chrono::month_day{std::chrono::April, std::chrono::day{10}});360  check(loc,361        SV("%b='5月'\t%B='5月'\t%h='5月'\t%m='05'\t%Om='05'\t%d='28'\t%e='28'\t%Od='28'\t%Oe='28'\n"),362        lfmt,363        std::chrono::month_day{std::chrono::May, std::chrono::day{28}});364  check(loc,365        SV("%b='6月'\t%B='6月'\t%h='6月'\t%m='06'\t%Om='06'\t%d='29'\t%e='29'\t%Od='29'\t%Oe='29'\n"),366        lfmt,367        std::chrono::month_day{std::chrono::June, std::chrono::day{29}});368  check(loc,369        SV("%b='7月'\t%B='7月'\t%h='7月'\t%m='07'\t%Om='07'\t%d='30'\t%e='30'\t%Od='30'\t%Oe='30'\n"),370        lfmt,371        std::chrono::month_day{std::chrono::July, std::chrono::day{30}});372  check(loc,373        SV("%b='8月'\t%B='8月'\t%h='8月'\t%m='08'\t%Om='08'\t%d='31'\t%e='31'\t%Od='31'\t%Oe='31'\n"),374        lfmt,375        std::chrono::month_day{std::chrono::August, std::chrono::day{31}});376  check(loc,377        SV("%b='9月'\t%B='9月'\t%h='9月'\t%m='09'\t%Om='09'\t%d='32'\t%e='32'\t%Od='32'\t%Oe='32'\n"),378        lfmt,379        std::chrono::month_day{std::chrono::September, std::chrono::day{32}});380  check(loc,381        SV("%b='10月'\t%B='10月'\t%h='10月'\t%m='10'\t%Om='10'\t%d='99'\t%e='99'\t%Od='99'\t%Oe='99'\n"),382        lfmt,383        std::chrono::month_day{std::chrono::October, std::chrono::day{99}});384  check(loc,385        SV("%b='11月'\t%B='11月'\t%h='11月'\t%m='11'\t%Om='11'\t%d='00'\t%e=' 0'\t%Od='00'\t%Oe=' 0'\n"),386        lfmt,387        std::chrono::month_day{std::chrono::November, std::chrono::day{100}});388  check(loc,389        SV("%b='12月'\t%B='12月'\t%h='12月'\t%m='12'\t%Om='12'\t%d='55'\t%e='55'\t%Od='55'\t%Oe='55'\n"),390        lfmt,391        std::chrono::month_day{std::chrono::December, std::chrono::day{255}});392#elif defined(__FreeBSD__) // defined(_WIN32)393  check(loc,394        SV("%b=' 1月'\t%B='1月'\t%h=' 1月'\t%m='01'\t%Om='01'\t%d='00'\t%e=' 0'\t%Od='00'\t%Oe=' 0'\n"),395        lfmt,396        std::chrono::month_day{std::chrono::January, std::chrono::day{0}});397  check(loc,398        SV("%b=' 2月'\t%B='2月'\t%h=' 2月'\t%m='02'\t%Om='02'\t%d='01'\t%e=' 1'\t%Od='01'\t%Oe=' 1'\n"),399        lfmt,400        std::chrono::month_day{std::chrono::February, std::chrono::day{1}});401  check(loc,402        SV("%b=' 3月'\t%B='3月'\t%h=' 3月'\t%m='03'\t%Om='03'\t%d='09'\t%e=' 9'\t%Od='09'\t%Oe=' 9'\n"),403        lfmt,404        std::chrono::month_day{std::chrono::March, std::chrono::day{9}});405  check(loc,406        SV("%b=' 4月'\t%B='4月'\t%h=' 4月'\t%m='04'\t%Om='04'\t%d='10'\t%e='10'\t%Od='10'\t%Oe='10'\n"),407        lfmt,408        std::chrono::month_day{std::chrono::April, std::chrono::day{10}});409  check(loc,410        SV("%b=' 5月'\t%B='5月'\t%h=' 5月'\t%m='05'\t%Om='05'\t%d='28'\t%e='28'\t%Od='28'\t%Oe='28'\n"),411        lfmt,412        std::chrono::month_day{std::chrono::May, std::chrono::day{28}});413  check(loc,414        SV("%b=' 6月'\t%B='6月'\t%h=' 6月'\t%m='06'\t%Om='06'\t%d='29'\t%e='29'\t%Od='29'\t%Oe='29'\n"),415        lfmt,416        std::chrono::month_day{std::chrono::June, std::chrono::day{29}});417  check(loc,418        SV("%b=' 7月'\t%B='7月'\t%h=' 7月'\t%m='07'\t%Om='07'\t%d='30'\t%e='30'\t%Od='30'\t%Oe='30'\n"),419        lfmt,420        std::chrono::month_day{std::chrono::July, std::chrono::day{30}});421  check(loc,422        SV("%b=' 8月'\t%B='8月'\t%h=' 8月'\t%m='08'\t%Om='08'\t%d='31'\t%e='31'\t%Od='31'\t%Oe='31'\n"),423        lfmt,424        std::chrono::month_day{std::chrono::August, std::chrono::day{31}});425  check(loc,426        SV("%b=' 9月'\t%B='9月'\t%h=' 9月'\t%m='09'\t%Om='09'\t%d='32'\t%e='32'\t%Od='32'\t%Oe='32'\n"),427        lfmt,428        std::chrono::month_day{std::chrono::September, std::chrono::day{32}});429  check(loc,430        SV("%b='10月'\t%B='10月'\t%h='10月'\t%m='10'\t%Om='10'\t%d='99'\t%e='99'\t%Od='99'\t%Oe='99'\n"),431        lfmt,432        std::chrono::month_day{std::chrono::October, std::chrono::day{99}});433  check(loc,434        SV("%b='11月'\t%B='11月'\t%h='11月'\t%m='11'\t%Om='11'\t%d='100'\t%e='100'\t%Od='100'\t%Oe='100'\n"),435        lfmt,436        std::chrono::month_day{std::chrono::November, std::chrono::day{100}});437  check(loc,438        SV("%b='12月'\t%B='12月'\t%h='12月'\t%m='12'\t%Om='12'\t%d='255'\t%e='255'\t%Od='255'\t%Oe='255'\n"),439        lfmt,440        std::chrono::month_day{std::chrono::December, std::chrono::day{255}});441#elif defined(__APPLE__) // defined(_WIN32)442  check(loc,443        SV("%b=' 1'\t%B='1月'\t%h=' 1'\t%m='01'\t%Om='01'\t%d='00'\t%e=' 0'\t%Od='00'\t%Oe=' 0'\n"),444        lfmt,445        std::chrono::month_day{std::chrono::January, std::chrono::day{0}});446  check(loc,447        SV("%b=' 2'\t%B='2月'\t%h=' 2'\t%m='02'\t%Om='02'\t%d='01'\t%e=' 1'\t%Od='01'\t%Oe=' 1'\n"),448        lfmt,449        std::chrono::month_day{std::chrono::February, std::chrono::day{1}});450  check(loc,451        SV("%b=' 3'\t%B='3月'\t%h=' 3'\t%m='03'\t%Om='03'\t%d='09'\t%e=' 9'\t%Od='09'\t%Oe=' 9'\n"),452        lfmt,453        std::chrono::month_day{std::chrono::March, std::chrono::day{9}});454  check(loc,455        SV("%b=' 4'\t%B='4月'\t%h=' 4'\t%m='04'\t%Om='04'\t%d='10'\t%e='10'\t%Od='10'\t%Oe='10'\n"),456        lfmt,457        std::chrono::month_day{std::chrono::April, std::chrono::day{10}});458  check(loc,459        SV("%b=' 5'\t%B='5月'\t%h=' 5'\t%m='05'\t%Om='05'\t%d='28'\t%e='28'\t%Od='28'\t%Oe='28'\n"),460        lfmt,461        std::chrono::month_day{std::chrono::May, std::chrono::day{28}});462  check(loc,463        SV("%b=' 6'\t%B='6月'\t%h=' 6'\t%m='06'\t%Om='06'\t%d='29'\t%e='29'\t%Od='29'\t%Oe='29'\n"),464        lfmt,465        std::chrono::month_day{std::chrono::June, std::chrono::day{29}});466  check(loc,467        SV("%b=' 7'\t%B='7月'\t%h=' 7'\t%m='07'\t%Om='07'\t%d='30'\t%e='30'\t%Od='30'\t%Oe='30'\n"),468        lfmt,469        std::chrono::month_day{std::chrono::July, std::chrono::day{30}});470  check(loc,471        SV("%b=' 8'\t%B='8月'\t%h=' 8'\t%m='08'\t%Om='08'\t%d='31'\t%e='31'\t%Od='31'\t%Oe='31'\n"),472        lfmt,473        std::chrono::month_day{std::chrono::August, std::chrono::day{31}});474  check(loc,475        SV("%b=' 9'\t%B='9月'\t%h=' 9'\t%m='09'\t%Om='09'\t%d='32'\t%e='32'\t%Od='32'\t%Oe='32'\n"),476        lfmt,477        std::chrono::month_day{std::chrono::September, std::chrono::day{32}});478  check(loc,479        SV("%b='10'\t%B='10月'\t%h='10'\t%m='10'\t%Om='10'\t%d='99'\t%e='99'\t%Od='99'\t%Oe='99'\n"),480        lfmt,481        std::chrono::month_day{std::chrono::October, std::chrono::day{99}});482  check(loc,483        SV("%b='11'\t%B='11月'\t%h='11'\t%m='11'\t%Om='11'\t%d='100'\t%e='100'\t%Od='100'\t%Oe='100'\n"),484        lfmt,485        std::chrono::month_day{std::chrono::November, std::chrono::day{100}});486  check(loc,487        SV("%b='12'\t%B='12月'\t%h='12'\t%m='12'\t%Om='12'\t%d='255'\t%e='255'\t%Od='255'\t%Oe='255'\n"),488        lfmt,489        std::chrono::month_day{std::chrono::December, std::chrono::day{255}});490#else                    // defined(_WIN32)491  check(loc,492        SV("%b=' 1月'\t%B='1月'\t%h=' 1月'\t%m='01'\t%Om='一'\t%d='00'\t%e=' 0'\t%Od='〇'\t%Oe='〇'\n"),493        lfmt,494        std::chrono::month_day{std::chrono::January, std::chrono::day{0}});495  check(loc,496        SV("%b=' 2月'\t%B='2月'\t%h=' 2月'\t%m='02'\t%Om='二'\t%d='01'\t%e=' 1'\t%Od='一'\t%Oe='一'\n"),497        lfmt,498        std::chrono::month_day{std::chrono::February, std::chrono::day{1}});499  check(loc,500        SV("%b=' 3月'\t%B='3月'\t%h=' 3月'\t%m='03'\t%Om='三'\t%d='09'\t%e=' 9'\t%Od='九'\t%Oe='九'\n"),501        lfmt,502        std::chrono::month_day{std::chrono::March, std::chrono::day{9}});503  check(loc,504        SV("%b=' 4月'\t%B='4月'\t%h=' 4月'\t%m='04'\t%Om='四'\t%d='10'\t%e='10'\t%Od='十'\t%Oe='十'\n"),505        lfmt,506        std::chrono::month_day{std::chrono::April, std::chrono::day{10}});507  check(loc,508        SV("%b=' 5月'\t%B='5月'\t%h=' 5月'\t%m='05'\t%Om='五'\t%d='28'\t%e='28'\t%Od='二十八'\t%Oe='二十八'\n"),509        lfmt,510        std::chrono::month_day{std::chrono::May, std::chrono::day{28}});511  check(loc,512        SV("%b=' 6月'\t%B='6月'\t%h=' 6月'\t%m='06'\t%Om='六'\t%d='29'\t%e='29'\t%Od='二十九'\t%Oe='二十九'\n"),513        lfmt,514        std::chrono::month_day{std::chrono::June, std::chrono::day{29}});515  check(loc,516        SV("%b=' 7月'\t%B='7月'\t%h=' 7月'\t%m='07'\t%Om='七'\t%d='30'\t%e='30'\t%Od='三十'\t%Oe='三十'\n"),517        lfmt,518        std::chrono::month_day{std::chrono::July, std::chrono::day{30}});519  check(loc,520        SV("%b=' 8月'\t%B='8月'\t%h=' 8月'\t%m='08'\t%Om='八'\t%d='31'\t%e='31'\t%Od='三十一'\t%Oe='三十一'\n"),521        lfmt,522        std::chrono::month_day{std::chrono::August, std::chrono::day{31}});523  check(loc,524        SV("%b=' 9月'\t%B='9月'\t%h=' 9月'\t%m='09'\t%Om='九'\t%d='32'\t%e='32'\t%Od='三十二'\t%Oe='三十二'\n"),525        lfmt,526        std::chrono::month_day{std::chrono::September, std::chrono::day{32}});527  check(loc,528        SV("%b='10月'\t%B='10月'\t%h='10月'\t%m='10'\t%Om='十'\t%d='99'\t%e='99'\t%Od='九十九'\t%Oe='九十九'\n"),529        lfmt,530        std::chrono::month_day{std::chrono::October, std::chrono::day{99}});531  check(loc,532        SV("%b='11月'\t%B='11月'\t%h='11月'\t%m='11'\t%Om='十一'\t%d='100'\t%e='100'\t%Od='100'\t%Oe='100'\n"),533        lfmt,534        std::chrono::month_day{std::chrono::November, std::chrono::day{100}});535  check(loc,536        SV("%b='12月'\t%B='12月'\t%h='12月'\t%m='12'\t%Om='十二'\t%d='255'\t%e='255'\t%Od='255'\t%Oe='255'\n"),537        lfmt,538        std::chrono::month_day{std::chrono::December, std::chrono::day{255}});539#endif                   //  defined(_WIN32)540 541  std::locale::global(std::locale::classic());542}543 544template <class CharT>545static void test() {546  test_no_chrono_specs<CharT>();547  test_valid_values<CharT>();548  check_invalid_types<CharT>({SV("b"), SV("B"), SV("d"), SV("e"), SV("h"), SV("m"), SV("Od"), SV("Oe"), SV("Om")},549                             std::chrono::month_day{std::chrono::January, std::chrono::day{31}});550 551  check_exception("The format specifier expects a '%' or a '}'",552                  SV("{:A"),553                  std::chrono::month_day{std::chrono::January, std::chrono::day{31}});554  check_exception("The chrono specifiers contain a '{'",555                  SV("{:%%{"),556                  std::chrono::month_day{std::chrono::January, std::chrono::day{31}});557  check_exception("End of input while parsing a conversion specifier",558                  SV("{:%"),559                  std::chrono::month_day{std::chrono::January, std::chrono::day{31}});560  check_exception("End of input while parsing the modifier E",561                  SV("{:%E"),562                  std::chrono::month_day{std::chrono::January, std::chrono::day{31}});563  check_exception("End of input while parsing the modifier O",564                  SV("{:%O"),565                  std::chrono::month_day{std::chrono::January, std::chrono::day{31}});566 567  // Precision not allowed568  check_exception("The format specifier expects a '%' or a '}'",569                  SV("{:.3}"),570                  std::chrono::month_day{std::chrono::January, std::chrono::day{31}});571}572 573int main(int, char**) {574  test<char>();575 576#ifndef TEST_HAS_NO_WIDE_CHARACTERS577  test<wchar_t>();578#endif579 580  return 0;581}582