Debian Codegraph @

libcxx/test/std/time/time.syn/formatter.month_day_last.pass.cpp

raw
1 //===----------------------------------------------------------------------===//
2 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3 // See https://llvm.org/LICENSE.txt for license information.
4 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 //
6 //===----------------------------------------------------------------------===//
7
8 // UNSUPPORTED: c++03, c++11, c++14, c++17
9 // UNSUPPORTED: no-localization
10 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
11
12 // TODO FMT This test should not require std::to_chars(floating-point)
13 // XFAIL: availability-fp_to_chars-missing
14
15 // REQUIRES: locale.fr_FR.UTF-8
16 // REQUIRES: locale.ja_JP.UTF-8
17
18 // <chrono>
19
20 // template<class charT> struct formatter<chrono::month_day_last, charT>;
21
22 #include <chrono>
23 #include <format>
24
25 #include <cassert>
26 #include <concepts>
27 #include <locale>
28 #include <iostream>
29 #include <type_traits>
30
31 #include "formatter_tests.h"
32 #include "make_string.h"
33 #include "platform_support.h" // locale name macros
34 #include "string_literal.h"
35 #include "test_macros.h"
36
37 template <class CharT>
38 static void test_no_chrono_specs() {
39 // Valid month
40 check(SV("Jan/last"), SV("{}"), std::chrono::month_day_last{std::chrono::month{1}});
41 check(SV("*Jan/last*"), SV("{:*^10}"), std::chrono::month_day_last{std::chrono::month{1}});
42 check(SV("*Jan/last"), SV("{:*>9}"), std::chrono::month_day_last{std::chrono::month{1}});
43
44 // Invalid month
45 check(SV("0 is not a valid month/last"), SV("{}"), std::chrono::month_day_last{std::chrono::month{0}});
46 check(SV("*0 is not a valid month/last*"), SV("{:*^29}"), std::chrono::month_day_last{std::chrono::month{0}});
47 }
48
49 template <class CharT>
50 static void test_valid_values() {
51 // Test that %b, %h, and %B throw an exception.
52 check_exception("Formatting a month name from an invalid month number",
53 SV("{:%b}"),
54 std::chrono::month_day_last{std::chrono::month{200}});
55 check_exception("Formatting a month name from an invalid month number",
56 SV("{:%b}"),
57 std::chrono::month_day_last{std::chrono::month{13}});
58 check_exception("Formatting a month name from an invalid month number",
59 SV("{:%b}"),
60 std::chrono::month_day_last{std::chrono::month{255}});
61
62 check_exception("Formatting a month name from an invalid month number",
63 SV("{:%h}"),
64 std::chrono::month_day_last{std::chrono::month{0}});
65 check_exception("Formatting a month name from an invalid month number",
66 SV("{:%h}"),
67 std::chrono::month_day_last{std::chrono::month{13}});
68 check_exception("Formatting a month name from an invalid month number",
69 SV("{:%h}"),
70 std::chrono::month_day_last{std::chrono::month{255}});
71
72 check_exception("Formatting a month name from an invalid month number",
73 SV("{:%B}"),
74 std::chrono::month_day_last{std::chrono::month{0}});
75 check_exception("Formatting a month name from an invalid month number",
76 SV("{:%B}"),
77 std::chrono::month_day_last{std::chrono::month{13}});
78 check_exception("Formatting a month name from an invalid month number",
79 SV("{:%B}"),
80 std::chrono::month_day_last{std::chrono::month{255}});
81
82 constexpr std::basic_string_view<CharT> fmt = SV("{:%%b='%b'%t%%B='%B'%t%%h='%h'%t%%m='%m'%t%%Om='%Om'%n}");
83 constexpr std::basic_string_view<CharT> lfmt = SV("{:L%%b='%b'%t%%B='%B'%t%%h='%h'%t%%m='%m'%t%%Om='%Om'%n}");
84
85 const std::locale loc(LOCALE_ja_JP_UTF_8);
86 std::locale::global(std::locale(LOCALE_fr_FR_UTF_8));
87
88 // Non localized output using C-locale
89 check(SV("%b='Jan'\t%B='January'\t%h='Jan'\t%m='01'\t%Om='01'\n"),
90 fmt,
91 std::chrono::month_day_last{std::chrono::January});
92 check(SV("%b='Feb'\t%B='February'\t%h='Feb'\t%m='02'\t%Om='02'\n"),
93 fmt,
94 std::chrono::month_day_last{std::chrono::February});
95 check(
96 SV("%b='Mar'\t%B='March'\t%h='Mar'\t%m='03'\t%Om='03'\n"), fmt, std::chrono::month_day_last{std::chrono::March});
97 check(
98 SV("%b='Apr'\t%B='April'\t%h='Apr'\t%m='04'\t%Om='04'\n"), fmt, std::chrono::month_day_last{std::chrono::April});
99 check(SV("%b='May'\t%B='May'\t%h='May'\t%m='05'\t%Om='05'\n"), fmt, std::chrono::month_day_last{std::chrono::May});
100 check(SV("%b='Jun'\t%B='June'\t%h='Jun'\t%m='06'\t%Om='06'\n"), fmt, std::chrono::month_day_last{std::chrono::June});
101 check(SV("%b='Jul'\t%B='July'\t%h='Jul'\t%m='07'\t%Om='07'\n"), fmt, std::chrono::month_day_last{std::chrono::July});
102 check(SV("%b='Aug'\t%B='August'\t%h='Aug'\t%m='08'\t%Om='08'\n"),
103 fmt,
104 std::chrono::month_day_last{std::chrono::August});
105 check(SV("%b='Sep'\t%B='September'\t%h='Sep'\t%m='09'\t%Om='09'\n"),
106 fmt,
107 std::chrono::month_day_last{std::chrono::September});
108 check(SV("%b='Oct'\t%B='October'\t%h='Oct'\t%m='10'\t%Om='10'\n"),
109 fmt,
110 std::chrono::month_day_last{std::chrono::October});
111 check(SV("%b='Nov'\t%B='November'\t%h='Nov'\t%m='11'\t%Om='11'\n"),
112 fmt,
113 std::chrono::month_day_last{std::chrono::November});
114 check(SV("%b='Dec'\t%B='December'\t%h='Dec'\t%m='12'\t%Om='12'\n"),
115 fmt,
116 std::chrono::month_day_last{std::chrono::December});
117
118 // Use the global locale (fr_FR)
119 #if defined(__APPLE__)
120 check(SV("%b='jan'\t%B='janvier'\t%h='jan'\t%m='01'\t%Om='01'\n"),
121 lfmt,
122 std::chrono::month_day_last{std::chrono::January});
123 check(SV("%b='fév'\t%B='février'\t%h='fév'\t%m='02'\t%Om='02'\n"),
124 lfmt,
125 std::chrono::month_day_last{std::chrono::February});
126 check(
127 SV("%b='mar'\t%B='mars'\t%h='mar'\t%m='03'\t%Om='03'\n"), lfmt, std::chrono::month_day_last{std::chrono::March});
128 check(
129 SV("%b='avr'\t%B='avril'\t%h='avr'\t%m='04'\t%Om='04'\n"), lfmt, std::chrono::month_day_last{std::chrono::April});
130 check(SV("%b='mai'\t%B='mai'\t%h='mai'\t%m='05'\t%Om='05'\n"), lfmt, std::chrono::month_day_last{std::chrono::May});
131 check(SV("%b='jui'\t%B='juin'\t%h='jui'\t%m='06'\t%Om='06'\n"), lfmt, std::chrono::month_day_last{std::chrono::June});
132 check(SV("%b='jul'\t%B='juillet'\t%h='jul'\t%m='07'\t%Om='07'\n"),
133 lfmt,
134 std::chrono::month_day_last{std::chrono::July});
135 check(
136 SV("%b='aoû'\t%B='août'\t%h='aoû'\t%m='08'\t%Om='08'\n"), lfmt, std::chrono::month_day_last{std::chrono::August});
137 check(SV("%b='sep'\t%B='septembre'\t%h='sep'\t%m='09'\t%Om='09'\n"),
138 lfmt,
139 std::chrono::month_day_last{std::chrono::September});
140 check(SV("%b='oct'\t%B='octobre'\t%h='oct'\t%m='10'\t%Om='10'\n"),
141 lfmt,
142 std::chrono::month_day_last{std::chrono::October});
143 check(SV("%b='nov'\t%B='novembre'\t%h='nov'\t%m='11'\t%Om='11'\n"),
144 lfmt,
145 std::chrono::month_day_last{std::chrono::November});
146 check(SV("%b='déc'\t%B='décembre'\t%h='déc'\t%m='12'\t%Om='12'\n"),
147 lfmt,
148 std::chrono::month_day_last{std::chrono::December});
149 #else // defined(__APPLE__)
150 check(SV("%b='janv.'\t%B='janvier'\t%h='janv.'\t%m='01'\t%Om='01'\n"),
151 lfmt,
152 std::chrono::month_day_last{std::chrono::January});
153 check(SV("%b='févr.'\t%B='février'\t%h='févr.'\t%m='02'\t%Om='02'\n"),
154 lfmt,
155 std::chrono::month_day_last{std::chrono::February});
156 check(SV("%b='mars'\t%B='mars'\t%h='mars'\t%m='03'\t%Om='03'\n"),
157 lfmt,
158 std::chrono::month_day_last{std::chrono::March});
159 check(
160 # if defined(_WIN32) || defined(_AIX) || defined(__FreeBSD__)
161 SV("%b='avr.'\t%B='avril'\t%h='avr.'\t%m='04'\t%Om='04'\n"),
162 # else // defined(_WIN32) || defined(_AIX) || defined(__FreeBSD__)
163 SV("%b='avril'\t%B='avril'\t%h='avril'\t%m='04'\t%Om='04'\n"),
164 # endif // defined(_WIN32) || defined(_AIX) || defined(__FreeBSD__)
165 lfmt,
166 std::chrono::month_day_last{std::chrono::April});
167 check(SV("%b='mai'\t%B='mai'\t%h='mai'\t%m='05'\t%Om='05'\n"), lfmt, std::chrono::month_day_last{std::chrono::May});
168 check(
169 SV("%b='juin'\t%B='juin'\t%h='juin'\t%m='06'\t%Om='06'\n"), lfmt, std::chrono::month_day_last{std::chrono::June});
170 check(SV("%b='juil.'\t%B='juillet'\t%h='juil.'\t%m='07'\t%Om='07'\n"),
171 lfmt,
172 std::chrono::month_day_last{std::chrono::July});
173 check(SV("%b='août'\t%B='août'\t%h='août'\t%m='08'\t%Om='08'\n"),
174 lfmt,
175 std::chrono::month_day_last{std::chrono::August});
176 check(SV("%b='sept.'\t%B='septembre'\t%h='sept.'\t%m='09'\t%Om='09'\n"),
177 lfmt,
178 std::chrono::month_day_last{std::chrono::September});
179 check(SV("%b='oct.'\t%B='octobre'\t%h='oct.'\t%m='10'\t%Om='10'\n"),
180 lfmt,
181 std::chrono::month_day_last{std::chrono::October});
182 check(SV("%b='nov.'\t%B='novembre'\t%h='nov.'\t%m='11'\t%Om='11'\n"),
183 lfmt,
184 std::chrono::month_day_last{std::chrono::November});
185 check(SV("%b='déc.'\t%B='décembre'\t%h='déc.'\t%m='12'\t%Om='12'\n"),
186 lfmt,
187 std::chrono::month_day_last{std::chrono::December});
188 #endif // defined(__APPLE__)
189
190 // Use supplied locale (ja_JP)
191 #ifdef _WIN32
192 check(loc,
193 SV("%b='1'\t%B='1月'\t%h='1'\t%m='01'\t%Om='01'\n"),
194 lfmt,
195 std::chrono::month_day_last{std::chrono::January});
196 check(loc,
197 SV("%b='2'\t%B='2月'\t%h='2'\t%m='02'\t%Om='02'\n"),
198 lfmt,
199 std::chrono::month_day_last{std::chrono::February});
200 check(
201 loc, SV("%b='3'\t%B='3月'\t%h='3'\t%m='03'\t%Om='03'\n"), lfmt, std::chrono::month_day_last{std::chrono::March});
202 check(
203 loc, SV("%b='4'\t%B='4月'\t%h='4'\t%m='04'\t%Om='04'\n"), lfmt, std::chrono::month_day_last{std::chrono::April});
204 check(loc, SV("%b='5'\t%B='5月'\t%h='5'\t%m='05'\t%Om='05'\n"), lfmt, std::chrono::month_day_last{std::chrono::May});
205 check(loc, SV("%b='6'\t%B='6月'\t%h='6'\t%m='06'\t%Om='06'\n"), lfmt, std::chrono::month_day_last{std::chrono::June});
206 check(loc, SV("%b='7'\t%B='7月'\t%h='7'\t%m='07'\t%Om='07'\n"), lfmt, std::chrono::month_day_last{std::chrono::July});
207 check(
208 loc, SV("%b='8'\t%B='8月'\t%h='8'\t%m='08'\t%Om='08'\n"), lfmt, std::chrono::month_day_last{std::chrono::August});
209 check(loc,
210 SV("%b='9'\t%B='9月'\t%h='9'\t%m='09'\t%Om='09'\n"),
211 lfmt,
212 std::chrono::month_day_last{std::chrono::September});
213 check(loc,
214 SV("%b='10'\t%B='10月'\t%h='10'\t%m='10'\t%Om='10'\n"),
215 lfmt,
216 std::chrono::month_day_last{std::chrono::October});
217 check(loc,
218 SV("%b='11'\t%B='11月'\t%h='11'\t%m='11'\t%Om='11'\n"),
219 lfmt,
220 std::chrono::month_day_last{std::chrono::November});
221 check(loc,
222 SV("%b='12'\t%B='12月'\t%h='12'\t%m='12'\t%Om='12'\n"),
223 lfmt,
224 std::chrono::month_day_last{std::chrono::December});
225 #elif defined(__APPLE__) // defined(_WIN32)
226 check(loc,
227 SV("%b=' 1'\t%B='1月'\t%h=' 1'\t%m='01'\t%Om='01'\n"),
228 lfmt,
229 std::chrono::month_day_last{std::chrono::January});
230 check(loc,
231 SV("%b=' 2'\t%B='2月'\t%h=' 2'\t%m='02'\t%Om='02'\n"),
232 lfmt,
233 std::chrono::month_day_last{std::chrono::February});
234 check(loc,
235 SV("%b=' 3'\t%B='3月'\t%h=' 3'\t%m='03'\t%Om='03'\n"),
236 lfmt,
237 std::chrono::month_day_last{std::chrono::March});
238 check(loc,
239 SV("%b=' 4'\t%B='4月'\t%h=' 4'\t%m='04'\t%Om='04'\n"),
240 lfmt,
241 std::chrono::month_day_last{std::chrono::April});
242 check(
243 loc, SV("%b=' 5'\t%B='5月'\t%h=' 5'\t%m='05'\t%Om='05'\n"), lfmt, std::chrono::month_day_last{std::chrono::May});
244 check(
245 loc, SV("%b=' 6'\t%B='6月'\t%h=' 6'\t%m='06'\t%Om='06'\n"), lfmt, std::chrono::month_day_last{std::chrono::June});
246 check(
247 loc, SV("%b=' 7'\t%B='7月'\t%h=' 7'\t%m='07'\t%Om='07'\n"), lfmt, std::chrono::month_day_last{std::chrono::July});
248 check(loc,
249 SV("%b=' 8'\t%B='8月'\t%h=' 8'\t%m='08'\t%Om='08'\n"),
250 lfmt,
251 std::chrono::month_day_last{std::chrono::August});
252 check(loc,
253 SV("%b=' 9'\t%B='9月'\t%h=' 9'\t%m='09'\t%Om='09'\n"),
254 lfmt,
255 std::chrono::month_day_last{std::chrono::September});
256 check(loc,
257 SV("%b='10'\t%B='10月'\t%h='10'\t%m='10'\t%Om='10'\n"),
258 lfmt,
259 std::chrono::month_day_last{std::chrono::October});
260 check(loc,
261 SV("%b='11'\t%B='11月'\t%h='11'\t%m='11'\t%Om='11'\n"),
262 lfmt,
263 std::chrono::month_day_last{std::chrono::November});
264 check(loc,
265 SV("%b='12'\t%B='12月'\t%h='12'\t%m='12'\t%Om='12'\n"),
266 lfmt,
267 std::chrono::month_day_last{std::chrono::December});
268 #elif defined(_AIX) // defined(_WIN32)
269 check(loc,
270 SV("%b='1月'\t%B='1月'\t%h='1月'\t%m='01'\t%Om='01'\n"),
271 lfmt,
272 std::chrono::month_day_last{std::chrono::January});
273 check(loc,
274 SV("%b='2月'\t%B='2月'\t%h='2月'\t%m='02'\t%Om='02'\n"),
275 lfmt,
276 std::chrono::month_day_last{std::chrono::February});
277 check(loc,
278 SV("%b='3月'\t%B='3月'\t%h='3月'\t%m='03'\t%Om='03'\n"),
279 lfmt,
280 std::chrono::month_day_last{std::chrono::March});
281 check(loc,
282 SV("%b='4月'\t%B='4月'\t%h='4月'\t%m='04'\t%Om='04'\n"),
283 lfmt,
284 std::chrono::month_day_last{std::chrono::April});
285 check(loc,
286 SV("%b='5月'\t%B='5月'\t%h='5月'\t%m='05'\t%Om='05'\n"),
287 lfmt,
288 std::chrono::month_day_last{std::chrono::May});
289 check(loc,
290 SV("%b='6月'\t%B='6月'\t%h='6月'\t%m='06'\t%Om='06'\n"),
291 lfmt,
292 std::chrono::month_day_last{std::chrono::June});
293 check(loc,
294 SV("%b='7月'\t%B='7月'\t%h='7月'\t%m='07'\t%Om='07'\n"),
295 lfmt,
296 std::chrono::month_day_last{std::chrono::July});
297 check(loc,
298 SV("%b='8月'\t%B='8月'\t%h='8月'\t%m='08'\t%Om='08'\n"),
299 lfmt,
300 std::chrono::month_day_last{std::chrono::August});
301 check(loc,
302 SV("%b='9月'\t%B='9月'\t%h='9月'\t%m='09'\t%Om='09'\n"),
303 lfmt,
304 std::chrono::month_day_last{std::chrono::September});
305 check(loc,
306 SV("%b='10月'\t%B='10月'\t%h='10月'\t%m='10'\t%Om='10'\n"),
307 lfmt,
308 std::chrono::month_day_last{std::chrono::October});
309 check(loc,
310 SV("%b='11月'\t%B='11月'\t%h='11月'\t%m='11'\t%Om='11'\n"),
311 lfmt,
312 std::chrono::month_day_last{std::chrono::November});
313 check(loc,
314 SV("%b='12月'\t%B='12月'\t%h='12月'\t%m='12'\t%Om='12'\n"),
315 lfmt,
316 std::chrono::month_day_last{std::chrono::December});
317 #elif defined(__FreeBSD__) // defined(_WIN32)
318 check(loc,
319 SV("%b=' 1月'\t%B='1月'\t%h=' 1月'\t%m='01'\t%Om='01'\n"),
320 lfmt,
321 std::chrono::month_day_last{std::chrono::January});
322 check(loc,
323 SV("%b=' 2月'\t%B='2月'\t%h=' 2月'\t%m='02'\t%Om='02'\n"),
324 lfmt,
325 std::chrono::month_day_last{std::chrono::February});
326 check(loc,
327 SV("%b=' 3月'\t%B='3月'\t%h=' 3月'\t%m='03'\t%Om='03'\n"),
328 lfmt,
329 std::chrono::month_day_last{std::chrono::March});
330 check(loc,
331 SV("%b=' 4月'\t%B='4月'\t%h=' 4月'\t%m='04'\t%Om='04'\n"),
332 lfmt,
333 std::chrono::month_day_last{std::chrono::April});
334 check(loc,
335 SV("%b=' 5月'\t%B='5月'\t%h=' 5月'\t%m='05'\t%Om='05'\n"),
336 lfmt,
337 std::chrono::month_day_last{std::chrono::May});
338 check(loc,
339 SV("%b=' 6月'\t%B='6月'\t%h=' 6月'\t%m='06'\t%Om='06'\n"),
340 lfmt,
341 std::chrono::month_day_last{std::chrono::June});
342 check(loc,
343 SV("%b=' 7月'\t%B='7月'\t%h=' 7月'\t%m='07'\t%Om='07'\n"),
344 lfmt,
345 std::chrono::month_day_last{std::chrono::July});
346 check(loc,
347 SV("%b=' 8月'\t%B='8月'\t%h=' 8月'\t%m='08'\t%Om='08'\n"),
348 lfmt,
349 std::chrono::month_day_last{std::chrono::August});
350 check(loc,
351 SV("%b=' 9月'\t%B='9月'\t%h=' 9月'\t%m='09'\t%Om='09'\n"),
352 lfmt,
353 std::chrono::month_day_last{std::chrono::September});
354 check(loc,
355 SV("%b='10月'\t%B='10月'\t%h='10月'\t%m='10'\t%Om='10'\n"),
356 lfmt,
357 std::chrono::month_day_last{std::chrono::October});
358 check(loc,
359 SV("%b='11月'\t%B='11月'\t%h='11月'\t%m='11'\t%Om='11'\n"),
360 lfmt,
361 std::chrono::month_day_last{std::chrono::November});
362 check(loc,
363 SV("%b='12月'\t%B='12月'\t%h='12月'\t%m='12'\t%Om='12'\n"),
364 lfmt,
365 std::chrono::month_day_last{std::chrono::December});
366 #else // defined(_WIN32)
367 check(loc,
368 SV("%b=' 1月'\t%B='1月'\t%h=' 1月'\t%m='01'\t%Om='一'\n"),
369 lfmt,
370 std::chrono::month_day_last{std::chrono::January});
371 check(loc,
372 SV("%b=' 2月'\t%B='2月'\t%h=' 2月'\t%m='02'\t%Om='二'\n"),
373 lfmt,
374 std::chrono::month_day_last{std::chrono::February});
375 check(loc,
376 SV("%b=' 3月'\t%B='3月'\t%h=' 3月'\t%m='03'\t%Om='三'\n"),
377 lfmt,
378 std::chrono::month_day_last{std::chrono::March});
379 check(loc,
380 SV("%b=' 4月'\t%B='4月'\t%h=' 4月'\t%m='04'\t%Om='四'\n"),
381 lfmt,
382 std::chrono::month_day_last{std::chrono::April});
383 check(loc,
384 SV("%b=' 5月'\t%B='5月'\t%h=' 5月'\t%m='05'\t%Om='五'\n"),
385 lfmt,
386 std::chrono::month_day_last{std::chrono::May});
387 check(loc,
388 SV("%b=' 6月'\t%B='6月'\t%h=' 6月'\t%m='06'\t%Om='六'\n"),
389 lfmt,
390 std::chrono::month_day_last{std::chrono::June});
391 check(loc,
392 SV("%b=' 7月'\t%B='7月'\t%h=' 7月'\t%m='07'\t%Om='七'\n"),
393 lfmt,
394 std::chrono::month_day_last{std::chrono::July});
395 check(loc,
396 SV("%b=' 8月'\t%B='8月'\t%h=' 8月'\t%m='08'\t%Om='八'\n"),
397 lfmt,
398 std::chrono::month_day_last{std::chrono::August});
399 check(loc,
400 SV("%b=' 9月'\t%B='9月'\t%h=' 9月'\t%m='09'\t%Om='九'\n"),
401 lfmt,
402 std::chrono::month_day_last{std::chrono::September});
403 check(loc,
404 SV("%b='10月'\t%B='10月'\t%h='10月'\t%m='10'\t%Om='十'\n"),
405 lfmt,
406 std::chrono::month_day_last{std::chrono::October});
407 check(loc,
408 SV("%b='11月'\t%B='11月'\t%h='11月'\t%m='11'\t%Om='十一'\n"),
409 lfmt,
410 std::chrono::month_day_last{std::chrono::November});
411 check(loc,
412 SV("%b='12月'\t%B='12月'\t%h='12月'\t%m='12'\t%Om='十二'\n"),
413 lfmt,
414 std::chrono::month_day_last{std::chrono::December});
415 #endif // defined(_WIN32)
416
417 std::locale::global(std::locale::classic());
418 }
419
420 template <class CharT>
421 static void test() {
422 test_no_chrono_specs<CharT>();
423 test_valid_values<CharT>();
424 check_invalid_types<CharT>(
425 {SV("b"), SV("B"), SV("h"), SV("m"), SV("Om")}, std::chrono::month_day_last{std::chrono::January});
426
427 check_exception(
428 "The format specifier expects a '%' or a '}'", SV("{:A"), std::chrono::month_day_last{std::chrono::January});
429 check_exception(
430 "The chrono specifiers contain a '{'", SV("{:%%{"), std::chrono::month_day_last{std::chrono::January});
431 check_exception("End of input while parsing a conversion specifier",
432 SV("{:%"),
433 std::chrono::month_day_last{std::chrono::January});
434 check_exception(
435 "End of input while parsing the modifier E", SV("{:%E"), std::chrono::month_day_last{std::chrono::January});
436 check_exception(
437 "End of input while parsing the modifier O", SV("{:%O"), std::chrono::month_day_last{std::chrono::January});
438
439 // Precision not allowed
440 check_exception(
441 "The format specifier expects a '%' or a '}'", SV("{:.3}"), std::chrono::month_day_last{std::chrono::January});
442 }
443
444 int main(int, char**) {
445 test<char>();
446
447 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
448 test<wchar_t>();
449 #endif
450
451 return 0;
452 }