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: libcpp-has-no-incomplete-format
11
12 // TODO FMT Evaluate gcc-12 status
13 // UNSUPPORTED: gcc-12
14
15 // REQUIRES: locale.en_US.UTF-8
16
17 // <format>
18
19 // This test the locale-specific form for these formatting functions:
20 //
21 // // [format.functions], formatting functions
22 // template<class... Args>
23 // string format(string_view fmt, const Args&... args);
24 // template<class... Args>
25 // wstring format(wstring_view fmt, const Args&... args);
26 // template<class... Args>
27 // string format(const locale& loc, string_view fmt, const Args&... args);
28 // template<class... Args>
29 // wstring format(const locale& loc, wstring_view fmt, const Args&... args);
30 //
31 // string vformat(string_view fmt, format_args args);
32 // wstring vformat(wstring_view fmt, wformat_args args);
33 // string vformat(const locale& loc, string_view fmt, format_args args);
34 // wstring vformat(const locale& loc, wstring_view fmt, wformat_args args);
35 //
36 // template<class Out, class... Args>
37 // Out format_to(Out out, string_view fmt, const Args&... args);
38 // template<class Out, class... Args>
39 // Out format_to(Out out, wstring_view fmt, const Args&... args);
40 // template<class Out, class... Args>
41 // Out format_to(Out out, const locale& loc, string_view fmt, const Args&... args);
42 // template<class Out, class... Args>
43 // Out format_to(Out out, const locale& loc, wstring_view fmt, const Args&... args);
44 //
45 // template<class Out>
46 // Out vformat_to(Out out, string_view fmt, format_args args);
47 // template<class Out>
48 // Out vformat_to(Out out, wstring_view fmt, wformat_args args);
49 // template<class Out>
50 // Out vformat_to(Out out, const locale& loc, string_view fmt,
51 // format_args args);
52 // template<class Out>
53 // Out vformat_to(Out out, const locale& loc, wstring_view fmt,
54 // wformat_arg args);
55 //
56 // template<class Out> struct format_to_n_result {
57 // Out out;
58 // iter_difference_t<Out> size;
59 // };
60 //
61 // template<class Out, class... Args>
62 // format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
63 // string_view fmt, const Args&... args);
64 // template<class Out, class... Args>
65 // format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
66 // wstring_view fmt, const Args&... args);
67 // template<class Out, class... Args>
68 // format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
69 // const locale& loc, string_view fmt,
70 // const Args&... args);
71 // template<class Out, class... Args>
72 // format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
73 // const locale& loc, wstring_view fmt,
74 // const Args&... args);
75 //
76 // template<class... Args>
77 // size_t formatted_size(string_view fmt, const Args&... args);
78 // template<class... Args>
79 // size_t formatted_size(wstring_view fmt, const Args&... args);
80 // template<class... Args>
81 // size_t formatted_size(const locale& loc, string_view fmt, const Args&... args);
82 // template<class... Args>
83 // size_t formatted_size(const locale& loc, wstring_view fmt, const Args&... args);
84
85 #include <format>
86 #include <cassert>
87 #include <iostream>
88 #include <vector>
89
90 #include "test_macros.h"
91 #include "make_string.h"
92 #include "platform_support.h" // locale name macros
93 #include "format_tests.h"
94 #include "string_literal.h"
95
96 #define STR(S) MAKE_STRING(CharT, S)
97 #define SV(S) MAKE_STRING_VIEW(CharT, S)
98
99 template <class CharT>
100 struct numpunct;
101
102 template <>
103 struct numpunct<char> : std::numpunct<char> {
do_truenamenumpunct104 string_type do_truename() const override { return "yes"; }
do_falsenamenumpunct105 string_type do_falsename() const override { return "no"; }
106
do_groupingnumpunct107 std::string do_grouping() const override { return "\1\2\3\2\1"; };
do_thousands_sepnumpunct108 char do_thousands_sep() const override { return '_'; }
do_decimal_pointnumpunct109 char do_decimal_point() const override { return '#'; }
110 };
111
112 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
113 template <>
114 struct numpunct<wchar_t> : std::numpunct<wchar_t> {
do_truenamenumpunct115 string_type do_truename() const override { return L"yes"; }
do_falsenamenumpunct116 string_type do_falsename() const override { return L"no"; }
117
do_groupingnumpunct118 std::string do_grouping() const override { return "\1\2\3\2\1"; };
do_thousands_sepnumpunct119 wchar_t do_thousands_sep() const override { return L'_'; }
do_decimal_pointnumpunct120 wchar_t do_decimal_point() const override { return L'#'; }
121 };
122 #endif
123
124 template <string_literal fmt, class CharT, class... Args>
test(std::basic_string_view<CharT> expected,const Args &...args)125 void test(std::basic_string_view<CharT> expected, const Args&... args) {
126 // *** format ***
127 {
128 std::basic_string<CharT> out = std::format(fmt.template sv<CharT>(), args...);
129 if constexpr (std::same_as<CharT, char>)
130 if (out != expected)
131 std::cerr << "\nFormat string " << fmt.template sv<char>() << "\nExpected output " << expected
132 << "\nActual output " << out << '\n';
133 assert(out == expected);
134 }
135 // *** vformat ***
136 {
137 std::basic_string<CharT> out =
138 std::vformat(fmt.template sv<CharT>(), std::make_format_args<context_t<CharT>>(args...));
139 assert(out == expected);
140 }
141 // *** format_to ***
142 {
143 std::basic_string<CharT> out(expected.size(), CharT(' '));
144 auto it = std::format_to(out.begin(), fmt.template sv<CharT>(), args...);
145 assert(it == out.end());
146 assert(out == expected);
147 }
148 // *** vformat_to ***
149 {
150 std::basic_string<CharT> out(expected.size(), CharT(' '));
151 auto it = std::vformat_to(out.begin(), fmt.template sv<CharT>(), std::make_format_args<context_t<CharT>>(args...));
152 assert(it == out.end());
153 assert(out == expected);
154 }
155 // *** format_to_n ***
156 {
157 std::basic_string<CharT> out;
158 std::format_to_n_result result = std::format_to_n(std::back_inserter(out), 1000, fmt.template sv<CharT>(), args...);
159 using diff_type = decltype(result.size);
160 diff_type formatted_size = std::formatted_size(fmt.template sv<CharT>(), args...);
161 diff_type size = std::min<diff_type>(1000, formatted_size);
162
163 assert(result.size == formatted_size);
164 assert(out == expected.substr(0, size));
165 }
166 // *** formatted_size ***
167 {
168 size_t size = std::formatted_size(fmt.template sv<CharT>(), args...);
169 assert(size == expected.size());
170 }
171 }
172
173 template <string_literal fmt, class CharT, class... Args>
test(std::basic_string_view<CharT> expected,std::locale loc,const Args &...args)174 void test(std::basic_string_view<CharT> expected, std::locale loc, const Args&... args) {
175 // *** format ***
176 {
177 std::basic_string<CharT> out = std::format(loc, fmt.template sv<CharT>(), args...);
178 if constexpr (std::same_as<CharT, char>)
179 if (out != expected)
180 std::cerr << "\nFormat string " << fmt.template sv<char>() << "\nExpected output " << expected
181 << "\nActual output " << out << '\n';
182 assert(out == expected);
183 }
184 // *** vformat ***
185 {
186 std::basic_string<CharT> out =
187 std::vformat(loc, fmt.template sv<CharT>(), std::make_format_args<context_t<CharT>>(args...));
188 assert(out == expected);
189 }
190 // *** format_to ***
191 {
192 std::basic_string<CharT> out(expected.size(), CharT(' '));
193 auto it = std::format_to(out.begin(), loc, fmt.template sv<CharT>(), args...);
194 assert(it == out.end());
195 assert(out == expected);
196 }
197 // *** vformat_to ***
198 {
199 std::basic_string<CharT> out(expected.size(), CharT(' '));
200 auto it =
201 std::vformat_to(out.begin(), loc, fmt.template sv<CharT>(), std::make_format_args<context_t<CharT>>(args...));
202 assert(it == out.end());
203 assert(out == expected);
204 }
205 // *** format_to_n ***
206 {
207 std::basic_string<CharT> out;
208 std::format_to_n_result result =
209 std::format_to_n(std::back_inserter(out), 1000, loc, fmt.template sv<CharT>(), args...);
210 using diff_type = decltype(result.size);
211 diff_type formatted_size = std::formatted_size(loc, fmt.template sv<CharT>(), args...);
212 diff_type size = std::min<diff_type>(1000, formatted_size);
213
214 assert(result.size == formatted_size);
215 assert(out == expected.substr(0, size));
216 }
217 // *** formatted_size ***
218 {
219 size_t size = std::formatted_size(loc, fmt.template sv<CharT>(), args...);
220 assert(size == expected.size());
221 }
222 }
223
224 #ifndef TEST_HAS_NO_UNICODE
225 template <class CharT>
226 struct numpunct_unicode;
227
228 template <>
229 struct numpunct_unicode<char> : std::numpunct<char> {
do_truenamenumpunct_unicode230 string_type do_truename() const override { return "gültig"; }
do_falsenamenumpunct_unicode231 string_type do_falsename() const override { return "ungültig"; }
232 };
233
234 # ifndef TEST_HAS_NO_WIDE_CHARACTERS
235 template <>
236 struct numpunct_unicode<wchar_t> : std::numpunct<wchar_t> {
do_truenamenumpunct_unicode237 string_type do_truename() const override { return L"gültig"; }
do_falsenamenumpunct_unicode238 string_type do_falsename() const override { return L"ungültig"; }
239 };
240 # endif
241 #endif // TEST_HAS_NO_UNICODE
242
243 template <class CharT>
test_bool()244 void test_bool() {
245 std::locale loc = std::locale(std::locale(), new numpunct<CharT>());
246
247 std::locale::global(std::locale(LOCALE_en_US_UTF_8));
248 assert(std::locale().name() == LOCALE_en_US_UTF_8);
249 test<"{:L}">(SV("true"), true);
250 test<"{:L}">(SV("false"), false);
251
252 test<"{:L}">(SV("yes"), loc, true);
253 test<"{:L}">(SV("no"), loc, false);
254
255 std::locale::global(loc);
256 test<"{:L}">(SV("yes"), true);
257 test<"{:L}">(SV("no"), false);
258
259 test<"{:L}">(SV("true"), std::locale(LOCALE_en_US_UTF_8), true);
260 test<"{:L}">(SV("false"), std::locale(LOCALE_en_US_UTF_8), false);
261
262 #ifndef TEST_HAS_NO_UNICODE
263 std::locale loc_unicode = std::locale(std::locale(), new numpunct_unicode<CharT>());
264
265 test<"{:L}">(SV("gültig"), loc_unicode, true);
266 test<"{:L}">(SV("ungültig"), loc_unicode, false);
267
268 test<"{:9L}">(SV("gültig "), loc_unicode, true);
269 test<"{:!<9L}">(SV("gültig!!!"), loc_unicode, true);
270 test<"{:_^9L}">(SV("_gültig__"), loc_unicode, true);
271 test<"{:>9L}">(SV(" gültig"), loc_unicode, true);
272 #endif // TEST_HAS_NO_UNICODE
273 }
274
275 template <class CharT>
test_integer()276 void test_integer() {
277 std::locale loc = std::locale(std::locale(), new numpunct<CharT>());
278 std::locale en_US = std::locale(LOCALE_en_US_UTF_8);
279
280 // *** Decimal ***
281 std::locale::global(en_US);
282 test<"{:L}">(SV("0"), 0);
283 test<"{:L}">(SV("1"), 1);
284 test<"{:L}">(SV("10"), 10);
285 test<"{:L}">(SV("100"), 100);
286 test<"{:L}">(SV("1,000"), 1'000);
287 test<"{:L}">(SV("10,000"), 10'000);
288 test<"{:L}">(SV("100,000"), 100'000);
289 test<"{:L}">(SV("1,000,000"), 1'000'000);
290 test<"{:L}">(SV("10,000,000"), 10'000'000);
291 test<"{:L}">(SV("100,000,000"), 100'000'000);
292 test<"{:L}">(SV("1,000,000,000"), 1'000'000'000);
293
294 test<"{:L}">(SV("-1"), -1);
295 test<"{:L}">(SV("-10"), -10);
296 test<"{:L}">(SV("-100"), -100);
297 test<"{:L}">(SV("-1,000"), -1'000);
298 test<"{:L}">(SV("-10,000"), -10'000);
299 test<"{:L}">(SV("-100,000"), -100'000);
300 test<"{:L}">(SV("-1,000,000"), -1'000'000);
301 test<"{:L}">(SV("-10,000,000"), -10'000'000);
302 test<"{:L}">(SV("-100,000,000"), -100'000'000);
303 test<"{:L}">(SV("-1,000,000,000"), -1'000'000'000);
304
305 std::locale::global(loc);
306 test<"{:L}">(SV("0"), 0);
307 test<"{:L}">(SV("1"), 1);
308 test<"{:L}">(SV("1_0"), 10);
309 test<"{:L}">(SV("10_0"), 100);
310 test<"{:L}">(SV("1_00_0"), 1'000);
311 test<"{:L}">(SV("10_00_0"), 10'000);
312 test<"{:L}">(SV("100_00_0"), 100'000);
313 test<"{:L}">(SV("1_000_00_0"), 1'000'000);
314 test<"{:L}">(SV("10_000_00_0"), 10'000'000);
315 test<"{:L}">(SV("1_00_000_00_0"), 100'000'000);
316 test<"{:L}">(SV("1_0_00_000_00_0"), 1'000'000'000);
317
318 test<"{:L}">(SV("-1"), -1);
319 test<"{:L}">(SV("-1_0"), -10);
320 test<"{:L}">(SV("-10_0"), -100);
321 test<"{:L}">(SV("-1_00_0"), -1'000);
322 test<"{:L}">(SV("-10_00_0"), -10'000);
323 test<"{:L}">(SV("-100_00_0"), -100'000);
324 test<"{:L}">(SV("-1_000_00_0"), -1'000'000);
325 test<"{:L}">(SV("-10_000_00_0"), -10'000'000);
326 test<"{:L}">(SV("-1_00_000_00_0"), -100'000'000);
327 test<"{:L}">(SV("-1_0_00_000_00_0"), -1'000'000'000);
328
329 test<"{:L}">(SV("0"), en_US, 0);
330 test<"{:L}">(SV("1"), en_US, 1);
331 test<"{:L}">(SV("10"), en_US, 10);
332 test<"{:L}">(SV("100"), en_US, 100);
333 test<"{:L}">(SV("1,000"), en_US, 1'000);
334 test<"{:L}">(SV("10,000"), en_US, 10'000);
335 test<"{:L}">(SV("100,000"), en_US, 100'000);
336 test<"{:L}">(SV("1,000,000"), en_US, 1'000'000);
337 test<"{:L}">(SV("10,000,000"), en_US, 10'000'000);
338 test<"{:L}">(SV("100,000,000"), en_US, 100'000'000);
339 test<"{:L}">(SV("1,000,000,000"), en_US, 1'000'000'000);
340
341 test<"{:L}">(SV("-1"), en_US, -1);
342 test<"{:L}">(SV("-10"), en_US, -10);
343 test<"{:L}">(SV("-100"), en_US, -100);
344 test<"{:L}">(SV("-1,000"), en_US, -1'000);
345 test<"{:L}">(SV("-10,000"), en_US, -10'000);
346 test<"{:L}">(SV("-100,000"), en_US, -100'000);
347 test<"{:L}">(SV("-1,000,000"), en_US, -1'000'000);
348 test<"{:L}">(SV("-10,000,000"), en_US, -10'000'000);
349 test<"{:L}">(SV("-100,000,000"), en_US, -100'000'000);
350 test<"{:L}">(SV("-1,000,000,000"), en_US, -1'000'000'000);
351
352 std::locale::global(en_US);
353 test<"{:L}">(SV("0"), loc, 0);
354 test<"{:L}">(SV("1"), loc, 1);
355 test<"{:L}">(SV("1_0"), loc, 10);
356 test<"{:L}">(SV("10_0"), loc, 100);
357 test<"{:L}">(SV("1_00_0"), loc, 1'000);
358 test<"{:L}">(SV("10_00_0"), loc, 10'000);
359 test<"{:L}">(SV("100_00_0"), loc, 100'000);
360 test<"{:L}">(SV("1_000_00_0"), loc, 1'000'000);
361 test<"{:L}">(SV("10_000_00_0"), loc, 10'000'000);
362 test<"{:L}">(SV("1_00_000_00_0"), loc, 100'000'000);
363 test<"{:L}">(SV("1_0_00_000_00_0"), loc, 1'000'000'000);
364
365 test<"{:L}">(SV("-1"), loc, -1);
366 test<"{:L}">(SV("-1_0"), loc, -10);
367 test<"{:L}">(SV("-10_0"), loc, -100);
368 test<"{:L}">(SV("-1_00_0"), loc, -1'000);
369 test<"{:L}">(SV("-10_00_0"), loc, -10'000);
370 test<"{:L}">(SV("-100_00_0"), loc, -100'000);
371 test<"{:L}">(SV("-1_000_00_0"), loc, -1'000'000);
372 test<"{:L}">(SV("-10_000_00_0"), loc, -10'000'000);
373 test<"{:L}">(SV("-1_00_000_00_0"), loc, -100'000'000);
374 test<"{:L}">(SV("-1_0_00_000_00_0"), loc, -1'000'000'000);
375
376 // *** Binary ***
377 std::locale::global(en_US);
378 test<"{:Lb}">(SV("0"), 0b0);
379 test<"{:Lb}">(SV("1"), 0b1);
380 test<"{:Lb}">(SV("1,000,000,000"), 0b1'000'000'000);
381
382 test<"{:#Lb}">(SV("0b0"), 0b0);
383 test<"{:#Lb}">(SV("0b1"), 0b1);
384 test<"{:#Lb}">(SV("0b1,000,000,000"), 0b1'000'000'000);
385
386 test<"{:LB}">(SV("-1"), -0b1);
387 test<"{:LB}">(SV("-1,000,000,000"), -0b1'000'000'000);
388
389 test<"{:#LB}">(SV("-0B1"), -0b1);
390 test<"{:#LB}">(SV("-0B1,000,000,000"), -0b1'000'000'000);
391
392 std::locale::global(loc);
393 test<"{:Lb}">(SV("0"), 0b0);
394 test<"{:Lb}">(SV("1"), 0b1);
395 test<"{:Lb}">(SV("1_0_00_000_00_0"), 0b1'000'000'000);
396
397 test<"{:#Lb}">(SV("0b0"), 0b0);
398 test<"{:#Lb}">(SV("0b1"), 0b1);
399 test<"{:#Lb}">(SV("0b1_0_00_000_00_0"), 0b1'000'000'000);
400
401 test<"{:LB}">(SV("-1"), -0b1);
402 test<"{:LB}">(SV("-1_0_00_000_00_0"), -0b1'000'000'000);
403
404 test<"{:#LB}">(SV("-0B1"), -0b1);
405 test<"{:#LB}">(SV("-0B1_0_00_000_00_0"), -0b1'000'000'000);
406
407 test<"{:Lb}">(SV("0"), en_US, 0b0);
408 test<"{:Lb}">(SV("1"), en_US, 0b1);
409 test<"{:Lb}">(SV("1,000,000,000"), en_US, 0b1'000'000'000);
410
411 test<"{:#Lb}">(SV("0b0"), en_US, 0b0);
412 test<"{:#Lb}">(SV("0b1"), en_US, 0b1);
413 test<"{:#Lb}">(SV("0b1,000,000,000"), en_US, 0b1'000'000'000);
414
415 test<"{:LB}">(SV("-1"), en_US, -0b1);
416 test<"{:LB}">(SV("-1,000,000,000"), en_US, -0b1'000'000'000);
417
418 test<"{:#LB}">(SV("-0B1"), en_US, -0b1);
419 test<"{:#LB}">(SV("-0B1,000,000,000"), en_US, -0b1'000'000'000);
420
421 std::locale::global(en_US);
422 test<"{:Lb}">(SV("0"), loc, 0b0);
423 test<"{:Lb}">(SV("1"), loc, 0b1);
424 test<"{:Lb}">(SV("1_0_00_000_00_0"), loc, 0b1'000'000'000);
425
426 test<"{:#Lb}">(SV("0b0"), loc, 0b0);
427 test<"{:#Lb}">(SV("0b1"), loc, 0b1);
428 test<"{:#Lb}">(SV("0b1_0_00_000_00_0"), loc, 0b1'000'000'000);
429
430 test<"{:LB}">(SV("-1"), loc, -0b1);
431 test<"{:LB}">(SV("-1_0_00_000_00_0"), loc, -0b1'000'000'000);
432
433 test<"{:#LB}">(SV("-0B1"), loc, -0b1);
434 test<"{:#LB}">(SV("-0B1_0_00_000_00_0"), loc, -0b1'000'000'000);
435
436 // *** Octal ***
437 std::locale::global(en_US);
438 test<"{:Lo}">(SV("0"), 00);
439 test<"{:Lo}">(SV("1"), 01);
440 test<"{:Lo}">(SV("1,000,000,000"), 01'000'000'000);
441
442 test<"{:#Lo}">(SV("0"), 00);
443 test<"{:#Lo}">(SV("01"), 01);
444 test<"{:#Lo}">(SV("01,000,000,000"), 01'000'000'000);
445
446 test<"{:Lo}">(SV("-1"), -01);
447 test<"{:Lo}">(SV("-1,000,000,000"), -01'000'000'000);
448
449 test<"{:#Lo}">(SV("-01"), -01);
450 test<"{:#Lo}">(SV("-01,000,000,000"), -01'000'000'000);
451
452 std::locale::global(loc);
453 test<"{:Lo}">(SV("0"), 00);
454 test<"{:Lo}">(SV("1"), 01);
455 test<"{:Lo}">(SV("1_0_00_000_00_0"), 01'000'000'000);
456
457 test<"{:#Lo}">(SV("0"), 00);
458 test<"{:#Lo}">(SV("01"), 01);
459 test<"{:#Lo}">(SV("01_0_00_000_00_0"), 01'000'000'000);
460
461 test<"{:Lo}">(SV("-1"), -01);
462 test<"{:Lo}">(SV("-1_0_00_000_00_0"), -01'000'000'000);
463
464 test<"{:#Lo}">(SV("-01"), -01);
465 test<"{:#Lo}">(SV("-01_0_00_000_00_0"), -01'000'000'000);
466
467 test<"{:Lo}">(SV("0"), en_US, 00);
468 test<"{:Lo}">(SV("1"), en_US, 01);
469 test<"{:Lo}">(SV("1,000,000,000"), en_US, 01'000'000'000);
470
471 test<"{:#Lo}">(SV("0"), en_US, 00);
472 test<"{:#Lo}">(SV("01"), en_US, 01);
473 test<"{:#Lo}">(SV("01,000,000,000"), en_US, 01'000'000'000);
474
475 test<"{:Lo}">(SV("-1"), en_US, -01);
476 test<"{:Lo}">(SV("-1,000,000,000"), en_US, -01'000'000'000);
477
478 test<"{:#Lo}">(SV("-01"), en_US, -01);
479 test<"{:#Lo}">(SV("-01,000,000,000"), en_US, -01'000'000'000);
480
481 std::locale::global(en_US);
482 test<"{:Lo}">(SV("0"), loc, 00);
483 test<"{:Lo}">(SV("1"), loc, 01);
484 test<"{:Lo}">(SV("1_0_00_000_00_0"), loc, 01'000'000'000);
485
486 test<"{:#Lo}">(SV("0"), loc, 00);
487 test<"{:#Lo}">(SV("01"), loc, 01);
488 test<"{:#Lo}">(SV("01_0_00_000_00_0"), loc, 01'000'000'000);
489
490 test<"{:Lo}">(SV("-1"), loc, -01);
491 test<"{:Lo}">(SV("-1_0_00_000_00_0"), loc, -01'000'000'000);
492
493 test<"{:#Lo}">(SV("-01"), loc, -01);
494 test<"{:#Lo}">(SV("-01_0_00_000_00_0"), loc, -01'000'000'000);
495
496 // *** Hexadecimal ***
497 std::locale::global(en_US);
498 test<"{:Lx}">(SV("0"), 0x0);
499 test<"{:Lx}">(SV("1"), 0x1);
500 test<"{:Lx}">(SV("1,000,000,000"), 0x1'000'000'000);
501
502 test<"{:#Lx}">(SV("0x0"), 0x0);
503 test<"{:#Lx}">(SV("0x1"), 0x1);
504 test<"{:#Lx}">(SV("0x1,000,000,000"), 0x1'000'000'000);
505
506 test<"{:LX}">(SV("-1"), -0x1);
507 test<"{:LX}">(SV("-1,000,000,000"), -0x1'000'000'000);
508
509 test<"{:#LX}">(SV("-0X1"), -0x1);
510 test<"{:#LX}">(SV("-0X1,000,000,000"), -0x1'000'000'000);
511
512 std::locale::global(loc);
513 test<"{:Lx}">(SV("0"), 0x0);
514 test<"{:Lx}">(SV("1"), 0x1);
515 test<"{:Lx}">(SV("1_0_00_000_00_0"), 0x1'000'000'000);
516
517 test<"{:#Lx}">(SV("0x0"), 0x0);
518 test<"{:#Lx}">(SV("0x1"), 0x1);
519 test<"{:#Lx}">(SV("0x1_0_00_000_00_0"), 0x1'000'000'000);
520
521 test<"{:LX}">(SV("-1"), -0x1);
522 test<"{:LX}">(SV("-1_0_00_000_00_0"), -0x1'000'000'000);
523
524 test<"{:#LX}">(SV("-0X1"), -0x1);
525 test<"{:#LX}">(SV("-0X1_0_00_000_00_0"), -0x1'000'000'000);
526
527 test<"{:Lx}">(SV("0"), en_US, 0x0);
528 test<"{:Lx}">(SV("1"), en_US, 0x1);
529 test<"{:Lx}">(SV("1,000,000,000"), en_US, 0x1'000'000'000);
530
531 test<"{:#Lx}">(SV("0x0"), en_US, 0x0);
532 test<"{:#Lx}">(SV("0x1"), en_US, 0x1);
533 test<"{:#Lx}">(SV("0x1,000,000,000"), en_US, 0x1'000'000'000);
534
535 test<"{:LX}">(SV("-1"), en_US, -0x1);
536 test<"{:LX}">(SV("-1,000,000,000"), en_US, -0x1'000'000'000);
537
538 test<"{:#LX}">(SV("-0X1"), en_US, -0x1);
539 test<"{:#LX}">(SV("-0X1,000,000,000"), en_US, -0x1'000'000'000);
540
541 std::locale::global(en_US);
542 test<"{:Lx}">(SV("0"), loc, 0x0);
543 test<"{:Lx}">(SV("1"), loc, 0x1);
544 test<"{:Lx}">(SV("1_0_00_000_00_0"), loc, 0x1'000'000'000);
545
546 test<"{:#Lx}">(SV("0x0"), loc, 0x0);
547 test<"{:#Lx}">(SV("0x1"), loc, 0x1);
548 test<"{:#Lx}">(SV("0x1_0_00_000_00_0"), loc, 0x1'000'000'000);
549
550 test<"{:LX}">(SV("-1"), loc, -0x1);
551 test<"{:LX}">(SV("-1_0_00_000_00_0"), loc, -0x1'000'000'000);
552
553 test<"{:#LX}">(SV("-0X1"), loc, -0x1);
554 test<"{:#LX}">(SV("-0X1_0_00_000_00_0"), loc, -0x1'000'000'000);
555
556 // *** align-fill & width ***
557 test<"{:L}">(SV("4_2"), loc, 42);
558
559 test<"{:6L}">(SV(" 4_2"), loc, 42);
560 test<"{:<6L}">(SV("4_2 "), loc, 42);
561 test<"{:^6L}">(SV(" 4_2 "), loc, 42);
562 test<"{:>6L}">(SV(" 4_2"), loc, 42);
563
564 test<"{:*<6L}">(SV("4_2***"), loc, 42);
565 test<"{:*^6L}">(SV("*4_2**"), loc, 42);
566 test<"{:*>6L}">(SV("***4_2"), loc, 42);
567
568 test<"{:*<8Lx}">(SV("4_a*****"), loc, 0x4a);
569 test<"{:*^8Lx}">(SV("**4_a***"), loc, 0x4a);
570 test<"{:*>8Lx}">(SV("*****4_a"), loc, 0x4a);
571
572 test<"{:*<#8Lx}">(SV("0x4_a***"), loc, 0x4a);
573 test<"{:*^#8Lx}">(SV("*0x4_a**"), loc, 0x4a);
574 test<"{:*>#8Lx}">(SV("***0x4_a"), loc, 0x4a);
575
576 test<"{:*<8LX}">(SV("4_A*****"), loc, 0x4a);
577 test<"{:*^8LX}">(SV("**4_A***"), loc, 0x4a);
578 test<"{:*>8LX}">(SV("*****4_A"), loc, 0x4a);
579
580 test<"{:*<#8LX}">(SV("0X4_A***"), loc, 0x4a);
581 test<"{:*^#8LX}">(SV("*0X4_A**"), loc, 0x4a);
582 test<"{:*>#8LX}">(SV("***0X4_A"), loc, 0x4a);
583
584 // Test whether zero padding is ignored
585 test<"{:<06L}">(SV("4_2 "), loc, 42);
586 test<"{:^06L}">(SV(" 4_2 "), loc, 42);
587 test<"{:>06L}">(SV(" 4_2"), loc, 42);
588
589 // *** zero-padding & width ***
590 test<"{:6L}">(SV(" 4_2"), loc, 42);
591 test<"{:06L}">(SV("0004_2"), loc, 42);
592 test<"{:06L}">(SV("-004_2"), loc, -42);
593
594 test<"{:08Lx}">(SV("000004_a"), loc, 0x4a);
595 test<"{:#08Lx}">(SV("0x0004_a"), loc, 0x4a);
596 test<"{:#08LX}">(SV("0X0004_A"), loc, 0x4a);
597
598 test<"{:08Lx}">(SV("-00004_a"), loc, -0x4a);
599 test<"{:#08Lx}">(SV("-0x004_a"), loc, -0x4a);
600 test<"{:#08LX}">(SV("-0X004_A"), loc, -0x4a);
601 }
602
603 template <class F, class CharT>
test_floating_point_hex_lower_case()604 void test_floating_point_hex_lower_case() {
605 std::locale loc = std::locale(std::locale(), new numpunct<CharT>());
606 std::locale en_US = std::locale(LOCALE_en_US_UTF_8);
607
608 // *** Basic ***
609 std::locale::global(en_US);
610 test<"{:La}">(SV("1.23456p-3"), F(0x1.23456p-3));
611 test<"{:La}">(SV("1.23456p-2"), F(0x1.23456p-2));
612 test<"{:La}">(SV("1.23456p-1"), F(0x1.23456p-1));
613 test<"{:La}">(SV("1.23456p+0"), F(0x1.23456p0));
614 test<"{:La}">(SV("1.23456p+1"), F(0x1.23456p+1));
615 test<"{:La}">(SV("1.23456p+2"), F(0x1.23456p+2));
616 test<"{:La}">(SV("1.23456p+3"), F(0x1.23456p+3));
617 test<"{:La}">(SV("1.23456p+20"), F(0x1.23456p+20));
618
619 std::locale::global(loc);
620 test<"{:La}">(SV("1#23456p-3"), F(0x1.23456p-3));
621 test<"{:La}">(SV("1#23456p-2"), F(0x1.23456p-2));
622 test<"{:La}">(SV("1#23456p-1"), F(0x1.23456p-1));
623 test<"{:La}">(SV("1#23456p+0"), F(0x1.23456p0));
624 test<"{:La}">(SV("1#23456p+1"), F(0x1.23456p+1));
625 test<"{:La}">(SV("1#23456p+2"), F(0x1.23456p+2));
626 test<"{:La}">(SV("1#23456p+3"), F(0x1.23456p+3));
627 test<"{:La}">(SV("1#23456p+20"), F(0x1.23456p+20));
628
629 test<"{:La}">(SV("1.23456p-3"), en_US, F(0x1.23456p-3));
630 test<"{:La}">(SV("1.23456p-2"), en_US, F(0x1.23456p-2));
631 test<"{:La}">(SV("1.23456p-1"), en_US, F(0x1.23456p-1));
632 test<"{:La}">(SV("1.23456p+0"), en_US, F(0x1.23456p0));
633 test<"{:La}">(SV("1.23456p+1"), en_US, F(0x1.23456p+1));
634 test<"{:La}">(SV("1.23456p+2"), en_US, F(0x1.23456p+2));
635 test<"{:La}">(SV("1.23456p+3"), en_US, F(0x1.23456p+3));
636 test<"{:La}">(SV("1.23456p+20"), en_US, F(0x1.23456p+20));
637
638 std::locale::global(en_US);
639 test<"{:La}">(SV("1#23456p-3"), loc, F(0x1.23456p-3));
640 test<"{:La}">(SV("1#23456p-2"), loc, F(0x1.23456p-2));
641 test<"{:La}">(SV("1#23456p-1"), loc, F(0x1.23456p-1));
642 test<"{:La}">(SV("1#23456p+0"), loc, F(0x1.23456p0));
643 test<"{:La}">(SV("1#23456p+1"), loc, F(0x1.23456p+1));
644 test<"{:La}">(SV("1#23456p+2"), loc, F(0x1.23456p+2));
645 test<"{:La}">(SV("1#23456p+3"), loc, F(0x1.23456p+3));
646 test<"{:La}">(SV("1#23456p+20"), loc, F(0x1.23456p+20));
647
648 // *** Fill, align, zero padding ***
649 std::locale::global(en_US);
650 test<"{:$<13La}">(SV("1.23456p+3$$$"), F(0x1.23456p3));
651 test<"{:$>13La}">(SV("$$$1.23456p+3"), F(0x1.23456p3));
652 test<"{:$^13La}">(SV("$1.23456p+3$$"), F(0x1.23456p3));
653 test<"{:013La}">(SV("0001.23456p+3"), F(0x1.23456p3));
654 test<"{:$<14La}">(SV("-1.23456p+3$$$"), F(-0x1.23456p3));
655 test<"{:$>14La}">(SV("$$$-1.23456p+3"), F(-0x1.23456p3));
656 test<"{:$^14La}">(SV("$-1.23456p+3$$"), F(-0x1.23456p3));
657 test<"{:014La}">(SV("-0001.23456p+3"), F(-0x1.23456p3));
658
659 std::locale::global(loc);
660 test<"{:$<13La}">(SV("1#23456p+3$$$"), F(0x1.23456p3));
661 test<"{:$>13La}">(SV("$$$1#23456p+3"), F(0x1.23456p3));
662 test<"{:$^13La}">(SV("$1#23456p+3$$"), F(0x1.23456p3));
663 test<"{:013La}">(SV("0001#23456p+3"), F(0x1.23456p3));
664 test<"{:$<14La}">(SV("-1#23456p+3$$$"), F(-0x1.23456p3));
665 test<"{:$>14La}">(SV("$$$-1#23456p+3"), F(-0x1.23456p3));
666 test<"{:$^14La}">(SV("$-1#23456p+3$$"), F(-0x1.23456p3));
667 test<"{:014La}">(SV("-0001#23456p+3"), F(-0x1.23456p3));
668
669 test<"{:$<13La}">(SV("1.23456p+3$$$"), en_US, F(0x1.23456p3));
670 test<"{:$>13La}">(SV("$$$1.23456p+3"), en_US, F(0x1.23456p3));
671 test<"{:$^13La}">(SV("$1.23456p+3$$"), en_US, F(0x1.23456p3));
672 test<"{:013La}">(SV("0001.23456p+3"), en_US, F(0x1.23456p3));
673 test<"{:$<14La}">(SV("-1.23456p+3$$$"), en_US, F(-0x1.23456p3));
674 test<"{:$>14La}">(SV("$$$-1.23456p+3"), en_US, F(-0x1.23456p3));
675 test<"{:$^14La}">(SV("$-1.23456p+3$$"), en_US, F(-0x1.23456p3));
676 test<"{:014La}">(SV("-0001.23456p+3"), en_US, F(-0x1.23456p3));
677
678 std::locale::global(en_US);
679 test<"{:$<13La}">(SV("1#23456p+3$$$"), loc, F(0x1.23456p3));
680 test<"{:$>13La}">(SV("$$$1#23456p+3"), loc, F(0x1.23456p3));
681 test<"{:$^13La}">(SV("$1#23456p+3$$"), loc, F(0x1.23456p3));
682 test<"{:013La}">(SV("0001#23456p+3"), loc, F(0x1.23456p3));
683 test<"{:$<14La}">(SV("-1#23456p+3$$$"), loc, F(-0x1.23456p3));
684 test<"{:$>14La}">(SV("$$$-1#23456p+3"), loc, F(-0x1.23456p3));
685 test<"{:$^14La}">(SV("$-1#23456p+3$$"), loc, F(-0x1.23456p3));
686 test<"{:014La}">(SV("-0001#23456p+3"), loc, F(-0x1.23456p3));
687 }
688
689 template <class F, class CharT>
test_floating_point_hex_upper_case()690 void test_floating_point_hex_upper_case() {
691 std::locale loc = std::locale(std::locale(), new numpunct<CharT>());
692 std::locale en_US = std::locale(LOCALE_en_US_UTF_8);
693
694 // *** Basic ***
695 std::locale::global(en_US);
696 test<"{:LA}">(SV("1.23456P-3"), F(0x1.23456p-3));
697 test<"{:LA}">(SV("1.23456P-2"), F(0x1.23456p-2));
698 test<"{:LA}">(SV("1.23456P-1"), F(0x1.23456p-1));
699 test<"{:LA}">(SV("1.23456P+0"), F(0x1.23456p0));
700 test<"{:LA}">(SV("1.23456P+1"), F(0x1.23456p+1));
701 test<"{:LA}">(SV("1.23456P+2"), F(0x1.23456p+2));
702 test<"{:LA}">(SV("1.23456P+3"), F(0x1.23456p+3));
703 test<"{:LA}">(SV("1.23456P+20"), F(0x1.23456p+20));
704
705 std::locale::global(loc);
706 test<"{:LA}">(SV("1#23456P-3"), F(0x1.23456p-3));
707 test<"{:LA}">(SV("1#23456P-2"), F(0x1.23456p-2));
708 test<"{:LA}">(SV("1#23456P-1"), F(0x1.23456p-1));
709 test<"{:LA}">(SV("1#23456P+0"), F(0x1.23456p0));
710 test<"{:LA}">(SV("1#23456P+1"), F(0x1.23456p+1));
711 test<"{:LA}">(SV("1#23456P+2"), F(0x1.23456p+2));
712 test<"{:LA}">(SV("1#23456P+3"), F(0x1.23456p+3));
713 test<"{:LA}">(SV("1#23456P+20"), F(0x1.23456p+20));
714
715 test<"{:LA}">(SV("1.23456P-3"), en_US, F(0x1.23456p-3));
716 test<"{:LA}">(SV("1.23456P-2"), en_US, F(0x1.23456p-2));
717 test<"{:LA}">(SV("1.23456P-1"), en_US, F(0x1.23456p-1));
718 test<"{:LA}">(SV("1.23456P+0"), en_US, F(0x1.23456p0));
719 test<"{:LA}">(SV("1.23456P+1"), en_US, F(0x1.23456p+1));
720 test<"{:LA}">(SV("1.23456P+2"), en_US, F(0x1.23456p+2));
721 test<"{:LA}">(SV("1.23456P+3"), en_US, F(0x1.23456p+3));
722 test<"{:LA}">(SV("1.23456P+20"), en_US, F(0x1.23456p+20));
723
724 std::locale::global(en_US);
725 test<"{:LA}">(SV("1#23456P-3"), loc, F(0x1.23456p-3));
726 test<"{:LA}">(SV("1#23456P-2"), loc, F(0x1.23456p-2));
727 test<"{:LA}">(SV("1#23456P-1"), loc, F(0x1.23456p-1));
728 test<"{:LA}">(SV("1#23456P+0"), loc, F(0x1.23456p0));
729 test<"{:LA}">(SV("1#23456P+1"), loc, F(0x1.23456p+1));
730 test<"{:LA}">(SV("1#23456P+2"), loc, F(0x1.23456p+2));
731 test<"{:LA}">(SV("1#23456P+3"), loc, F(0x1.23456p+3));
732 test<"{:LA}">(SV("1#23456P+20"), loc, F(0x1.23456p+20));
733
734 // *** Fill, align, zero Padding ***
735 std::locale::global(en_US);
736 test<"{:$<13LA}">(SV("1.23456P+3$$$"), F(0x1.23456p3));
737 test<"{:$>13LA}">(SV("$$$1.23456P+3"), F(0x1.23456p3));
738 test<"{:$^13LA}">(SV("$1.23456P+3$$"), F(0x1.23456p3));
739 test<"{:013LA}">(SV("0001.23456P+3"), F(0x1.23456p3));
740 test<"{:$<14LA}">(SV("-1.23456P+3$$$"), F(-0x1.23456p3));
741 test<"{:$>14LA}">(SV("$$$-1.23456P+3"), F(-0x1.23456p3));
742 test<"{:$^14LA}">(SV("$-1.23456P+3$$"), F(-0x1.23456p3));
743 test<"{:014LA}">(SV("-0001.23456P+3"), F(-0x1.23456p3));
744
745 std::locale::global(loc);
746 test<"{:$<13LA}">(SV("1#23456P+3$$$"), F(0x1.23456p3));
747 test<"{:$>13LA}">(SV("$$$1#23456P+3"), F(0x1.23456p3));
748 test<"{:$^13LA}">(SV("$1#23456P+3$$"), F(0x1.23456p3));
749 test<"{:013LA}">(SV("0001#23456P+3"), F(0x1.23456p3));
750 test<"{:$<14LA}">(SV("-1#23456P+3$$$"), F(-0x1.23456p3));
751 test<"{:$>14LA}">(SV("$$$-1#23456P+3"), F(-0x1.23456p3));
752 test<"{:$^14LA}">(SV("$-1#23456P+3$$"), F(-0x1.23456p3));
753 test<"{:014LA}">(SV("-0001#23456P+3"), F(-0x1.23456p3));
754
755 test<"{:$<13LA}">(SV("1.23456P+3$$$"), en_US, F(0x1.23456p3));
756 test<"{:$>13LA}">(SV("$$$1.23456P+3"), en_US, F(0x1.23456p3));
757 test<"{:$^13LA}">(SV("$1.23456P+3$$"), en_US, F(0x1.23456p3));
758 test<"{:013LA}">(SV("0001.23456P+3"), en_US, F(0x1.23456p3));
759 test<"{:$<14LA}">(SV("-1.23456P+3$$$"), en_US, F(-0x1.23456p3));
760 test<"{:$>14LA}">(SV("$$$-1.23456P+3"), en_US, F(-0x1.23456p3));
761 test<"{:$^14LA}">(SV("$-1.23456P+3$$"), en_US, F(-0x1.23456p3));
762 test<"{:014LA}">(SV("-0001.23456P+3"), en_US, F(-0x1.23456p3));
763
764 std::locale::global(en_US);
765 test<"{:$<13LA}">(SV("1#23456P+3$$$"), loc, F(0x1.23456p3));
766 test<"{:$>13LA}">(SV("$$$1#23456P+3"), loc, F(0x1.23456p3));
767 test<"{:$^13LA}">(SV("$1#23456P+3$$"), loc, F(0x1.23456p3));
768 test<"{:013LA}">(SV("0001#23456P+3"), loc, F(0x1.23456p3));
769 test<"{:$<14LA}">(SV("-1#23456P+3$$$"), loc, F(-0x1.23456p3));
770 test<"{:$>14LA}">(SV("$$$-1#23456P+3"), loc, F(-0x1.23456p3));
771 test<"{:$^14LA}">(SV("$-1#23456P+3$$"), loc, F(-0x1.23456p3));
772 test<"{:014LA}">(SV("-0001#23456P+3"), loc, F(-0x1.23456p3));
773 }
774
775 template <class F, class CharT>
test_floating_point_hex_lower_case_precision()776 void test_floating_point_hex_lower_case_precision() {
777 std::locale loc = std::locale(std::locale(), new numpunct<CharT>());
778 std::locale en_US = std::locale(LOCALE_en_US_UTF_8);
779
780 // *** Basic ***
781 std::locale::global(en_US);
782 test<"{:.6La}">(SV("1.234560p-3"), F(0x1.23456p-3));
783 test<"{:.6La}">(SV("1.234560p-2"), F(0x1.23456p-2));
784 test<"{:.6La}">(SV("1.234560p-1"), F(0x1.23456p-1));
785 test<"{:.6La}">(SV("1.234560p+0"), F(0x1.23456p0));
786 test<"{:.6La}">(SV("1.234560p+1"), F(0x1.23456p+1));
787 test<"{:.6La}">(SV("1.234560p+2"), F(0x1.23456p+2));
788 test<"{:.6La}">(SV("1.234560p+3"), F(0x1.23456p+3));
789 test<"{:.6La}">(SV("1.234560p+20"), F(0x1.23456p+20));
790
791 std::locale::global(loc);
792 test<"{:.6La}">(SV("1#234560p-3"), F(0x1.23456p-3));
793 test<"{:.6La}">(SV("1#234560p-2"), F(0x1.23456p-2));
794 test<"{:.6La}">(SV("1#234560p-1"), F(0x1.23456p-1));
795 test<"{:.6La}">(SV("1#234560p+0"), F(0x1.23456p0));
796 test<"{:.6La}">(SV("1#234560p+1"), F(0x1.23456p+1));
797 test<"{:.6La}">(SV("1#234560p+2"), F(0x1.23456p+2));
798 test<"{:.6La}">(SV("1#234560p+3"), F(0x1.23456p+3));
799 test<"{:.6La}">(SV("1#234560p+20"), F(0x1.23456p+20));
800
801 test<"{:.6La}">(SV("1.234560p-3"), en_US, F(0x1.23456p-3));
802 test<"{:.6La}">(SV("1.234560p-2"), en_US, F(0x1.23456p-2));
803 test<"{:.6La}">(SV("1.234560p-1"), en_US, F(0x1.23456p-1));
804 test<"{:.6La}">(SV("1.234560p+0"), en_US, F(0x1.23456p0));
805 test<"{:.6La}">(SV("1.234560p+1"), en_US, F(0x1.23456p+1));
806 test<"{:.6La}">(SV("1.234560p+2"), en_US, F(0x1.23456p+2));
807 test<"{:.6La}">(SV("1.234560p+3"), en_US, F(0x1.23456p+3));
808 test<"{:.6La}">(SV("1.234560p+20"), en_US, F(0x1.23456p+20));
809
810 std::locale::global(en_US);
811 test<"{:.6La}">(SV("1#234560p-3"), loc, F(0x1.23456p-3));
812 test<"{:.6La}">(SV("1#234560p-2"), loc, F(0x1.23456p-2));
813 test<"{:.6La}">(SV("1#234560p-1"), loc, F(0x1.23456p-1));
814 test<"{:.6La}">(SV("1#234560p+0"), loc, F(0x1.23456p0));
815 test<"{:.6La}">(SV("1#234560p+1"), loc, F(0x1.23456p+1));
816 test<"{:.6La}">(SV("1#234560p+2"), loc, F(0x1.23456p+2));
817 test<"{:.6La}">(SV("1#234560p+3"), loc, F(0x1.23456p+3));
818 test<"{:.6La}">(SV("1#234560p+20"), loc, F(0x1.23456p+20));
819
820 // *** Fill, align, zero padding ***
821 std::locale::global(en_US);
822 test<"{:$<14.6La}">(SV("1.234560p+3$$$"), F(0x1.23456p3));
823 test<"{:$>14.6La}">(SV("$$$1.234560p+3"), F(0x1.23456p3));
824 test<"{:$^14.6La}">(SV("$1.234560p+3$$"), F(0x1.23456p3));
825 test<"{:014.6La}">(SV("0001.234560p+3"), F(0x1.23456p3));
826 test<"{:$<15.6La}">(SV("-1.234560p+3$$$"), F(-0x1.23456p3));
827 test<"{:$>15.6La}">(SV("$$$-1.234560p+3"), F(-0x1.23456p3));
828 test<"{:$^15.6La}">(SV("$-1.234560p+3$$"), F(-0x1.23456p3));
829 test<"{:015.6La}">(SV("-0001.234560p+3"), F(-0x1.23456p3));
830
831 std::locale::global(loc);
832 test<"{:$<14.6La}">(SV("1#234560p+3$$$"), F(0x1.23456p3));
833 test<"{:$>14.6La}">(SV("$$$1#234560p+3"), F(0x1.23456p3));
834 test<"{:$^14.6La}">(SV("$1#234560p+3$$"), F(0x1.23456p3));
835 test<"{:014.6La}">(SV("0001#234560p+3"), F(0x1.23456p3));
836 test<"{:$<15.6La}">(SV("-1#234560p+3$$$"), F(-0x1.23456p3));
837 test<"{:$>15.6La}">(SV("$$$-1#234560p+3"), F(-0x1.23456p3));
838 test<"{:$^15.6La}">(SV("$-1#234560p+3$$"), F(-0x1.23456p3));
839 test<"{:015.6La}">(SV("-0001#234560p+3"), F(-0x1.23456p3));
840
841 test<"{:$<14.6La}">(SV("1.234560p+3$$$"), en_US, F(0x1.23456p3));
842 test<"{:$>14.6La}">(SV("$$$1.234560p+3"), en_US, F(0x1.23456p3));
843 test<"{:$^14.6La}">(SV("$1.234560p+3$$"), en_US, F(0x1.23456p3));
844 test<"{:014.6La}">(SV("0001.234560p+3"), en_US, F(0x1.23456p3));
845 test<"{:$<15.6La}">(SV("-1.234560p+3$$$"), en_US, F(-0x1.23456p3));
846 test<"{:$>15.6La}">(SV("$$$-1.234560p+3"), en_US, F(-0x1.23456p3));
847 test<"{:$^15.6La}">(SV("$-1.234560p+3$$"), en_US, F(-0x1.23456p3));
848 test<"{:015.6La}">(SV("-0001.234560p+3"), en_US, F(-0x1.23456p3));
849
850 std::locale::global(en_US);
851 test<"{:$<14.6La}">(SV("1#234560p+3$$$"), loc, F(0x1.23456p3));
852 test<"{:$>14.6La}">(SV("$$$1#234560p+3"), loc, F(0x1.23456p3));
853 test<"{:$^14.6La}">(SV("$1#234560p+3$$"), loc, F(0x1.23456p3));
854 test<"{:014.6La}">(SV("0001#234560p+3"), loc, F(0x1.23456p3));
855 test<"{:$<15.6La}">(SV("-1#234560p+3$$$"), loc, F(-0x1.23456p3));
856 test<"{:$>15.6La}">(SV("$$$-1#234560p+3"), loc, F(-0x1.23456p3));
857 test<"{:$^15.6La}">(SV("$-1#234560p+3$$"), loc, F(-0x1.23456p3));
858 test<"{:015.6La}">(SV("-0001#234560p+3"), loc, F(-0x1.23456p3));
859 }
860
861 template <class F, class CharT>
test_floating_point_hex_upper_case_precision()862 void test_floating_point_hex_upper_case_precision() {
863 std::locale loc = std::locale(std::locale(), new numpunct<CharT>());
864 std::locale en_US = std::locale(LOCALE_en_US_UTF_8);
865
866 // *** Basic ***
867 std::locale::global(en_US);
868 test<"{:.6LA}">(SV("1.234560P-3"), F(0x1.23456p-3));
869 test<"{:.6LA}">(SV("1.234560P-2"), F(0x1.23456p-2));
870 test<"{:.6LA}">(SV("1.234560P-1"), F(0x1.23456p-1));
871 test<"{:.6LA}">(SV("1.234560P+0"), F(0x1.23456p0));
872 test<"{:.6LA}">(SV("1.234560P+1"), F(0x1.23456p+1));
873 test<"{:.6LA}">(SV("1.234560P+2"), F(0x1.23456p+2));
874 test<"{:.6LA}">(SV("1.234560P+3"), F(0x1.23456p+3));
875 test<"{:.6LA}">(SV("1.234560P+20"), F(0x1.23456p+20));
876
877 std::locale::global(loc);
878 test<"{:.6LA}">(SV("1#234560P-3"), F(0x1.23456p-3));
879 test<"{:.6LA}">(SV("1#234560P-2"), F(0x1.23456p-2));
880 test<"{:.6LA}">(SV("1#234560P-1"), F(0x1.23456p-1));
881 test<"{:.6LA}">(SV("1#234560P+0"), F(0x1.23456p0));
882 test<"{:.6LA}">(SV("1#234560P+1"), F(0x1.23456p+1));
883 test<"{:.6LA}">(SV("1#234560P+2"), F(0x1.23456p+2));
884 test<"{:.6LA}">(SV("1#234560P+3"), F(0x1.23456p+3));
885 test<"{:.6LA}">(SV("1#234560P+20"), F(0x1.23456p+20));
886
887 test<"{:.6LA}">(SV("1.234560P-3"), en_US, F(0x1.23456p-3));
888 test<"{:.6LA}">(SV("1.234560P-2"), en_US, F(0x1.23456p-2));
889 test<"{:.6LA}">(SV("1.234560P-1"), en_US, F(0x1.23456p-1));
890 test<"{:.6LA}">(SV("1.234560P+0"), en_US, F(0x1.23456p0));
891 test<"{:.6LA}">(SV("1.234560P+1"), en_US, F(0x1.23456p+1));
892 test<"{:.6LA}">(SV("1.234560P+2"), en_US, F(0x1.23456p+2));
893 test<"{:.6LA}">(SV("1.234560P+3"), en_US, F(0x1.23456p+3));
894 test<"{:.6LA}">(SV("1.234560P+20"), en_US, F(0x1.23456p+20));
895
896 std::locale::global(en_US);
897 test<"{:.6LA}">(SV("1#234560P-3"), loc, F(0x1.23456p-3));
898 test<"{:.6LA}">(SV("1#234560P-2"), loc, F(0x1.23456p-2));
899 test<"{:.6LA}">(SV("1#234560P-1"), loc, F(0x1.23456p-1));
900 test<"{:.6LA}">(SV("1#234560P+0"), loc, F(0x1.23456p0));
901 test<"{:.6LA}">(SV("1#234560P+1"), loc, F(0x1.23456p+1));
902 test<"{:.6LA}">(SV("1#234560P+2"), loc, F(0x1.23456p+2));
903 test<"{:.6LA}">(SV("1#234560P+3"), loc, F(0x1.23456p+3));
904 test<"{:.6LA}">(SV("1#234560P+20"), loc, F(0x1.23456p+20));
905
906 // *** Fill, align, zero Padding ***
907 std::locale::global(en_US);
908 test<"{:$<14.6LA}">(SV("1.234560P+3$$$"), F(0x1.23456p3));
909 test<"{:$>14.6LA}">(SV("$$$1.234560P+3"), F(0x1.23456p3));
910 test<"{:$^14.6LA}">(SV("$1.234560P+3$$"), F(0x1.23456p3));
911 test<"{:014.6LA}">(SV("0001.234560P+3"), F(0x1.23456p3));
912 test<"{:$<15.6LA}">(SV("-1.234560P+3$$$"), F(-0x1.23456p3));
913 test<"{:$>15.6LA}">(SV("$$$-1.234560P+3"), F(-0x1.23456p3));
914 test<"{:$^15.6LA}">(SV("$-1.234560P+3$$"), F(-0x1.23456p3));
915 test<"{:015.6LA}">(SV("-0001.234560P+3"), F(-0x1.23456p3));
916
917 std::locale::global(loc);
918 test<"{:$<14.6LA}">(SV("1#234560P+3$$$"), F(0x1.23456p3));
919 test<"{:$>14.6LA}">(SV("$$$1#234560P+3"), F(0x1.23456p3));
920 test<"{:$^14.6LA}">(SV("$1#234560P+3$$"), F(0x1.23456p3));
921 test<"{:014.6LA}">(SV("0001#234560P+3"), F(0x1.23456p3));
922 test<"{:$<15.6LA}">(SV("-1#234560P+3$$$"), F(-0x1.23456p3));
923 test<"{:$>15.6LA}">(SV("$$$-1#234560P+3"), F(-0x1.23456p3));
924 test<"{:$^15.6LA}">(SV("$-1#234560P+3$$"), F(-0x1.23456p3));
925 test<"{:015.6LA}">(SV("-0001#234560P+3"), F(-0x1.23456p3));
926
927 test<"{:$<14.6LA}">(SV("1.234560P+3$$$"), en_US, F(0x1.23456p3));
928 test<"{:$>14.6LA}">(SV("$$$1.234560P+3"), en_US, F(0x1.23456p3));
929 test<"{:$^14.6LA}">(SV("$1.234560P+3$$"), en_US, F(0x1.23456p3));
930 test<"{:014.6LA}">(SV("0001.234560P+3"), en_US, F(0x1.23456p3));
931 test<"{:$<15.6LA}">(SV("-1.234560P+3$$$"), en_US, F(-0x1.23456p3));
932 test<"{:$>15.6LA}">(SV("$$$-1.234560P+3"), en_US, F(-0x1.23456p3));
933 test<"{:$^15.6LA}">(SV("$-1.234560P+3$$"), en_US, F(-0x1.23456p3));
934 test<"{:015.6LA}">(SV("-0001.234560P+3"), en_US, F(-0x1.23456p3));
935
936 std::locale::global(en_US);
937 test<"{:$<14.6LA}">(SV("1#234560P+3$$$"), loc, F(0x1.23456p3));
938 test<"{:$>14.6LA}">(SV("$$$1#234560P+3"), loc, F(0x1.23456p3));
939 test<"{:$^14.6LA}">(SV("$1#234560P+3$$"), loc, F(0x1.23456p3));
940 test<"{:014.6LA}">(SV("0001#234560P+3"), loc, F(0x1.23456p3));
941 test<"{:$<15.6LA}">(SV("-1#234560P+3$$$"), loc, F(-0x1.23456p3));
942 test<"{:$>15.6LA}">(SV("$$$-1#234560P+3"), loc, F(-0x1.23456p3));
943 test<"{:$^15.6LA}">(SV("$-1#234560P+3$$"), loc, F(-0x1.23456p3));
944 test<"{:015.6LA}">(SV("-0001#234560P+3"), loc, F(-0x1.23456p3));
945 }
946
947 template <class F, class CharT>
test_floating_point_scientific_lower_case()948 void test_floating_point_scientific_lower_case() {
949 std::locale loc = std::locale(std::locale(), new numpunct<CharT>());
950 std::locale en_US = std::locale(LOCALE_en_US_UTF_8);
951
952 // *** Basic ***
953 std::locale::global(en_US);
954 test<"{:.6Le}">(SV("1.234567e-03"), F(1.234567e-3));
955 test<"{:.6Le}">(SV("1.234567e-02"), F(1.234567e-2));
956 test<"{:.6Le}">(SV("1.234567e-01"), F(1.234567e-1));
957 test<"{:.6Le}">(SV("1.234567e+00"), F(1.234567e0));
958 test<"{:.6Le}">(SV("1.234567e+01"), F(1.234567e1));
959 test<"{:.6Le}">(SV("1.234567e+02"), F(1.234567e2));
960 test<"{:.6Le}">(SV("1.234567e+03"), F(1.234567e3));
961 test<"{:.6Le}">(SV("1.234567e+20"), F(1.234567e20));
962 test<"{:.6Le}">(SV("-1.234567e-03"), F(-1.234567e-3));
963 test<"{:.6Le}">(SV("-1.234567e-02"), F(-1.234567e-2));
964 test<"{:.6Le}">(SV("-1.234567e-01"), F(-1.234567e-1));
965 test<"{:.6Le}">(SV("-1.234567e+00"), F(-1.234567e0));
966 test<"{:.6Le}">(SV("-1.234567e+01"), F(-1.234567e1));
967 test<"{:.6Le}">(SV("-1.234567e+02"), F(-1.234567e2));
968 test<"{:.6Le}">(SV("-1.234567e+03"), F(-1.234567e3));
969 test<"{:.6Le}">(SV("-1.234567e+20"), F(-1.234567e20));
970
971 std::locale::global(loc);
972 test<"{:.6Le}">(SV("1#234567e-03"), F(1.234567e-3));
973 test<"{:.6Le}">(SV("1#234567e-02"), F(1.234567e-2));
974 test<"{:.6Le}">(SV("1#234567e-01"), F(1.234567e-1));
975 test<"{:.6Le}">(SV("1#234567e+00"), F(1.234567e0));
976 test<"{:.6Le}">(SV("1#234567e+01"), F(1.234567e1));
977 test<"{:.6Le}">(SV("1#234567e+02"), F(1.234567e2));
978 test<"{:.6Le}">(SV("1#234567e+03"), F(1.234567e3));
979 test<"{:.6Le}">(SV("1#234567e+20"), F(1.234567e20));
980 test<"{:.6Le}">(SV("-1#234567e-03"), F(-1.234567e-3));
981 test<"{:.6Le}">(SV("-1#234567e-02"), F(-1.234567e-2));
982 test<"{:.6Le}">(SV("-1#234567e-01"), F(-1.234567e-1));
983 test<"{:.6Le}">(SV("-1#234567e+00"), F(-1.234567e0));
984 test<"{:.6Le}">(SV("-1#234567e+01"), F(-1.234567e1));
985 test<"{:.6Le}">(SV("-1#234567e+02"), F(-1.234567e2));
986 test<"{:.6Le}">(SV("-1#234567e+03"), F(-1.234567e3));
987 test<"{:.6Le}">(SV("-1#234567e+20"), F(-1.234567e20));
988
989 test<"{:.6Le}">(SV("1.234567e-03"), en_US, F(1.234567e-3));
990 test<"{:.6Le}">(SV("1.234567e-02"), en_US, F(1.234567e-2));
991 test<"{:.6Le}">(SV("1.234567e-01"), en_US, F(1.234567e-1));
992 test<"{:.6Le}">(SV("1.234567e+00"), en_US, F(1.234567e0));
993 test<"{:.6Le}">(SV("1.234567e+01"), en_US, F(1.234567e1));
994 test<"{:.6Le}">(SV("1.234567e+02"), en_US, F(1.234567e2));
995 test<"{:.6Le}">(SV("1.234567e+03"), en_US, F(1.234567e3));
996 test<"{:.6Le}">(SV("1.234567e+20"), en_US, F(1.234567e20));
997 test<"{:.6Le}">(SV("-1.234567e-03"), en_US, F(-1.234567e-3));
998 test<"{:.6Le}">(SV("-1.234567e-02"), en_US, F(-1.234567e-2));
999 test<"{:.6Le}">(SV("-1.234567e-01"), en_US, F(-1.234567e-1));
1000 test<"{:.6Le}">(SV("-1.234567e+00"), en_US, F(-1.234567e0));
1001 test<"{:.6Le}">(SV("-1.234567e+01"), en_US, F(-1.234567e1));
1002 test<"{:.6Le}">(SV("-1.234567e+02"), en_US, F(-1.234567e2));
1003 test<"{:.6Le}">(SV("-1.234567e+03"), en_US, F(-1.234567e3));
1004 test<"{:.6Le}">(SV("-1.234567e+20"), en_US, F(-1.234567e20));
1005
1006 std::locale::global(en_US);
1007 test<"{:.6Le}">(SV("1#234567e-03"), loc, F(1.234567e-3));
1008 test<"{:.6Le}">(SV("1#234567e-02"), loc, F(1.234567e-2));
1009 test<"{:.6Le}">(SV("1#234567e-01"), loc, F(1.234567e-1));
1010 test<"{:.6Le}">(SV("1#234567e+00"), loc, F(1.234567e0));
1011 test<"{:.6Le}">(SV("1#234567e+01"), loc, F(1.234567e1));
1012 test<"{:.6Le}">(SV("1#234567e+02"), loc, F(1.234567e2));
1013 test<"{:.6Le}">(SV("1#234567e+03"), loc, F(1.234567e3));
1014 test<"{:.6Le}">(SV("1#234567e+20"), loc, F(1.234567e20));
1015 test<"{:.6Le}">(SV("-1#234567e-03"), loc, F(-1.234567e-3));
1016 test<"{:.6Le}">(SV("-1#234567e-02"), loc, F(-1.234567e-2));
1017 test<"{:.6Le}">(SV("-1#234567e-01"), loc, F(-1.234567e-1));
1018 test<"{:.6Le}">(SV("-1#234567e+00"), loc, F(-1.234567e0));
1019 test<"{:.6Le}">(SV("-1#234567e+01"), loc, F(-1.234567e1));
1020 test<"{:.6Le}">(SV("-1#234567e+02"), loc, F(-1.234567e2));
1021 test<"{:.6Le}">(SV("-1#234567e+03"), loc, F(-1.234567e3));
1022 test<"{:.6Le}">(SV("-1#234567e+20"), loc, F(-1.234567e20));
1023
1024 // *** Fill, align, zero padding ***
1025 std::locale::global(en_US);
1026 test<"{:$<15.6Le}">(SV("1.234567e+03$$$"), F(1.234567e3));
1027 test<"{:$>15.6Le}">(SV("$$$1.234567e+03"), F(1.234567e3));
1028 test<"{:$^15.6Le}">(SV("$1.234567e+03$$"), F(1.234567e3));
1029 test<"{:015.6Le}">(SV("0001.234567e+03"), F(1.234567e3));
1030 test<"{:$<16.6Le}">(SV("-1.234567e+03$$$"), F(-1.234567e3));
1031 test<"{:$>16.6Le}">(SV("$$$-1.234567e+03"), F(-1.234567e3));
1032 test<"{:$^16.6Le}">(SV("$-1.234567e+03$$"), F(-1.234567e3));
1033 test<"{:016.6Le}">(SV("-0001.234567e+03"), F(-1.234567e3));
1034
1035 std::locale::global(loc);
1036 test<"{:$<15.6Le}">(SV("1#234567e+03$$$"), F(1.234567e3));
1037 test<"{:$>15.6Le}">(SV("$$$1#234567e+03"), F(1.234567e3));
1038 test<"{:$^15.6Le}">(SV("$1#234567e+03$$"), F(1.234567e3));
1039 test<"{:015.6Le}">(SV("0001#234567e+03"), F(1.234567e3));
1040 test<"{:$<16.6Le}">(SV("-1#234567e+03$$$"), F(-1.234567e3));
1041 test<"{:$>16.6Le}">(SV("$$$-1#234567e+03"), F(-1.234567e3));
1042 test<"{:$^16.6Le}">(SV("$-1#234567e+03$$"), F(-1.234567e3));
1043 test<"{:016.6Le}">(SV("-0001#234567e+03"), F(-1.234567e3));
1044
1045 test<"{:$<15.6Le}">(SV("1.234567e+03$$$"), en_US, F(1.234567e3));
1046 test<"{:$>15.6Le}">(SV("$$$1.234567e+03"), en_US, F(1.234567e3));
1047 test<"{:$^15.6Le}">(SV("$1.234567e+03$$"), en_US, F(1.234567e3));
1048 test<"{:015.6Le}">(SV("0001.234567e+03"), en_US, F(1.234567e3));
1049 test<"{:$<16.6Le}">(SV("-1.234567e+03$$$"), en_US, F(-1.234567e3));
1050 test<"{:$>16.6Le}">(SV("$$$-1.234567e+03"), en_US, F(-1.234567e3));
1051 test<"{:$^16.6Le}">(SV("$-1.234567e+03$$"), en_US, F(-1.234567e3));
1052 test<"{:016.6Le}">(SV("-0001.234567e+03"), en_US, F(-1.234567e3));
1053
1054 std::locale::global(en_US);
1055 test<"{:$<15.6Le}">(SV("1#234567e+03$$$"), loc, F(1.234567e3));
1056 test<"{:$>15.6Le}">(SV("$$$1#234567e+03"), loc, F(1.234567e3));
1057 test<"{:$^15.6Le}">(SV("$1#234567e+03$$"), loc, F(1.234567e3));
1058 test<"{:015.6Le}">(SV("0001#234567e+03"), loc, F(1.234567e3));
1059 test<"{:$<16.6Le}">(SV("-1#234567e+03$$$"), loc, F(-1.234567e3));
1060 test<"{:$>16.6Le}">(SV("$$$-1#234567e+03"), loc, F(-1.234567e3));
1061 test<"{:$^16.6Le}">(SV("$-1#234567e+03$$"), loc, F(-1.234567e3));
1062 test<"{:016.6Le}">(SV("-0001#234567e+03"), loc, F(-1.234567e3));
1063 }
1064
1065 template <class F, class CharT>
test_floating_point_scientific_upper_case()1066 void test_floating_point_scientific_upper_case() {
1067 std::locale loc = std::locale(std::locale(), new numpunct<CharT>());
1068 std::locale en_US = std::locale(LOCALE_en_US_UTF_8);
1069
1070 // *** Basic ***
1071 std::locale::global(en_US);
1072 test<"{:.6LE}">(SV("1.234567E-03"), F(1.234567e-3));
1073 test<"{:.6LE}">(SV("1.234567E-02"), F(1.234567e-2));
1074 test<"{:.6LE}">(SV("1.234567E-01"), F(1.234567e-1));
1075 test<"{:.6LE}">(SV("1.234567E+00"), F(1.234567e0));
1076 test<"{:.6LE}">(SV("1.234567E+01"), F(1.234567e1));
1077 test<"{:.6LE}">(SV("1.234567E+02"), F(1.234567e2));
1078 test<"{:.6LE}">(SV("1.234567E+03"), F(1.234567e3));
1079 test<"{:.6LE}">(SV("1.234567E+20"), F(1.234567e20));
1080 test<"{:.6LE}">(SV("-1.234567E-03"), F(-1.234567e-3));
1081 test<"{:.6LE}">(SV("-1.234567E-02"), F(-1.234567e-2));
1082 test<"{:.6LE}">(SV("-1.234567E-01"), F(-1.234567e-1));
1083 test<"{:.6LE}">(SV("-1.234567E+00"), F(-1.234567e0));
1084 test<"{:.6LE}">(SV("-1.234567E+01"), F(-1.234567e1));
1085 test<"{:.6LE}">(SV("-1.234567E+02"), F(-1.234567e2));
1086 test<"{:.6LE}">(SV("-1.234567E+03"), F(-1.234567e3));
1087 test<"{:.6LE}">(SV("-1.234567E+20"), F(-1.234567e20));
1088
1089 std::locale::global(loc);
1090 test<"{:.6LE}">(SV("1#234567E-03"), F(1.234567e-3));
1091 test<"{:.6LE}">(SV("1#234567E-02"), F(1.234567e-2));
1092 test<"{:.6LE}">(SV("1#234567E-01"), F(1.234567e-1));
1093 test<"{:.6LE}">(SV("1#234567E+00"), F(1.234567e0));
1094 test<"{:.6LE}">(SV("1#234567E+01"), F(1.234567e1));
1095 test<"{:.6LE}">(SV("1#234567E+02"), F(1.234567e2));
1096 test<"{:.6LE}">(SV("1#234567E+03"), F(1.234567e3));
1097 test<"{:.6LE}">(SV("1#234567E+20"), F(1.234567e20));
1098 test<"{:.6LE}">(SV("-1#234567E-03"), F(-1.234567e-3));
1099 test<"{:.6LE}">(SV("-1#234567E-02"), F(-1.234567e-2));
1100 test<"{:.6LE}">(SV("-1#234567E-01"), F(-1.234567e-1));
1101 test<"{:.6LE}">(SV("-1#234567E+00"), F(-1.234567e0));
1102 test<"{:.6LE}">(SV("-1#234567E+01"), F(-1.234567e1));
1103 test<"{:.6LE}">(SV("-1#234567E+02"), F(-1.234567e2));
1104 test<"{:.6LE}">(SV("-1#234567E+03"), F(-1.234567e3));
1105 test<"{:.6LE}">(SV("-1#234567E+20"), F(-1.234567e20));
1106
1107 test<"{:.6LE}">(SV("1.234567E-03"), en_US, F(1.234567e-3));
1108 test<"{:.6LE}">(SV("1.234567E-02"), en_US, F(1.234567e-2));
1109 test<"{:.6LE}">(SV("1.234567E-01"), en_US, F(1.234567e-1));
1110 test<"{:.6LE}">(SV("1.234567E+00"), en_US, F(1.234567e0));
1111 test<"{:.6LE}">(SV("1.234567E+01"), en_US, F(1.234567e1));
1112 test<"{:.6LE}">(SV("1.234567E+02"), en_US, F(1.234567e2));
1113 test<"{:.6LE}">(SV("1.234567E+03"), en_US, F(1.234567e3));
1114 test<"{:.6LE}">(SV("1.234567E+20"), en_US, F(1.234567e20));
1115 test<"{:.6LE}">(SV("-1.234567E-03"), en_US, F(-1.234567e-3));
1116 test<"{:.6LE}">(SV("-1.234567E-02"), en_US, F(-1.234567e-2));
1117 test<"{:.6LE}">(SV("-1.234567E-01"), en_US, F(-1.234567e-1));
1118 test<"{:.6LE}">(SV("-1.234567E+00"), en_US, F(-1.234567e0));
1119 test<"{:.6LE}">(SV("-1.234567E+01"), en_US, F(-1.234567e1));
1120 test<"{:.6LE}">(SV("-1.234567E+02"), en_US, F(-1.234567e2));
1121 test<"{:.6LE}">(SV("-1.234567E+03"), en_US, F(-1.234567e3));
1122 test<"{:.6LE}">(SV("-1.234567E+20"), en_US, F(-1.234567e20));
1123
1124 std::locale::global(en_US);
1125 test<"{:.6LE}">(SV("1#234567E-03"), loc, F(1.234567e-3));
1126 test<"{:.6LE}">(SV("1#234567E-02"), loc, F(1.234567e-2));
1127 test<"{:.6LE}">(SV("1#234567E-01"), loc, F(1.234567e-1));
1128 test<"{:.6LE}">(SV("1#234567E+00"), loc, F(1.234567e0));
1129 test<"{:.6LE}">(SV("1#234567E+01"), loc, F(1.234567e1));
1130 test<"{:.6LE}">(SV("1#234567E+02"), loc, F(1.234567e2));
1131 test<"{:.6LE}">(SV("1#234567E+03"), loc, F(1.234567e3));
1132 test<"{:.6LE}">(SV("1#234567E+20"), loc, F(1.234567e20));
1133 test<"{:.6LE}">(SV("-1#234567E-03"), loc, F(-1.234567e-3));
1134 test<"{:.6LE}">(SV("-1#234567E-02"), loc, F(-1.234567e-2));
1135 test<"{:.6LE}">(SV("-1#234567E-01"), loc, F(-1.234567e-1));
1136 test<"{:.6LE}">(SV("-1#234567E+00"), loc, F(-1.234567e0));
1137 test<"{:.6LE}">(SV("-1#234567E+01"), loc, F(-1.234567e1));
1138 test<"{:.6LE}">(SV("-1#234567E+02"), loc, F(-1.234567e2));
1139 test<"{:.6LE}">(SV("-1#234567E+03"), loc, F(-1.234567e3));
1140 test<"{:.6LE}">(SV("-1#234567E+20"), loc, F(-1.234567e20));
1141
1142 // *** Fill, align, zero padding ***
1143 std::locale::global(en_US);
1144 test<"{:$<15.6LE}">(SV("1.234567E+03$$$"), F(1.234567e3));
1145 test<"{:$>15.6LE}">(SV("$$$1.234567E+03"), F(1.234567e3));
1146 test<"{:$^15.6LE}">(SV("$1.234567E+03$$"), F(1.234567e3));
1147 test<"{:015.6LE}">(SV("0001.234567E+03"), F(1.234567e3));
1148 test<"{:$<16.6LE}">(SV("-1.234567E+03$$$"), F(-1.234567e3));
1149 test<"{:$>16.6LE}">(SV("$$$-1.234567E+03"), F(-1.234567e3));
1150 test<"{:$^16.6LE}">(SV("$-1.234567E+03$$"), F(-1.234567e3));
1151 test<"{:016.6LE}">(SV("-0001.234567E+03"), F(-1.234567e3));
1152
1153 std::locale::global(loc);
1154 test<"{:$<15.6LE}">(SV("1#234567E+03$$$"), F(1.234567e3));
1155 test<"{:$>15.6LE}">(SV("$$$1#234567E+03"), F(1.234567e3));
1156 test<"{:$^15.6LE}">(SV("$1#234567E+03$$"), F(1.234567e3));
1157 test<"{:015.6LE}">(SV("0001#234567E+03"), F(1.234567e3));
1158 test<"{:$<16.6LE}">(SV("-1#234567E+03$$$"), F(-1.234567e3));
1159 test<"{:$>16.6LE}">(SV("$$$-1#234567E+03"), F(-1.234567e3));
1160 test<"{:$^16.6LE}">(SV("$-1#234567E+03$$"), F(-1.234567e3));
1161 test<"{:016.6LE}">(SV("-0001#234567E+03"), F(-1.234567e3));
1162
1163 test<"{:$<15.6LE}">(SV("1.234567E+03$$$"), en_US, F(1.234567e3));
1164 test<"{:$>15.6LE}">(SV("$$$1.234567E+03"), en_US, F(1.234567e3));
1165 test<"{:$^15.6LE}">(SV("$1.234567E+03$$"), en_US, F(1.234567e3));
1166 test<"{:015.6LE}">(SV("0001.234567E+03"), en_US, F(1.234567e3));
1167 test<"{:$<16.6LE}">(SV("-1.234567E+03$$$"), en_US, F(-1.234567e3));
1168 test<"{:$>16.6LE}">(SV("$$$-1.234567E+03"), en_US, F(-1.234567e3));
1169 test<"{:$^16.6LE}">(SV("$-1.234567E+03$$"), en_US, F(-1.234567e3));
1170 test<"{:016.6LE}">(SV("-0001.234567E+03"), en_US, F(-1.234567e3));
1171
1172 std::locale::global(en_US);
1173 test<"{:$<15.6LE}">(SV("1#234567E+03$$$"), loc, F(1.234567e3));
1174 test<"{:$>15.6LE}">(SV("$$$1#234567E+03"), loc, F(1.234567e3));
1175 test<"{:$^15.6LE}">(SV("$1#234567E+03$$"), loc, F(1.234567e3));
1176 test<"{:015.6LE}">(SV("0001#234567E+03"), loc, F(1.234567e3));
1177 test<"{:$<16.6LE}">(SV("-1#234567E+03$$$"), loc, F(-1.234567e3));
1178 test<"{:$>16.6LE}">(SV("$$$-1#234567E+03"), loc, F(-1.234567e3));
1179 test<"{:$^16.6LE}">(SV("$-1#234567E+03$$"), loc, F(-1.234567e3));
1180 test<"{:016.6LE}">(SV("-0001#234567E+03"), loc, F(-1.234567e3));
1181 }
1182
1183 template <class F, class CharT>
test_floating_point_fixed_lower_case()1184 void test_floating_point_fixed_lower_case() {
1185 std::locale loc = std::locale(std::locale(), new numpunct<CharT>());
1186 std::locale en_US = std::locale(LOCALE_en_US_UTF_8);
1187
1188 // *** Basic ***
1189 std::locale::global(en_US);
1190 test<"{:.6Lf}">(SV("0.000001"), F(1.234567e-6));
1191 test<"{:.6Lf}">(SV("0.000012"), F(1.234567e-5));
1192 test<"{:.6Lf}">(SV("0.000123"), F(1.234567e-4));
1193 test<"{:.6Lf}">(SV("0.001235"), F(1.234567e-3));
1194 test<"{:.6Lf}">(SV("0.012346"), F(1.234567e-2));
1195 test<"{:.6Lf}">(SV("0.123457"), F(1.234567e-1));
1196 test<"{:.6Lf}">(SV("1.234567"), F(1.234567e0));
1197 test<"{:.6Lf}">(SV("12.345670"), F(1.234567e1));
1198 if constexpr (sizeof(F) > sizeof(float)) {
1199 test<"{:.6Lf}">(SV("123.456700"), F(1.234567e2));
1200 test<"{:.6Lf}">(SV("1,234.567000"), F(1.234567e3));
1201 test<"{:.6Lf}">(SV("12,345.670000"), F(1.234567e4));
1202 test<"{:.6Lf}">(SV("123,456.700000"), F(1.234567e5));
1203 test<"{:.6Lf}">(SV("1,234,567.000000"), F(1.234567e6));
1204 test<"{:.6Lf}">(SV("12,345,670.000000"), F(1.234567e7));
1205 test<"{:.6Lf}">(SV("123,456,700,000,000,000,000.000000"), F(1.234567e20));
1206 }
1207 test<"{:.6Lf}">(SV("-0.000001"), F(-1.234567e-6));
1208 test<"{:.6Lf}">(SV("-0.000012"), F(-1.234567e-5));
1209 test<"{:.6Lf}">(SV("-0.000123"), F(-1.234567e-4));
1210 test<"{:.6Lf}">(SV("-0.001235"), F(-1.234567e-3));
1211 test<"{:.6Lf}">(SV("-0.012346"), F(-1.234567e-2));
1212 test<"{:.6Lf}">(SV("-0.123457"), F(-1.234567e-1));
1213 test<"{:.6Lf}">(SV("-1.234567"), F(-1.234567e0));
1214 test<"{:.6Lf}">(SV("-12.345670"), F(-1.234567e1));
1215 if constexpr (sizeof(F) > sizeof(float)) {
1216 test<"{:.6Lf}">(SV("-123.456700"), F(-1.234567e2));
1217 test<"{:.6Lf}">(SV("-1,234.567000"), F(-1.234567e3));
1218 test<"{:.6Lf}">(SV("-12,345.670000"), F(-1.234567e4));
1219 test<"{:.6Lf}">(SV("-123,456.700000"), F(-1.234567e5));
1220 test<"{:.6Lf}">(SV("-1,234,567.000000"), F(-1.234567e6));
1221 test<"{:.6Lf}">(SV("-12,345,670.000000"), F(-1.234567e7));
1222 test<"{:.6Lf}">(SV("-123,456,700,000,000,000,000.000000"), F(-1.234567e20));
1223 }
1224
1225 std::locale::global(loc);
1226 test<"{:.6Lf}">(SV("0#000001"), F(1.234567e-6));
1227 test<"{:.6Lf}">(SV("0#000012"), F(1.234567e-5));
1228 test<"{:.6Lf}">(SV("0#000123"), F(1.234567e-4));
1229 test<"{:.6Lf}">(SV("0#001235"), F(1.234567e-3));
1230 test<"{:.6Lf}">(SV("0#012346"), F(1.234567e-2));
1231 test<"{:.6Lf}">(SV("0#123457"), F(1.234567e-1));
1232 test<"{:.6Lf}">(SV("1#234567"), F(1.234567e0));
1233 test<"{:.6Lf}">(SV("1_2#345670"), F(1.234567e1));
1234 if constexpr (sizeof(F) > sizeof(float)) {
1235 test<"{:.6Lf}">(SV("12_3#456700"), F(1.234567e2));
1236 test<"{:.6Lf}">(SV("1_23_4#567000"), F(1.234567e3));
1237 test<"{:.6Lf}">(SV("12_34_5#670000"), F(1.234567e4));
1238 test<"{:.6Lf}">(SV("123_45_6#700000"), F(1.234567e5));
1239 test<"{:.6Lf}">(SV("1_234_56_7#000000"), F(1.234567e6));
1240 test<"{:.6Lf}">(SV("12_345_67_0#000000"), F(1.234567e7));
1241 test<"{:.6Lf}">(SV("1_2_3_4_5_6_7_0_0_0_0_0_0_00_000_00_0#000000"), F(1.234567e20));
1242 }
1243 test<"{:.6Lf}">(SV("-0#000001"), F(-1.234567e-6));
1244 test<"{:.6Lf}">(SV("-0#000012"), F(-1.234567e-5));
1245 test<"{:.6Lf}">(SV("-0#000123"), F(-1.234567e-4));
1246 test<"{:.6Lf}">(SV("-0#001235"), F(-1.234567e-3));
1247 test<"{:.6Lf}">(SV("-0#012346"), F(-1.234567e-2));
1248 test<"{:.6Lf}">(SV("-0#123457"), F(-1.234567e-1));
1249 test<"{:.6Lf}">(SV("-1#234567"), F(-1.234567e0));
1250 test<"{:.6Lf}">(SV("-1_2#345670"), F(-1.234567e1));
1251 if constexpr (sizeof(F) > sizeof(float)) {
1252 test<"{:.6Lf}">(SV("-12_3#456700"), F(-1.234567e2));
1253 test<"{:.6Lf}">(SV("-1_23_4#567000"), F(-1.234567e3));
1254 test<"{:.6Lf}">(SV("-12_34_5#670000"), F(-1.234567e4));
1255 test<"{:.6Lf}">(SV("-123_45_6#700000"), F(-1.234567e5));
1256 test<"{:.6Lf}">(SV("-1_234_56_7#000000"), F(-1.234567e6));
1257 test<"{:.6Lf}">(SV("-12_345_67_0#000000"), F(-1.234567e7));
1258 test<"{:.6Lf}">(SV("-1_2_3_4_5_6_7_0_0_0_0_0_0_00_000_00_0#000000"), F(-1.234567e20));
1259 }
1260
1261 test<"{:.6Lf}">(SV("0.000001"), en_US, F(1.234567e-6));
1262 test<"{:.6Lf}">(SV("0.000012"), en_US, F(1.234567e-5));
1263 test<"{:.6Lf}">(SV("0.000123"), en_US, F(1.234567e-4));
1264 test<"{:.6Lf}">(SV("0.001235"), en_US, F(1.234567e-3));
1265 test<"{:.6Lf}">(SV("0.012346"), en_US, F(1.234567e-2));
1266 test<"{:.6Lf}">(SV("0.123457"), en_US, F(1.234567e-1));
1267 test<"{:.6Lf}">(SV("1.234567"), en_US, F(1.234567e0));
1268 test<"{:.6Lf}">(SV("12.345670"), en_US, F(1.234567e1));
1269 if constexpr (sizeof(F) > sizeof(float)) {
1270 test<"{:.6Lf}">(SV("123.456700"), en_US, F(1.234567e2));
1271 test<"{:.6Lf}">(SV("1,234.567000"), en_US, F(1.234567e3));
1272 test<"{:.6Lf}">(SV("12,345.670000"), en_US, F(1.234567e4));
1273 test<"{:.6Lf}">(SV("123,456.700000"), en_US, F(1.234567e5));
1274 test<"{:.6Lf}">(SV("1,234,567.000000"), en_US, F(1.234567e6));
1275 test<"{:.6Lf}">(SV("12,345,670.000000"), en_US, F(1.234567e7));
1276 test<"{:.6Lf}">(SV("123,456,700,000,000,000,000.000000"), en_US, F(1.234567e20));
1277 }
1278 test<"{:.6Lf}">(SV("-0.000001"), en_US, F(-1.234567e-6));
1279 test<"{:.6Lf}">(SV("-0.000012"), en_US, F(-1.234567e-5));
1280 test<"{:.6Lf}">(SV("-0.000123"), en_US, F(-1.234567e-4));
1281 test<"{:.6Lf}">(SV("-0.001235"), en_US, F(-1.234567e-3));
1282 test<"{:.6Lf}">(SV("-0.012346"), en_US, F(-1.234567e-2));
1283 test<"{:.6Lf}">(SV("-0.123457"), en_US, F(-1.234567e-1));
1284 test<"{:.6Lf}">(SV("-1.234567"), en_US, F(-1.234567e0));
1285 test<"{:.6Lf}">(SV("-12.345670"), en_US, F(-1.234567e1));
1286 if constexpr (sizeof(F) > sizeof(float)) {
1287 test<"{:.6Lf}">(SV("-123.456700"), en_US, F(-1.234567e2));
1288 test<"{:.6Lf}">(SV("-1,234.567000"), en_US, F(-1.234567e3));
1289 test<"{:.6Lf}">(SV("-12,345.670000"), en_US, F(-1.234567e4));
1290 test<"{:.6Lf}">(SV("-123,456.700000"), en_US, F(-1.234567e5));
1291 test<"{:.6Lf}">(SV("-1,234,567.000000"), en_US, F(-1.234567e6));
1292 test<"{:.6Lf}">(SV("-12,345,670.000000"), en_US, F(-1.234567e7));
1293 test<"{:.6Lf}">(SV("-123,456,700,000,000,000,000.000000"), en_US, F(-1.234567e20));
1294 }
1295
1296 std::locale::global(en_US);
1297 test<"{:.6Lf}">(SV("0#000001"), loc, F(1.234567e-6));
1298 test<"{:.6Lf}">(SV("0#000012"), loc, F(1.234567e-5));
1299 test<"{:.6Lf}">(SV("0#000123"), loc, F(1.234567e-4));
1300 test<"{:.6Lf}">(SV("0#001235"), loc, F(1.234567e-3));
1301 test<"{:.6Lf}">(SV("0#012346"), loc, F(1.234567e-2));
1302 test<"{:.6Lf}">(SV("0#123457"), loc, F(1.234567e-1));
1303 test<"{:.6Lf}">(SV("1#234567"), loc, F(1.234567e0));
1304 test<"{:.6Lf}">(SV("1_2#345670"), loc, F(1.234567e1));
1305 if constexpr (sizeof(F) > sizeof(float)) {
1306 test<"{:.6Lf}">(SV("12_3#456700"), loc, F(1.234567e2));
1307 test<"{:.6Lf}">(SV("1_23_4#567000"), loc, F(1.234567e3));
1308 test<"{:.6Lf}">(SV("12_34_5#670000"), loc, F(1.234567e4));
1309 test<"{:.6Lf}">(SV("123_45_6#700000"), loc, F(1.234567e5));
1310 test<"{:.6Lf}">(SV("1_234_56_7#000000"), loc, F(1.234567e6));
1311 test<"{:.6Lf}">(SV("12_345_67_0#000000"), loc, F(1.234567e7));
1312 test<"{:.6Lf}">(SV("1_2_3_4_5_6_7_0_0_0_0_0_0_00_000_00_0#000000"), loc, F(1.234567e20));
1313 }
1314 test<"{:.6Lf}">(SV("-0#000001"), loc, F(-1.234567e-6));
1315 test<"{:.6Lf}">(SV("-0#000012"), loc, F(-1.234567e-5));
1316 test<"{:.6Lf}">(SV("-0#000123"), loc, F(-1.234567e-4));
1317 test<"{:.6Lf}">(SV("-0#001235"), loc, F(-1.234567e-3));
1318 test<"{:.6Lf}">(SV("-0#012346"), loc, F(-1.234567e-2));
1319 test<"{:.6Lf}">(SV("-0#123457"), loc, F(-1.234567e-1));
1320 test<"{:.6Lf}">(SV("-1#234567"), loc, F(-1.234567e0));
1321 test<"{:.6Lf}">(SV("-1_2#345670"), loc, F(-1.234567e1));
1322 if constexpr (sizeof(F) > sizeof(float)) {
1323 test<"{:.6Lf}">(SV("-12_3#456700"), loc, F(-1.234567e2));
1324 test<"{:.6Lf}">(SV("-1_23_4#567000"), loc, F(-1.234567e3));
1325 test<"{:.6Lf}">(SV("-12_34_5#670000"), loc, F(-1.234567e4));
1326 test<"{:.6Lf}">(SV("-123_45_6#700000"), loc, F(-1.234567e5));
1327 test<"{:.6Lf}">(SV("-1_234_56_7#000000"), loc, F(-1.234567e6));
1328 test<"{:.6Lf}">(SV("-12_345_67_0#000000"), loc, F(-1.234567e7));
1329 test<"{:.6Lf}">(SV("-1_2_3_4_5_6_7_0_0_0_0_0_0_00_000_00_0#000000"), loc, F(-1.234567e20));
1330 }
1331
1332 // *** Fill, align, zero padding ***
1333 if constexpr (sizeof(F) > sizeof(float)) {
1334 std::locale::global(en_US);
1335 test<"{:$<15.6Lf}">(SV("1,234.567000$$$"), F(1.234567e3));
1336 test<"{:$>15.6Lf}">(SV("$$$1,234.567000"), F(1.234567e3));
1337 test<"{:$^15.6Lf}">(SV("$1,234.567000$$"), F(1.234567e3));
1338 test<"{:015.6Lf}">(SV("0001,234.567000"), F(1.234567e3));
1339 test<"{:$<16.6Lf}">(SV("-1,234.567000$$$"), F(-1.234567e3));
1340 test<"{:$>16.6Lf}">(SV("$$$-1,234.567000"), F(-1.234567e3));
1341 test<"{:$^16.6Lf}">(SV("$-1,234.567000$$"), F(-1.234567e3));
1342 test<"{:016.6Lf}">(SV("-0001,234.567000"), F(-1.234567e3));
1343
1344 std::locale::global(loc);
1345 test<"{:$<16.6Lf}">(SV("1_23_4#567000$$$"), F(1.234567e3));
1346 test<"{:$>16.6Lf}">(SV("$$$1_23_4#567000"), F(1.234567e3));
1347 test<"{:$^16.6Lf}">(SV("$1_23_4#567000$$"), F(1.234567e3));
1348 test<"{:016.6Lf}">(SV("0001_23_4#567000"), F(1.234567e3));
1349 test<"{:$<17.6Lf}">(SV("-1_23_4#567000$$$"), F(-1.234567e3));
1350 test<"{:$>17.6Lf}">(SV("$$$-1_23_4#567000"), F(-1.234567e3));
1351 test<"{:$^17.6Lf}">(SV("$-1_23_4#567000$$"), F(-1.234567e3));
1352 test<"{:017.6Lf}">(SV("-0001_23_4#567000"), F(-1.234567e3));
1353
1354 test<"{:$<15.6Lf}">(SV("1,234.567000$$$"), en_US, F(1.234567e3));
1355 test<"{:$>15.6Lf}">(SV("$$$1,234.567000"), en_US, F(1.234567e3));
1356 test<"{:$^15.6Lf}">(SV("$1,234.567000$$"), en_US, F(1.234567e3));
1357 test<"{:015.6Lf}">(SV("0001,234.567000"), en_US, F(1.234567e3));
1358 test<"{:$<16.6Lf}">(SV("-1,234.567000$$$"), en_US, F(-1.234567e3));
1359 test<"{:$>16.6Lf}">(SV("$$$-1,234.567000"), en_US, F(-1.234567e3));
1360 test<"{:$^16.6Lf}">(SV("$-1,234.567000$$"), en_US, F(-1.234567e3));
1361 test<"{:016.6Lf}">(SV("-0001,234.567000"), en_US, F(-1.234567e3));
1362
1363 std::locale::global(en_US);
1364 test<"{:$<16.6Lf}">(SV("1_23_4#567000$$$"), loc, F(1.234567e3));
1365 test<"{:$>16.6Lf}">(SV("$$$1_23_4#567000"), loc, F(1.234567e3));
1366 test<"{:$^16.6Lf}">(SV("$1_23_4#567000$$"), loc, F(1.234567e3));
1367 test<"{:016.6Lf}">(SV("0001_23_4#567000"), loc, F(1.234567e3));
1368 test<"{:$<17.6Lf}">(SV("-1_23_4#567000$$$"), loc, F(-1.234567e3));
1369 test<"{:$>17.6Lf}">(SV("$$$-1_23_4#567000"), loc, F(-1.234567e3));
1370 test<"{:$^17.6Lf}">(SV("$-1_23_4#567000$$"), loc, F(-1.234567e3));
1371 test<"{:017.6Lf}">(SV("-0001_23_4#567000"), loc, F(-1.234567e3));
1372 }
1373 }
1374
1375 template <class F, class CharT>
test_floating_point_fixed_upper_case()1376 void test_floating_point_fixed_upper_case() {
1377 std::locale loc = std::locale(std::locale(), new numpunct<CharT>());
1378 std::locale en_US = std::locale(LOCALE_en_US_UTF_8);
1379
1380 // *** Basic ***
1381 std::locale::global(en_US);
1382 test<"{:.6Lf}">(SV("0.000001"), F(1.234567e-6));
1383 test<"{:.6Lf}">(SV("0.000012"), F(1.234567e-5));
1384 test<"{:.6Lf}">(SV("0.000123"), F(1.234567e-4));
1385 test<"{:.6Lf}">(SV("0.001235"), F(1.234567e-3));
1386 test<"{:.6Lf}">(SV("0.012346"), F(1.234567e-2));
1387 test<"{:.6Lf}">(SV("0.123457"), F(1.234567e-1));
1388 test<"{:.6Lf}">(SV("1.234567"), F(1.234567e0));
1389 test<"{:.6Lf}">(SV("12.345670"), F(1.234567e1));
1390 if constexpr (sizeof(F) > sizeof(float)) {
1391 test<"{:.6Lf}">(SV("123.456700"), F(1.234567e2));
1392 test<"{:.6Lf}">(SV("1,234.567000"), F(1.234567e3));
1393 test<"{:.6Lf}">(SV("12,345.670000"), F(1.234567e4));
1394 test<"{:.6Lf}">(SV("123,456.700000"), F(1.234567e5));
1395 test<"{:.6Lf}">(SV("1,234,567.000000"), F(1.234567e6));
1396 test<"{:.6Lf}">(SV("12,345,670.000000"), F(1.234567e7));
1397 test<"{:.6Lf}">(SV("123,456,700,000,000,000,000.000000"), F(1.234567e20));
1398 }
1399 test<"{:.6Lf}">(SV("-0.000001"), F(-1.234567e-6));
1400 test<"{:.6Lf}">(SV("-0.000012"), F(-1.234567e-5));
1401 test<"{:.6Lf}">(SV("-0.000123"), F(-1.234567e-4));
1402 test<"{:.6Lf}">(SV("-0.001235"), F(-1.234567e-3));
1403 test<"{:.6Lf}">(SV("-0.012346"), F(-1.234567e-2));
1404 test<"{:.6Lf}">(SV("-0.123457"), F(-1.234567e-1));
1405 test<"{:.6Lf}">(SV("-1.234567"), F(-1.234567e0));
1406 test<"{:.6Lf}">(SV("-12.345670"), F(-1.234567e1));
1407 if constexpr (sizeof(F) > sizeof(float)) {
1408 test<"{:.6Lf}">(SV("-123.456700"), F(-1.234567e2));
1409 test<"{:.6Lf}">(SV("-1,234.567000"), F(-1.234567e3));
1410 test<"{:.6Lf}">(SV("-12,345.670000"), F(-1.234567e4));
1411 test<"{:.6Lf}">(SV("-123,456.700000"), F(-1.234567e5));
1412 test<"{:.6Lf}">(SV("-1,234,567.000000"), F(-1.234567e6));
1413 test<"{:.6Lf}">(SV("-12,345,670.000000"), F(-1.234567e7));
1414 test<"{:.6Lf}">(SV("-123,456,700,000,000,000,000.000000"), F(-1.234567e20));
1415 }
1416
1417 std::locale::global(loc);
1418 test<"{:.6Lf}">(SV("0#000001"), F(1.234567e-6));
1419 test<"{:.6Lf}">(SV("0#000012"), F(1.234567e-5));
1420 test<"{:.6Lf}">(SV("0#000123"), F(1.234567e-4));
1421 test<"{:.6Lf}">(SV("0#001235"), F(1.234567e-3));
1422 test<"{:.6Lf}">(SV("0#012346"), F(1.234567e-2));
1423 test<"{:.6Lf}">(SV("0#123457"), F(1.234567e-1));
1424 test<"{:.6Lf}">(SV("1#234567"), F(1.234567e0));
1425 test<"{:.6Lf}">(SV("1_2#345670"), F(1.234567e1));
1426 if constexpr (sizeof(F) > sizeof(float)) {
1427 test<"{:.6Lf}">(SV("12_3#456700"), F(1.234567e2));
1428 test<"{:.6Lf}">(SV("1_23_4#567000"), F(1.234567e3));
1429 test<"{:.6Lf}">(SV("12_34_5#670000"), F(1.234567e4));
1430 test<"{:.6Lf}">(SV("123_45_6#700000"), F(1.234567e5));
1431 test<"{:.6Lf}">(SV("1_234_56_7#000000"), F(1.234567e6));
1432 test<"{:.6Lf}">(SV("12_345_67_0#000000"), F(1.234567e7));
1433 test<"{:.6Lf}">(SV("1_2_3_4_5_6_7_0_0_0_0_0_0_00_000_00_0#000000"), F(1.234567e20));
1434 }
1435 test<"{:.6Lf}">(SV("-0#000001"), F(-1.234567e-6));
1436 test<"{:.6Lf}">(SV("-0#000012"), F(-1.234567e-5));
1437 test<"{:.6Lf}">(SV("-0#000123"), F(-1.234567e-4));
1438 test<"{:.6Lf}">(SV("-0#001235"), F(-1.234567e-3));
1439 test<"{:.6Lf}">(SV("-0#012346"), F(-1.234567e-2));
1440 test<"{:.6Lf}">(SV("-0#123457"), F(-1.234567e-1));
1441 test<"{:.6Lf}">(SV("-1#234567"), F(-1.234567e0));
1442 test<"{:.6Lf}">(SV("-1_2#345670"), F(-1.234567e1));
1443 if constexpr (sizeof(F) > sizeof(float)) {
1444 test<"{:.6Lf}">(SV("-12_3#456700"), F(-1.234567e2));
1445 test<"{:.6Lf}">(SV("-1_23_4#567000"), F(-1.234567e3));
1446 test<"{:.6Lf}">(SV("-12_34_5#670000"), F(-1.234567e4));
1447 test<"{:.6Lf}">(SV("-123_45_6#700000"), F(-1.234567e5));
1448 test<"{:.6Lf}">(SV("-1_234_56_7#000000"), F(-1.234567e6));
1449 test<"{:.6Lf}">(SV("-12_345_67_0#000000"), F(-1.234567e7));
1450 test<"{:.6Lf}">(SV("-1_2_3_4_5_6_7_0_0_0_0_0_0_00_000_00_0#000000"), F(-1.234567e20));
1451 }
1452
1453 test<"{:.6Lf}">(SV("0.000001"), en_US, F(1.234567e-6));
1454 test<"{:.6Lf}">(SV("0.000012"), en_US, F(1.234567e-5));
1455 test<"{:.6Lf}">(SV("0.000123"), en_US, F(1.234567e-4));
1456 test<"{:.6Lf}">(SV("0.001235"), en_US, F(1.234567e-3));
1457 test<"{:.6Lf}">(SV("0.012346"), en_US, F(1.234567e-2));
1458 test<"{:.6Lf}">(SV("0.123457"), en_US, F(1.234567e-1));
1459 test<"{:.6Lf}">(SV("1.234567"), en_US, F(1.234567e0));
1460 test<"{:.6Lf}">(SV("12.345670"), en_US, F(1.234567e1));
1461 if constexpr (sizeof(F) > sizeof(float)) {
1462 test<"{:.6Lf}">(SV("123.456700"), en_US, F(1.234567e2));
1463 test<"{:.6Lf}">(SV("1,234.567000"), en_US, F(1.234567e3));
1464 test<"{:.6Lf}">(SV("12,345.670000"), en_US, F(1.234567e4));
1465 test<"{:.6Lf}">(SV("123,456.700000"), en_US, F(1.234567e5));
1466 test<"{:.6Lf}">(SV("1,234,567.000000"), en_US, F(1.234567e6));
1467 test<"{:.6Lf}">(SV("12,345,670.000000"), en_US, F(1.234567e7));
1468 test<"{:.6Lf}">(SV("123,456,700,000,000,000,000.000000"), en_US, F(1.234567e20));
1469 }
1470 test<"{:.6Lf}">(SV("-0.000001"), en_US, F(-1.234567e-6));
1471 test<"{:.6Lf}">(SV("-0.000012"), en_US, F(-1.234567e-5));
1472 test<"{:.6Lf}">(SV("-0.000123"), en_US, F(-1.234567e-4));
1473 test<"{:.6Lf}">(SV("-0.001235"), en_US, F(-1.234567e-3));
1474 test<"{:.6Lf}">(SV("-0.012346"), en_US, F(-1.234567e-2));
1475 test<"{:.6Lf}">(SV("-0.123457"), en_US, F(-1.234567e-1));
1476 test<"{:.6Lf}">(SV("-1.234567"), en_US, F(-1.234567e0));
1477 test<"{:.6Lf}">(SV("-12.345670"), en_US, F(-1.234567e1));
1478 if constexpr (sizeof(F) > sizeof(float)) {
1479 test<"{:.6Lf}">(SV("-123.456700"), en_US, F(-1.234567e2));
1480 test<"{:.6Lf}">(SV("-1,234.567000"), en_US, F(-1.234567e3));
1481 test<"{:.6Lf}">(SV("-12,345.670000"), en_US, F(-1.234567e4));
1482 test<"{:.6Lf}">(SV("-123,456.700000"), en_US, F(-1.234567e5));
1483 test<"{:.6Lf}">(SV("-1,234,567.000000"), en_US, F(-1.234567e6));
1484 test<"{:.6Lf}">(SV("-12,345,670.000000"), en_US, F(-1.234567e7));
1485 test<"{:.6Lf}">(SV("-123,456,700,000,000,000,000.000000"), en_US, F(-1.234567e20));
1486 }
1487
1488 std::locale::global(en_US);
1489 test<"{:.6Lf}">(SV("0#000001"), loc, F(1.234567e-6));
1490 test<"{:.6Lf}">(SV("0#000012"), loc, F(1.234567e-5));
1491 test<"{:.6Lf}">(SV("0#000123"), loc, F(1.234567e-4));
1492 test<"{:.6Lf}">(SV("0#001235"), loc, F(1.234567e-3));
1493 test<"{:.6Lf}">(SV("0#012346"), loc, F(1.234567e-2));
1494 test<"{:.6Lf}">(SV("0#123457"), loc, F(1.234567e-1));
1495 test<"{:.6Lf}">(SV("1#234567"), loc, F(1.234567e0));
1496 test<"{:.6Lf}">(SV("1_2#345670"), loc, F(1.234567e1));
1497 if constexpr (sizeof(F) > sizeof(float)) {
1498 test<"{:.6Lf}">(SV("12_3#456700"), loc, F(1.234567e2));
1499 test<"{:.6Lf}">(SV("1_23_4#567000"), loc, F(1.234567e3));
1500 test<"{:.6Lf}">(SV("12_34_5#670000"), loc, F(1.234567e4));
1501 test<"{:.6Lf}">(SV("123_45_6#700000"), loc, F(1.234567e5));
1502 test<"{:.6Lf}">(SV("1_234_56_7#000000"), loc, F(1.234567e6));
1503 test<"{:.6Lf}">(SV("12_345_67_0#000000"), loc, F(1.234567e7));
1504 test<"{:.6Lf}">(SV("1_2_3_4_5_6_7_0_0_0_0_0_0_00_000_00_0#000000"), loc, F(1.234567e20));
1505 }
1506 test<"{:.6Lf}">(SV("-0#000001"), loc, F(-1.234567e-6));
1507 test<"{:.6Lf}">(SV("-0#000012"), loc, F(-1.234567e-5));
1508 test<"{:.6Lf}">(SV("-0#000123"), loc, F(-1.234567e-4));
1509 test<"{:.6Lf}">(SV("-0#001235"), loc, F(-1.234567e-3));
1510 test<"{:.6Lf}">(SV("-0#012346"), loc, F(-1.234567e-2));
1511 test<"{:.6Lf}">(SV("-0#123457"), loc, F(-1.234567e-1));
1512 test<"{:.6Lf}">(SV("-1#234567"), loc, F(-1.234567e0));
1513 test<"{:.6Lf}">(SV("-1_2#345670"), loc, F(-1.234567e1));
1514 if constexpr (sizeof(F) > sizeof(float)) {
1515 test<"{:.6Lf}">(SV("-12_3#456700"), loc, F(-1.234567e2));
1516 test<"{:.6Lf}">(SV("-1_23_4#567000"), loc, F(-1.234567e3));
1517 test<"{:.6Lf}">(SV("-12_34_5#670000"), loc, F(-1.234567e4));
1518 test<"{:.6Lf}">(SV("-123_45_6#700000"), loc, F(-1.234567e5));
1519 test<"{:.6Lf}">(SV("-1_234_56_7#000000"), loc, F(-1.234567e6));
1520 test<"{:.6Lf}">(SV("-12_345_67_0#000000"), loc, F(-1.234567e7));
1521 test<"{:.6Lf}">(SV("-1_2_3_4_5_6_7_0_0_0_0_0_0_00_000_00_0#000000"), loc, F(-1.234567e20));
1522 }
1523
1524 // *** Fill, align, zero padding ***
1525 if constexpr (sizeof(F) > sizeof(float)) {
1526 std::locale::global(en_US);
1527 test<"{:$<15.6Lf}">(SV("1,234.567000$$$"), F(1.234567e3));
1528 test<"{:$>15.6Lf}">(SV("$$$1,234.567000"), F(1.234567e3));
1529 test<"{:$^15.6Lf}">(SV("$1,234.567000$$"), F(1.234567e3));
1530 test<"{:015.6Lf}">(SV("0001,234.567000"), F(1.234567e3));
1531 test<"{:$<16.6Lf}">(SV("-1,234.567000$$$"), F(-1.234567e3));
1532 test<"{:$>16.6Lf}">(SV("$$$-1,234.567000"), F(-1.234567e3));
1533 test<"{:$^16.6Lf}">(SV("$-1,234.567000$$"), F(-1.234567e3));
1534 test<"{:016.6Lf}">(SV("-0001,234.567000"), F(-1.234567e3));
1535
1536 std::locale::global(loc);
1537 test<"{:$<16.6Lf}">(SV("1_23_4#567000$$$"), F(1.234567e3));
1538 test<"{:$>16.6Lf}">(SV("$$$1_23_4#567000"), F(1.234567e3));
1539 test<"{:$^16.6Lf}">(SV("$1_23_4#567000$$"), F(1.234567e3));
1540 test<"{:016.6Lf}">(SV("0001_23_4#567000"), F(1.234567e3));
1541 test<"{:$<17.6Lf}">(SV("-1_23_4#567000$$$"), F(-1.234567e3));
1542 test<"{:$>17.6Lf}">(SV("$$$-1_23_4#567000"), F(-1.234567e3));
1543 test<"{:$^17.6Lf}">(SV("$-1_23_4#567000$$"), F(-1.234567e3));
1544 test<"{:017.6Lf}">(SV("-0001_23_4#567000"), F(-1.234567e3));
1545
1546 test<"{:$<15.6Lf}">(SV("1,234.567000$$$"), en_US, F(1.234567e3));
1547 test<"{:$>15.6Lf}">(SV("$$$1,234.567000"), en_US, F(1.234567e3));
1548 test<"{:$^15.6Lf}">(SV("$1,234.567000$$"), en_US, F(1.234567e3));
1549 test<"{:015.6Lf}">(SV("0001,234.567000"), en_US, F(1.234567e3));
1550 test<"{:$<16.6Lf}">(SV("-1,234.567000$$$"), en_US, F(-1.234567e3));
1551 test<"{:$>16.6Lf}">(SV("$$$-1,234.567000"), en_US, F(-1.234567e3));
1552 test<"{:$^16.6Lf}">(SV("$-1,234.567000$$"), en_US, F(-1.234567e3));
1553 test<"{:016.6Lf}">(SV("-0001,234.567000"), en_US, F(-1.234567e3));
1554
1555 std::locale::global(en_US);
1556 test<"{:$<16.6Lf}">(SV("1_23_4#567000$$$"), loc, F(1.234567e3));
1557 test<"{:$>16.6Lf}">(SV("$$$1_23_4#567000"), loc, F(1.234567e3));
1558 test<"{:$^16.6Lf}">(SV("$1_23_4#567000$$"), loc, F(1.234567e3));
1559 test<"{:016.6Lf}">(SV("0001_23_4#567000"), loc, F(1.234567e3));
1560 test<"{:$<17.6Lf}">(SV("-1_23_4#567000$$$"), loc, F(-1.234567e3));
1561 test<"{:$>17.6Lf}">(SV("$$$-1_23_4#567000"), loc, F(-1.234567e3));
1562 test<"{:$^17.6Lf}">(SV("$-1_23_4#567000$$"), loc, F(-1.234567e3));
1563 test<"{:017.6Lf}">(SV("-0001_23_4#567000"), loc, F(-1.234567e3));
1564 }
1565 }
1566
1567 template <class F, class CharT>
test_floating_point_general_lower_case()1568 void test_floating_point_general_lower_case() {
1569 std::locale loc = std::locale(std::locale(), new numpunct<CharT>());
1570 std::locale en_US = std::locale(LOCALE_en_US_UTF_8);
1571
1572 // *** Basic ***
1573 std::locale::global(en_US);
1574 test<"{:.6Lg}">(SV("1.23457e-06"), F(1.234567e-6));
1575 test<"{:.6Lg}">(SV("1.23457e-05"), F(1.234567e-5));
1576 test<"{:.6Lg}">(SV("0.000123457"), F(1.234567e-4));
1577 test<"{:.6Lg}">(SV("0.00123457"), F(1.234567e-3));
1578 test<"{:.6Lg}">(SV("0.0123457"), F(1.234567e-2));
1579 test<"{:.6Lg}">(SV("0.123457"), F(1.234567e-1));
1580 test<"{:.6Lg}">(SV("1.23457"), F(1.234567e0));
1581 test<"{:.6Lg}">(SV("12.3457"), F(1.234567e1));
1582 test<"{:.6Lg}">(SV("123.457"), F(1.234567e2));
1583 test<"{:.6Lg}">(SV("1,234.57"), F(1.234567e3));
1584 test<"{:.6Lg}">(SV("12,345.7"), F(1.234567e4));
1585 test<"{:.6Lg}">(SV("123,457"), F(1.234567e5));
1586 test<"{:.6Lg}">(SV("1.23457e+06"), F(1.234567e6));
1587 test<"{:.6Lg}">(SV("1.23457e+07"), F(1.234567e7));
1588 test<"{:.6Lg}">(SV("-1.23457e-06"), F(-1.234567e-6));
1589 test<"{:.6Lg}">(SV("-1.23457e-05"), F(-1.234567e-5));
1590 test<"{:.6Lg}">(SV("-0.000123457"), F(-1.234567e-4));
1591 test<"{:.6Lg}">(SV("-0.00123457"), F(-1.234567e-3));
1592 test<"{:.6Lg}">(SV("-0.0123457"), F(-1.234567e-2));
1593 test<"{:.6Lg}">(SV("-0.123457"), F(-1.234567e-1));
1594 test<"{:.6Lg}">(SV("-1.23457"), F(-1.234567e0));
1595 test<"{:.6Lg}">(SV("-12.3457"), F(-1.234567e1));
1596 test<"{:.6Lg}">(SV("-123.457"), F(-1.234567e2));
1597 test<"{:.6Lg}">(SV("-1,234.57"), F(-1.234567e3));
1598 test<"{:.6Lg}">(SV("-12,345.7"), F(-1.234567e4));
1599 test<"{:.6Lg}">(SV("-123,457"), F(-1.234567e5));
1600 test<"{:.6Lg}">(SV("-1.23457e+06"), F(-1.234567e6));
1601 test<"{:.6Lg}">(SV("-1.23457e+07"), F(-1.234567e7));
1602
1603 std::locale::global(loc);
1604 test<"{:.6Lg}">(SV("1#23457e-06"), F(1.234567e-6));
1605 test<"{:.6Lg}">(SV("1#23457e-05"), F(1.234567e-5));
1606 test<"{:.6Lg}">(SV("0#000123457"), F(1.234567e-4));
1607 test<"{:.6Lg}">(SV("0#00123457"), F(1.234567e-3));
1608 test<"{:.6Lg}">(SV("0#0123457"), F(1.234567e-2));
1609 test<"{:.6Lg}">(SV("0#123457"), F(1.234567e-1));
1610 test<"{:.6Lg}">(SV("1#23457"), F(1.234567e0));
1611 test<"{:.6Lg}">(SV("1_2#3457"), F(1.234567e1));
1612 test<"{:.6Lg}">(SV("12_3#457"), F(1.234567e2));
1613 test<"{:.6Lg}">(SV("1_23_4#57"), F(1.234567e3));
1614 test<"{:.6Lg}">(SV("12_34_5#7"), F(1.234567e4));
1615 test<"{:.6Lg}">(SV("123_45_7"), F(1.234567e5));
1616 test<"{:.6Lg}">(SV("1#23457e+06"), F(1.234567e6));
1617 test<"{:.6Lg}">(SV("1#23457e+07"), F(1.234567e7));
1618 test<"{:.6Lg}">(SV("-1#23457e-06"), F(-1.234567e-6));
1619 test<"{:.6Lg}">(SV("-1#23457e-05"), F(-1.234567e-5));
1620 test<"{:.6Lg}">(SV("-0#000123457"), F(-1.234567e-4));
1621 test<"{:.6Lg}">(SV("-0#00123457"), F(-1.234567e-3));
1622 test<"{:.6Lg}">(SV("-0#0123457"), F(-1.234567e-2));
1623 test<"{:.6Lg}">(SV("-0#123457"), F(-1.234567e-1));
1624 test<"{:.6Lg}">(SV("-1#23457"), F(-1.234567e0));
1625 test<"{:.6Lg}">(SV("-1_2#3457"), F(-1.234567e1));
1626 test<"{:.6Lg}">(SV("-12_3#457"), F(-1.234567e2));
1627 test<"{:.6Lg}">(SV("-1_23_4#57"), F(-1.234567e3));
1628 test<"{:.6Lg}">(SV("-12_34_5#7"), F(-1.234567e4));
1629 test<"{:.6Lg}">(SV("-123_45_7"), F(-1.234567e5));
1630 test<"{:.6Lg}">(SV("-1#23457e+06"), F(-1.234567e6));
1631 test<"{:.6Lg}">(SV("-1#23457e+07"), F(-1.234567e7));
1632
1633 test<"{:.6Lg}">(SV("1.23457e-06"), en_US, F(1.234567e-6));
1634 test<"{:.6Lg}">(SV("1.23457e-05"), en_US, F(1.234567e-5));
1635 test<"{:.6Lg}">(SV("0.000123457"), en_US, F(1.234567e-4));
1636 test<"{:.6Lg}">(SV("0.00123457"), en_US, F(1.234567e-3));
1637 test<"{:.6Lg}">(SV("0.0123457"), en_US, F(1.234567e-2));
1638 test<"{:.6Lg}">(SV("0.123457"), en_US, F(1.234567e-1));
1639 test<"{:.6Lg}">(SV("1.23457"), en_US, F(1.234567e0));
1640 test<"{:.6Lg}">(SV("12.3457"), en_US, F(1.234567e1));
1641 test<"{:.6Lg}">(SV("123.457"), en_US, F(1.234567e2));
1642 test<"{:.6Lg}">(SV("1,234.57"), en_US, F(1.234567e3));
1643 test<"{:.6Lg}">(SV("12,345.7"), en_US, F(1.234567e4));
1644 test<"{:.6Lg}">(SV("123,457"), en_US, F(1.234567e5));
1645 test<"{:.6Lg}">(SV("1.23457e+06"), en_US, F(1.234567e6));
1646 test<"{:.6Lg}">(SV("1.23457e+07"), en_US, F(1.234567e7));
1647 test<"{:.6Lg}">(SV("-1.23457e-06"), en_US, F(-1.234567e-6));
1648 test<"{:.6Lg}">(SV("-1.23457e-05"), en_US, F(-1.234567e-5));
1649 test<"{:.6Lg}">(SV("-0.000123457"), en_US, F(-1.234567e-4));
1650 test<"{:.6Lg}">(SV("-0.00123457"), en_US, F(-1.234567e-3));
1651 test<"{:.6Lg}">(SV("-0.0123457"), en_US, F(-1.234567e-2));
1652 test<"{:.6Lg}">(SV("-0.123457"), en_US, F(-1.234567e-1));
1653 test<"{:.6Lg}">(SV("-1.23457"), en_US, F(-1.234567e0));
1654 test<"{:.6Lg}">(SV("-12.3457"), en_US, F(-1.234567e1));
1655 test<"{:.6Lg}">(SV("-123.457"), en_US, F(-1.234567e2));
1656 test<"{:.6Lg}">(SV("-1,234.57"), en_US, F(-1.234567e3));
1657 test<"{:.6Lg}">(SV("-12,345.7"), en_US, F(-1.234567e4));
1658 test<"{:.6Lg}">(SV("-123,457"), en_US, F(-1.234567e5));
1659 test<"{:.6Lg}">(SV("-1.23457e+06"), en_US, F(-1.234567e6));
1660 test<"{:.6Lg}">(SV("-1.23457e+07"), en_US, F(-1.234567e7));
1661
1662 std::locale::global(en_US);
1663 test<"{:.6Lg}">(SV("1#23457e-06"), loc, F(1.234567e-6));
1664 test<"{:.6Lg}">(SV("1#23457e-05"), loc, F(1.234567e-5));
1665 test<"{:.6Lg}">(SV("0#000123457"), loc, F(1.234567e-4));
1666 test<"{:.6Lg}">(SV("0#00123457"), loc, F(1.234567e-3));
1667 test<"{:.6Lg}">(SV("0#0123457"), loc, F(1.234567e-2));
1668 test<"{:.6Lg}">(SV("0#123457"), loc, F(1.234567e-1));
1669 test<"{:.6Lg}">(SV("1#23457"), loc, F(1.234567e0));
1670 test<"{:.6Lg}">(SV("1_2#3457"), loc, F(1.234567e1));
1671 test<"{:.6Lg}">(SV("12_3#457"), loc, F(1.234567e2));
1672 test<"{:.6Lg}">(SV("1_23_4#57"), loc, F(1.234567e3));
1673 test<"{:.6Lg}">(SV("12_34_5#7"), loc, F(1.234567e4));
1674 test<"{:.6Lg}">(SV("123_45_7"), loc, F(1.234567e5));
1675 test<"{:.6Lg}">(SV("1#23457e+06"), loc, F(1.234567e6));
1676 test<"{:.6Lg}">(SV("1#23457e+07"), loc, F(1.234567e7));
1677 test<"{:.6Lg}">(SV("-1#23457e-06"), loc, F(-1.234567e-6));
1678 test<"{:.6Lg}">(SV("-1#23457e-05"), loc, F(-1.234567e-5));
1679 test<"{:.6Lg}">(SV("-0#000123457"), loc, F(-1.234567e-4));
1680 test<"{:.6Lg}">(SV("-0#00123457"), loc, F(-1.234567e-3));
1681 test<"{:.6Lg}">(SV("-0#0123457"), loc, F(-1.234567e-2));
1682 test<"{:.6Lg}">(SV("-0#123457"), loc, F(-1.234567e-1));
1683 test<"{:.6Lg}">(SV("-1#23457"), loc, F(-1.234567e0));
1684 test<"{:.6Lg}">(SV("-1_2#3457"), loc, F(-1.234567e1));
1685 test<"{:.6Lg}">(SV("-12_3#457"), loc, F(-1.234567e2));
1686 test<"{:.6Lg}">(SV("-1_23_4#57"), loc, F(-1.234567e3));
1687 test<"{:.6Lg}">(SV("-12_34_5#7"), loc, F(-1.234567e4));
1688 test<"{:.6Lg}">(SV("-123_45_7"), loc, F(-1.234567e5));
1689 test<"{:.6Lg}">(SV("-1#23457e+06"), loc, F(-1.234567e6));
1690 test<"{:.6Lg}">(SV("-1#23457e+07"), loc, F(-1.234567e7));
1691
1692 // *** Fill, align, zero padding ***
1693 std::locale::global(en_US);
1694 test<"{:$<11.6Lg}">(SV("1,234.57$$$"), F(1.234567e3));
1695 test<"{:$>11.6Lg}">(SV("$$$1,234.57"), F(1.234567e3));
1696 test<"{:$^11.6Lg}">(SV("$1,234.57$$"), F(1.234567e3));
1697 test<"{:011.6Lg}">(SV("0001,234.57"), F(1.234567e3));
1698 test<"{:$<12.6Lg}">(SV("-1,234.57$$$"), F(-1.234567e3));
1699 test<"{:$>12.6Lg}">(SV("$$$-1,234.57"), F(-1.234567e3));
1700 test<"{:$^12.6Lg}">(SV("$-1,234.57$$"), F(-1.234567e3));
1701 test<"{:012.6Lg}">(SV("-0001,234.57"), F(-1.234567e3));
1702
1703 std::locale::global(loc);
1704 test<"{:$<12.6Lg}">(SV("1_23_4#57$$$"), F(1.234567e3));
1705 test<"{:$>12.6Lg}">(SV("$$$1_23_4#57"), F(1.234567e3));
1706 test<"{:$^12.6Lg}">(SV("$1_23_4#57$$"), F(1.234567e3));
1707 test<"{:012.6Lg}">(SV("0001_23_4#57"), F(1.234567e3));
1708 test<"{:$<13.6Lg}">(SV("-1_23_4#57$$$"), F(-1.234567e3));
1709 test<"{:$>13.6Lg}">(SV("$$$-1_23_4#57"), F(-1.234567e3));
1710 test<"{:$^13.6Lg}">(SV("$-1_23_4#57$$"), F(-1.234567e3));
1711 test<"{:013.6Lg}">(SV("-0001_23_4#57"), F(-1.234567e3));
1712
1713 test<"{:$<11.6Lg}">(SV("1,234.57$$$"), en_US, F(1.234567e3));
1714 test<"{:$>11.6Lg}">(SV("$$$1,234.57"), en_US, F(1.234567e3));
1715 test<"{:$^11.6Lg}">(SV("$1,234.57$$"), en_US, F(1.234567e3));
1716 test<"{:011.6Lg}">(SV("0001,234.57"), en_US, F(1.234567e3));
1717 test<"{:$<12.6Lg}">(SV("-1,234.57$$$"), en_US, F(-1.234567e3));
1718 test<"{:$>12.6Lg}">(SV("$$$-1,234.57"), en_US, F(-1.234567e3));
1719 test<"{:$^12.6Lg}">(SV("$-1,234.57$$"), en_US, F(-1.234567e3));
1720 test<"{:012.6Lg}">(SV("-0001,234.57"), en_US, F(-1.234567e3));
1721
1722 std::locale::global(en_US);
1723 test<"{:$<12.6Lg}">(SV("1_23_4#57$$$"), loc, F(1.234567e3));
1724 test<"{:$>12.6Lg}">(SV("$$$1_23_4#57"), loc, F(1.234567e3));
1725 test<"{:$^12.6Lg}">(SV("$1_23_4#57$$"), loc, F(1.234567e3));
1726 test<"{:012.6Lg}">(SV("0001_23_4#57"), loc, F(1.234567e3));
1727 test<"{:$<13.6Lg}">(SV("-1_23_4#57$$$"), loc, F(-1.234567e3));
1728 test<"{:$>13.6Lg}">(SV("$$$-1_23_4#57"), loc, F(-1.234567e3));
1729 test<"{:$^13.6Lg}">(SV("$-1_23_4#57$$"), loc, F(-1.234567e3));
1730 test<"{:013.6Lg}">(SV("-0001_23_4#57"), loc, F(-1.234567e3));
1731 }
1732
1733 template <class F, class CharT>
test_floating_point_general_upper_case()1734 void test_floating_point_general_upper_case() {
1735 std::locale loc = std::locale(std::locale(), new numpunct<CharT>());
1736 std::locale en_US = std::locale(LOCALE_en_US_UTF_8);
1737
1738 // *** Basic ***
1739 std::locale::global(en_US);
1740 test<"{:.6LG}">(SV("1.23457E-06"), F(1.234567e-6));
1741 test<"{:.6LG}">(SV("1.23457E-05"), F(1.234567e-5));
1742 test<"{:.6LG}">(SV("0.000123457"), F(1.234567e-4));
1743 test<"{:.6LG}">(SV("0.00123457"), F(1.234567e-3));
1744 test<"{:.6LG}">(SV("0.0123457"), F(1.234567e-2));
1745 test<"{:.6LG}">(SV("0.123457"), F(1.234567e-1));
1746 test<"{:.6LG}">(SV("1.23457"), F(1.234567e0));
1747 test<"{:.6LG}">(SV("12.3457"), F(1.234567e1));
1748 test<"{:.6LG}">(SV("123.457"), F(1.234567e2));
1749 test<"{:.6LG}">(SV("1,234.57"), F(1.234567e3));
1750 test<"{:.6LG}">(SV("12,345.7"), F(1.234567e4));
1751 test<"{:.6LG}">(SV("123,457"), F(1.234567e5));
1752 test<"{:.6LG}">(SV("1.23457E+06"), F(1.234567e6));
1753 test<"{:.6LG}">(SV("1.23457E+07"), F(1.234567e7));
1754 test<"{:.6LG}">(SV("-1.23457E-06"), F(-1.234567e-6));
1755 test<"{:.6LG}">(SV("-1.23457E-05"), F(-1.234567e-5));
1756 test<"{:.6LG}">(SV("-0.000123457"), F(-1.234567e-4));
1757 test<"{:.6LG}">(SV("-0.00123457"), F(-1.234567e-3));
1758 test<"{:.6LG}">(SV("-0.0123457"), F(-1.234567e-2));
1759 test<"{:.6LG}">(SV("-0.123457"), F(-1.234567e-1));
1760 test<"{:.6LG}">(SV("-1.23457"), F(-1.234567e0));
1761 test<"{:.6LG}">(SV("-12.3457"), F(-1.234567e1));
1762 test<"{:.6LG}">(SV("-123.457"), F(-1.234567e2));
1763 test<"{:.6LG}">(SV("-1,234.57"), F(-1.234567e3));
1764 test<"{:.6LG}">(SV("-12,345.7"), F(-1.234567e4));
1765 test<"{:.6LG}">(SV("-123,457"), F(-1.234567e5));
1766 test<"{:.6LG}">(SV("-1.23457E+06"), F(-1.234567e6));
1767 test<"{:.6LG}">(SV("-1.23457E+07"), F(-1.234567e7));
1768
1769 std::locale::global(loc);
1770 test<"{:.6LG}">(SV("1#23457E-06"), F(1.234567e-6));
1771 test<"{:.6LG}">(SV("1#23457E-05"), F(1.234567e-5));
1772 test<"{:.6LG}">(SV("0#000123457"), F(1.234567e-4));
1773 test<"{:.6LG}">(SV("0#00123457"), F(1.234567e-3));
1774 test<"{:.6LG}">(SV("0#0123457"), F(1.234567e-2));
1775 test<"{:.6LG}">(SV("0#123457"), F(1.234567e-1));
1776 test<"{:.6LG}">(SV("1#23457"), F(1.234567e0));
1777 test<"{:.6LG}">(SV("1_2#3457"), F(1.234567e1));
1778 test<"{:.6LG}">(SV("12_3#457"), F(1.234567e2));
1779 test<"{:.6LG}">(SV("1_23_4#57"), F(1.234567e3));
1780 test<"{:.6LG}">(SV("12_34_5#7"), F(1.234567e4));
1781 test<"{:.6LG}">(SV("123_45_7"), F(1.234567e5));
1782 test<"{:.6LG}">(SV("1#23457E+06"), F(1.234567e6));
1783 test<"{:.6LG}">(SV("1#23457E+07"), F(1.234567e7));
1784 test<"{:.6LG}">(SV("-1#23457E-06"), F(-1.234567e-6));
1785 test<"{:.6LG}">(SV("-1#23457E-05"), F(-1.234567e-5));
1786 test<"{:.6LG}">(SV("-0#000123457"), F(-1.234567e-4));
1787 test<"{:.6LG}">(SV("-0#00123457"), F(-1.234567e-3));
1788 test<"{:.6LG}">(SV("-0#0123457"), F(-1.234567e-2));
1789 test<"{:.6LG}">(SV("-0#123457"), F(-1.234567e-1));
1790 test<"{:.6LG}">(SV("-1#23457"), F(-1.234567e0));
1791 test<"{:.6LG}">(SV("-1_2#3457"), F(-1.234567e1));
1792 test<"{:.6LG}">(SV("-12_3#457"), F(-1.234567e2));
1793 test<"{:.6LG}">(SV("-1_23_4#57"), F(-1.234567e3));
1794 test<"{:.6LG}">(SV("-12_34_5#7"), F(-1.234567e4));
1795 test<"{:.6LG}">(SV("-123_45_7"), F(-1.234567e5));
1796 test<"{:.6LG}">(SV("-1#23457E+06"), F(-1.234567e6));
1797 test<"{:.6LG}">(SV("-1#23457E+07"), F(-1.234567e7));
1798
1799 test<"{:.6LG}">(SV("1.23457E-06"), en_US, F(1.234567e-6));
1800 test<"{:.6LG}">(SV("1.23457E-05"), en_US, F(1.234567e-5));
1801 test<"{:.6LG}">(SV("0.000123457"), en_US, F(1.234567e-4));
1802 test<"{:.6LG}">(SV("0.00123457"), en_US, F(1.234567e-3));
1803 test<"{:.6LG}">(SV("0.0123457"), en_US, F(1.234567e-2));
1804 test<"{:.6LG}">(SV("0.123457"), en_US, F(1.234567e-1));
1805 test<"{:.6LG}">(SV("1.23457"), en_US, F(1.234567e0));
1806 test<"{:.6LG}">(SV("12.3457"), en_US, F(1.234567e1));
1807 test<"{:.6LG}">(SV("123.457"), en_US, F(1.234567e2));
1808 test<"{:.6LG}">(SV("1,234.57"), en_US, F(1.234567e3));
1809 test<"{:.6LG}">(SV("12,345.7"), en_US, F(1.234567e4));
1810 test<"{:.6LG}">(SV("123,457"), en_US, F(1.234567e5));
1811 test<"{:.6LG}">(SV("1.23457E+06"), en_US, F(1.234567e6));
1812 test<"{:.6LG}">(SV("1.23457E+07"), en_US, F(1.234567e7));
1813 test<"{:.6LG}">(SV("-1.23457E-06"), en_US, F(-1.234567e-6));
1814 test<"{:.6LG}">(SV("-1.23457E-05"), en_US, F(-1.234567e-5));
1815 test<"{:.6LG}">(SV("-0.000123457"), en_US, F(-1.234567e-4));
1816 test<"{:.6LG}">(SV("-0.00123457"), en_US, F(-1.234567e-3));
1817 test<"{:.6LG}">(SV("-0.0123457"), en_US, F(-1.234567e-2));
1818 test<"{:.6LG}">(SV("-0.123457"), en_US, F(-1.234567e-1));
1819 test<"{:.6LG}">(SV("-1.23457"), en_US, F(-1.234567e0));
1820 test<"{:.6LG}">(SV("-12.3457"), en_US, F(-1.234567e1));
1821 test<"{:.6LG}">(SV("-123.457"), en_US, F(-1.234567e2));
1822 test<"{:.6LG}">(SV("-1,234.57"), en_US, F(-1.234567e3));
1823 test<"{:.6LG}">(SV("-12,345.7"), en_US, F(-1.234567e4));
1824 test<"{:.6LG}">(SV("-123,457"), en_US, F(-1.234567e5));
1825 test<"{:.6LG}">(SV("-1.23457E+06"), en_US, F(-1.234567e6));
1826 test<"{:.6LG}">(SV("-1.23457E+07"), en_US, F(-1.234567e7));
1827
1828 std::locale::global(en_US);
1829 test<"{:.6LG}">(SV("1#23457E-06"), loc, F(1.234567e-6));
1830 test<"{:.6LG}">(SV("1#23457E-05"), loc, F(1.234567e-5));
1831 test<"{:.6LG}">(SV("0#000123457"), loc, F(1.234567e-4));
1832 test<"{:.6LG}">(SV("0#00123457"), loc, F(1.234567e-3));
1833 test<"{:.6LG}">(SV("0#0123457"), loc, F(1.234567e-2));
1834 test<"{:.6LG}">(SV("0#123457"), loc, F(1.234567e-1));
1835 test<"{:.6LG}">(SV("1#23457"), loc, F(1.234567e0));
1836 test<"{:.6LG}">(SV("1_2#3457"), loc, F(1.234567e1));
1837 test<"{:.6LG}">(SV("12_3#457"), loc, F(1.234567e2));
1838 test<"{:.6LG}">(SV("1_23_4#57"), loc, F(1.234567e3));
1839 test<"{:.6LG}">(SV("12_34_5#7"), loc, F(1.234567e4));
1840 test<"{:.6LG}">(SV("123_45_7"), loc, F(1.234567e5));
1841 test<"{:.6LG}">(SV("1#23457E+06"), loc, F(1.234567e6));
1842 test<"{:.6LG}">(SV("1#23457E+07"), loc, F(1.234567e7));
1843 test<"{:.6LG}">(SV("-1#23457E-06"), loc, F(-1.234567e-6));
1844 test<"{:.6LG}">(SV("-1#23457E-05"), loc, F(-1.234567e-5));
1845 test<"{:.6LG}">(SV("-0#000123457"), loc, F(-1.234567e-4));
1846 test<"{:.6LG}">(SV("-0#00123457"), loc, F(-1.234567e-3));
1847 test<"{:.6LG}">(SV("-0#0123457"), loc, F(-1.234567e-2));
1848 test<"{:.6LG}">(SV("-0#123457"), loc, F(-1.234567e-1));
1849 test<"{:.6LG}">(SV("-1#23457"), loc, F(-1.234567e0));
1850 test<"{:.6LG}">(SV("-1_2#3457"), loc, F(-1.234567e1));
1851 test<"{:.6LG}">(SV("-12_3#457"), loc, F(-1.234567e2));
1852 test<"{:.6LG}">(SV("-1_23_4#57"), loc, F(-1.234567e3));
1853 test<"{:.6LG}">(SV("-12_34_5#7"), loc, F(-1.234567e4));
1854 test<"{:.6LG}">(SV("-123_45_7"), loc, F(-1.234567e5));
1855 test<"{:.6LG}">(SV("-1#23457E+06"), loc, F(-1.234567e6));
1856 test<"{:.6LG}">(SV("-1#23457E+07"), loc, F(-1.234567e7));
1857
1858 // *** Fill, align, zero padding ***
1859 std::locale::global(en_US);
1860 test<"{:$<11.6LG}">(SV("1,234.57$$$"), F(1.234567e3));
1861 test<"{:$>11.6LG}">(SV("$$$1,234.57"), F(1.234567e3));
1862 test<"{:$^11.6LG}">(SV("$1,234.57$$"), F(1.234567e3));
1863 test<"{:011.6LG}">(SV("0001,234.57"), F(1.234567e3));
1864 test<"{:$<12.6LG}">(SV("-1,234.57$$$"), F(-1.234567e3));
1865 test<"{:$>12.6LG}">(SV("$$$-1,234.57"), F(-1.234567e3));
1866 test<"{:$^12.6LG}">(SV("$-1,234.57$$"), F(-1.234567e3));
1867 test<"{:012.6LG}">(SV("-0001,234.57"), F(-1.234567e3));
1868
1869 std::locale::global(loc);
1870 test<"{:$<12.6LG}">(SV("1_23_4#57$$$"), F(1.234567e3));
1871 test<"{:$>12.6LG}">(SV("$$$1_23_4#57"), F(1.234567e3));
1872 test<"{:$^12.6LG}">(SV("$1_23_4#57$$"), F(1.234567e3));
1873 test<"{:012.6LG}">(SV("0001_23_4#57"), F(1.234567e3));
1874 test<"{:$<13.6LG}">(SV("-1_23_4#57$$$"), F(-1.234567e3));
1875 test<"{:$>13.6LG}">(SV("$$$-1_23_4#57"), F(-1.234567e3));
1876 test<"{:$^13.6LG}">(SV("$-1_23_4#57$$"), F(-1.234567e3));
1877 test<"{:013.6LG}">(SV("-0001_23_4#57"), F(-1.234567e3));
1878
1879 test<"{:$<11.6LG}">(SV("1,234.57$$$"), en_US, F(1.234567e3));
1880 test<"{:$>11.6LG}">(SV("$$$1,234.57"), en_US, F(1.234567e3));
1881 test<"{:$^11.6LG}">(SV("$1,234.57$$"), en_US, F(1.234567e3));
1882 test<"{:011.6LG}">(SV("0001,234.57"), en_US, F(1.234567e3));
1883 test<"{:$<12.6LG}">(SV("-1,234.57$$$"), en_US, F(-1.234567e3));
1884 test<"{:$>12.6LG}">(SV("$$$-1,234.57"), en_US, F(-1.234567e3));
1885 test<"{:$^12.6LG}">(SV("$-1,234.57$$"), en_US, F(-1.234567e3));
1886 test<"{:012.6LG}">(SV("-0001,234.57"), en_US, F(-1.234567e3));
1887
1888 std::locale::global(en_US);
1889 test<"{:$<12.6LG}">(SV("1_23_4#57$$$"), loc, F(1.234567e3));
1890 test<"{:$>12.6LG}">(SV("$$$1_23_4#57"), loc, F(1.234567e3));
1891 test<"{:$^12.6LG}">(SV("$1_23_4#57$$"), loc, F(1.234567e3));
1892 test<"{:012.6LG}">(SV("0001_23_4#57"), loc, F(1.234567e3));
1893 test<"{:$<13.6LG}">(SV("-1_23_4#57$$$"), loc, F(-1.234567e3));
1894 test<"{:$>13.6LG}">(SV("$$$-1_23_4#57"), loc, F(-1.234567e3));
1895 test<"{:$^13.6LG}">(SV("$-1_23_4#57$$"), loc, F(-1.234567e3));
1896 test<"{:013.6LG}">(SV("-0001_23_4#57"), loc, F(-1.234567e3));
1897 }
1898
1899 template <class F, class CharT>
test_floating_point_default()1900 void test_floating_point_default() {
1901 std::locale loc = std::locale(std::locale(), new numpunct<CharT>());
1902 std::locale en_US = std::locale(LOCALE_en_US_UTF_8);
1903
1904 // *** Basic ***
1905 std::locale::global(en_US);
1906 test<"{:L}">(SV("1.234567e-06"), F(1.234567e-6));
1907 test<"{:L}">(SV("1.234567e-05"), F(1.234567e-5));
1908 test<"{:L}">(SV("0.0001234567"), F(1.234567e-4));
1909 test<"{:L}">(SV("0.001234567"), F(1.234567e-3));
1910 test<"{:L}">(SV("0.01234567"), F(1.234567e-2));
1911 test<"{:L}">(SV("0.1234567"), F(1.234567e-1));
1912 test<"{:L}">(SV("1.234567"), F(1.234567e0));
1913 test<"{:L}">(SV("12.34567"), F(1.234567e1));
1914 test<"{:L}">(SV("123.4567"), F(1.234567e2));
1915 test<"{:L}">(SV("1,234.567"), F(1.234567e3));
1916 test<"{:L}">(SV("12,345.67"), F(1.234567e4));
1917 test<"{:L}">(SV("123,456.7"), F(1.234567e5));
1918 test<"{:L}">(SV("1,234,567"), F(1.234567e6));
1919 test<"{:L}">(SV("12,345,670"), F(1.234567e7));
1920 if constexpr (sizeof(F) > sizeof(float)) {
1921 test<"{:L}">(SV("123,456,700"), F(1.234567e8));
1922 test<"{:L}">(SV("1,234,567,000"), F(1.234567e9));
1923 test<"{:L}">(SV("12,345,670,000"), F(1.234567e10));
1924 test<"{:L}">(SV("123,456,700,000"), F(1.234567e11));
1925 test<"{:L}">(SV("1.234567e+12"), F(1.234567e12));
1926 test<"{:L}">(SV("1.234567e+13"), F(1.234567e13));
1927 }
1928 test<"{:L}">(SV("-1.234567e-06"), F(-1.234567e-6));
1929 test<"{:L}">(SV("-1.234567e-05"), F(-1.234567e-5));
1930 test<"{:L}">(SV("-0.0001234567"), F(-1.234567e-4));
1931 test<"{:L}">(SV("-0.001234567"), F(-1.234567e-3));
1932 test<"{:L}">(SV("-0.01234567"), F(-1.234567e-2));
1933 test<"{:L}">(SV("-0.1234567"), F(-1.234567e-1));
1934 test<"{:L}">(SV("-1.234567"), F(-1.234567e0));
1935 test<"{:L}">(SV("-12.34567"), F(-1.234567e1));
1936 test<"{:L}">(SV("-123.4567"), F(-1.234567e2));
1937 test<"{:L}">(SV("-1,234.567"), F(-1.234567e3));
1938 test<"{:L}">(SV("-12,345.67"), F(-1.234567e4));
1939 test<"{:L}">(SV("-123,456.7"), F(-1.234567e5));
1940 test<"{:L}">(SV("-1,234,567"), F(-1.234567e6));
1941 test<"{:L}">(SV("-12,345,670"), F(-1.234567e7));
1942 if constexpr (sizeof(F) > sizeof(float)) {
1943 test<"{:L}">(SV("-123,456,700"), F(-1.234567e8));
1944 test<"{:L}">(SV("-1,234,567,000"), F(-1.234567e9));
1945 test<"{:L}">(SV("-12,345,670,000"), F(-1.234567e10));
1946 test<"{:L}">(SV("-123,456,700,000"), F(-1.234567e11));
1947 test<"{:L}">(SV("-1.234567e+12"), F(-1.234567e12));
1948 test<"{:L}">(SV("-1.234567e+13"), F(-1.234567e13));
1949 }
1950
1951 std::locale::global(loc);
1952 test<"{:L}">(SV("1#234567e-06"), F(1.234567e-6));
1953 test<"{:L}">(SV("1#234567e-05"), F(1.234567e-5));
1954 test<"{:L}">(SV("0#0001234567"), F(1.234567e-4));
1955 test<"{:L}">(SV("0#001234567"), F(1.234567e-3));
1956 test<"{:L}">(SV("0#01234567"), F(1.234567e-2));
1957 test<"{:L}">(SV("0#1234567"), F(1.234567e-1));
1958 test<"{:L}">(SV("1#234567"), F(1.234567e0));
1959 test<"{:L}">(SV("1_2#34567"), F(1.234567e1));
1960 test<"{:L}">(SV("12_3#4567"), F(1.234567e2));
1961 test<"{:L}">(SV("1_23_4#567"), F(1.234567e3));
1962 test<"{:L}">(SV("12_34_5#67"), F(1.234567e4));
1963 test<"{:L}">(SV("123_45_6#7"), F(1.234567e5));
1964 test<"{:L}">(SV("1_234_56_7"), F(1.234567e6));
1965 test<"{:L}">(SV("12_345_67_0"), F(1.234567e7));
1966 if constexpr (sizeof(F) > sizeof(float)) {
1967 test<"{:L}">(SV("1_23_456_70_0"), F(1.234567e8));
1968 test<"{:L}">(SV("1_2_34_567_00_0"), F(1.234567e9));
1969 test<"{:L}">(SV("1_2_3_45_670_00_0"), F(1.234567e10));
1970 test<"{:L}">(SV("1_2_3_4_56_700_00_0"), F(1.234567e11));
1971 test<"{:L}">(SV("1#234567e+12"), F(1.234567e12));
1972 test<"{:L}">(SV("1#234567e+13"), F(1.234567e13));
1973 }
1974 test<"{:L}">(SV("-1#234567e-06"), F(-1.234567e-6));
1975 test<"{:L}">(SV("-1#234567e-05"), F(-1.234567e-5));
1976 test<"{:L}">(SV("-0#0001234567"), F(-1.234567e-4));
1977 test<"{:L}">(SV("-0#001234567"), F(-1.234567e-3));
1978 test<"{:L}">(SV("-0#01234567"), F(-1.234567e-2));
1979 test<"{:L}">(SV("-0#1234567"), F(-1.234567e-1));
1980 test<"{:L}">(SV("-1#234567"), F(-1.234567e0));
1981 test<"{:L}">(SV("-1_2#34567"), F(-1.234567e1));
1982 test<"{:L}">(SV("-12_3#4567"), F(-1.234567e2));
1983 test<"{:L}">(SV("-1_23_4#567"), F(-1.234567e3));
1984 test<"{:L}">(SV("-12_34_5#67"), F(-1.234567e4));
1985 test<"{:L}">(SV("-123_45_6#7"), F(-1.234567e5));
1986 test<"{:L}">(SV("-1_234_56_7"), F(-1.234567e6));
1987 test<"{:L}">(SV("-12_345_67_0"), F(-1.234567e7));
1988 if constexpr (sizeof(F) > sizeof(float)) {
1989 test<"{:L}">(SV("-1_23_456_70_0"), F(-1.234567e8));
1990 test<"{:L}">(SV("-1_2_34_567_00_0"), F(-1.234567e9));
1991 test<"{:L}">(SV("-1_2_3_45_670_00_0"), F(-1.234567e10));
1992 test<"{:L}">(SV("-1_2_3_4_56_700_00_0"), F(-1.234567e11));
1993 test<"{:L}">(SV("-1#234567e+12"), F(-1.234567e12));
1994 test<"{:L}">(SV("-1#234567e+13"), F(-1.234567e13));
1995 }
1996
1997 test<"{:L}">(SV("1.234567e-06"), en_US, F(1.234567e-6));
1998 test<"{:L}">(SV("1.234567e-05"), en_US, F(1.234567e-5));
1999 test<"{:L}">(SV("0.0001234567"), en_US, F(1.234567e-4));
2000 test<"{:L}">(SV("0.001234567"), en_US, F(1.234567e-3));
2001 test<"{:L}">(SV("0.01234567"), en_US, F(1.234567e-2));
2002 test<"{:L}">(SV("0.1234567"), en_US, F(1.234567e-1));
2003 test<"{:L}">(SV("1.234567"), en_US, F(1.234567e0));
2004 test<"{:L}">(SV("12.34567"), en_US, F(1.234567e1));
2005 test<"{:L}">(SV("123.4567"), en_US, F(1.234567e2));
2006 test<"{:L}">(SV("1,234.567"), en_US, F(1.234567e3));
2007 test<"{:L}">(SV("12,345.67"), en_US, F(1.234567e4));
2008 test<"{:L}">(SV("123,456.7"), en_US, F(1.234567e5));
2009 test<"{:L}">(SV("1,234,567"), en_US, F(1.234567e6));
2010 test<"{:L}">(SV("12,345,670"), en_US, F(1.234567e7));
2011 if constexpr (sizeof(F) > sizeof(float)) {
2012 test<"{:L}">(SV("123,456,700"), en_US, F(1.234567e8));
2013 test<"{:L}">(SV("1,234,567,000"), en_US, F(1.234567e9));
2014 test<"{:L}">(SV("12,345,670,000"), en_US, F(1.234567e10));
2015 test<"{:L}">(SV("123,456,700,000"), en_US, F(1.234567e11));
2016 test<"{:L}">(SV("1.234567e+12"), en_US, F(1.234567e12));
2017 test<"{:L}">(SV("1.234567e+13"), en_US, F(1.234567e13));
2018 }
2019 test<"{:L}">(SV("-1.234567e-06"), en_US, F(-1.234567e-6));
2020 test<"{:L}">(SV("-1.234567e-05"), en_US, F(-1.234567e-5));
2021 test<"{:L}">(SV("-0.0001234567"), en_US, F(-1.234567e-4));
2022 test<"{:L}">(SV("-0.001234567"), en_US, F(-1.234567e-3));
2023 test<"{:L}">(SV("-0.01234567"), en_US, F(-1.234567e-2));
2024 test<"{:L}">(SV("-0.1234567"), en_US, F(-1.234567e-1));
2025 test<"{:L}">(SV("-1.234567"), en_US, F(-1.234567e0));
2026 test<"{:L}">(SV("-12.34567"), en_US, F(-1.234567e1));
2027 test<"{:L}">(SV("-123.4567"), en_US, F(-1.234567e2));
2028 test<"{:L}">(SV("-1,234.567"), en_US, F(-1.234567e3));
2029 test<"{:L}">(SV("-12,345.67"), en_US, F(-1.234567e4));
2030 test<"{:L}">(SV("-123,456.7"), en_US, F(-1.234567e5));
2031 test<"{:L}">(SV("-1,234,567"), en_US, F(-1.234567e6));
2032 test<"{:L}">(SV("-12,345,670"), en_US, F(-1.234567e7));
2033 if constexpr (sizeof(F) > sizeof(float)) {
2034 test<"{:L}">(SV("-123,456,700"), en_US, F(-1.234567e8));
2035 test<"{:L}">(SV("-1,234,567,000"), en_US, F(-1.234567e9));
2036 test<"{:L}">(SV("-12,345,670,000"), en_US, F(-1.234567e10));
2037 test<"{:L}">(SV("-123,456,700,000"), en_US, F(-1.234567e11));
2038 test<"{:L}">(SV("-1.234567e+12"), en_US, F(-1.234567e12));
2039 test<"{:L}">(SV("-1.234567e+13"), en_US, F(-1.234567e13));
2040 }
2041
2042 std::locale::global(en_US);
2043 test<"{:L}">(SV("1#234567e-06"), loc, F(1.234567e-6));
2044 test<"{:L}">(SV("1#234567e-05"), loc, F(1.234567e-5));
2045 test<"{:L}">(SV("0#0001234567"), loc, F(1.234567e-4));
2046 test<"{:L}">(SV("0#001234567"), loc, F(1.234567e-3));
2047 test<"{:L}">(SV("0#01234567"), loc, F(1.234567e-2));
2048 test<"{:L}">(SV("0#1234567"), loc, F(1.234567e-1));
2049 test<"{:L}">(SV("1#234567"), loc, F(1.234567e0));
2050 test<"{:L}">(SV("1_2#34567"), loc, F(1.234567e1));
2051 test<"{:L}">(SV("12_3#4567"), loc, F(1.234567e2));
2052 test<"{:L}">(SV("1_23_4#567"), loc, F(1.234567e3));
2053 test<"{:L}">(SV("12_34_5#67"), loc, F(1.234567e4));
2054 test<"{:L}">(SV("123_45_6#7"), loc, F(1.234567e5));
2055 test<"{:L}">(SV("1_234_56_7"), loc, F(1.234567e6));
2056 test<"{:L}">(SV("12_345_67_0"), loc, F(1.234567e7));
2057 if constexpr (sizeof(F) > sizeof(float)) {
2058 test<"{:L}">(SV("1_23_456_70_0"), loc, F(1.234567e8));
2059 test<"{:L}">(SV("1_2_34_567_00_0"), loc, F(1.234567e9));
2060 test<"{:L}">(SV("1_2_3_45_670_00_0"), loc, F(1.234567e10));
2061 test<"{:L}">(SV("1_2_3_4_56_700_00_0"), loc, F(1.234567e11));
2062 test<"{:L}">(SV("1#234567e+12"), loc, F(1.234567e12));
2063 test<"{:L}">(SV("1#234567e+13"), loc, F(1.234567e13));
2064 }
2065 test<"{:L}">(SV("-1#234567e-06"), loc, F(-1.234567e-6));
2066 test<"{:L}">(SV("-1#234567e-05"), loc, F(-1.234567e-5));
2067 test<"{:L}">(SV("-0#0001234567"), loc, F(-1.234567e-4));
2068 test<"{:L}">(SV("-0#001234567"), loc, F(-1.234567e-3));
2069 test<"{:L}">(SV("-0#01234567"), loc, F(-1.234567e-2));
2070 test<"{:L}">(SV("-0#1234567"), loc, F(-1.234567e-1));
2071 test<"{:L}">(SV("-1#234567"), loc, F(-1.234567e0));
2072 test<"{:L}">(SV("-1_2#34567"), loc, F(-1.234567e1));
2073 test<"{:L}">(SV("-12_3#4567"), loc, F(-1.234567e2));
2074 test<"{:L}">(SV("-1_23_4#567"), loc, F(-1.234567e3));
2075 test<"{:L}">(SV("-12_34_5#67"), loc, F(-1.234567e4));
2076 test<"{:L}">(SV("-123_45_6#7"), loc, F(-1.234567e5));
2077 test<"{:L}">(SV("-1_234_56_7"), loc, F(-1.234567e6));
2078 test<"{:L}">(SV("-12_345_67_0"), loc, F(-1.234567e7));
2079 if constexpr (sizeof(F) > sizeof(float)) {
2080 test<"{:L}">(SV("-1_23_456_70_0"), loc, F(-1.234567e8));
2081 test<"{:L}">(SV("-1_2_34_567_00_0"), loc, F(-1.234567e9));
2082 test<"{:L}">(SV("-1_2_3_45_670_00_0"), loc, F(-1.234567e10));
2083 test<"{:L}">(SV("-1_2_3_4_56_700_00_0"), loc, F(-1.234567e11));
2084 test<"{:L}">(SV("-1#234567e+12"), loc, F(-1.234567e12));
2085 test<"{:L}">(SV("-1#234567e+13"), loc, F(-1.234567e13));
2086 }
2087
2088 // *** Fill, align, zero padding ***
2089 std::locale::global(en_US);
2090 test<"{:$<12L}">(SV("1,234.567$$$"), F(1.234567e3));
2091 test<"{:$>12L}">(SV("$$$1,234.567"), F(1.234567e3));
2092 test<"{:$^12L}">(SV("$1,234.567$$"), F(1.234567e3));
2093 test<"{:012L}">(SV("0001,234.567"), F(1.234567e3));
2094 test<"{:$<13L}">(SV("-1,234.567$$$"), F(-1.234567e3));
2095 test<"{:$>13L}">(SV("$$$-1,234.567"), F(-1.234567e3));
2096 test<"{:$^13L}">(SV("$-1,234.567$$"), F(-1.234567e3));
2097 test<"{:013L}">(SV("-0001,234.567"), F(-1.234567e3));
2098
2099 std::locale::global(loc);
2100 test<"{:$<13L}">(SV("1_23_4#567$$$"), F(1.234567e3));
2101 test<"{:$>13L}">(SV("$$$1_23_4#567"), F(1.234567e3));
2102 test<"{:$^13L}">(SV("$1_23_4#567$$"), F(1.234567e3));
2103 test<"{:013L}">(SV("0001_23_4#567"), F(1.234567e3));
2104 test<"{:$<14L}">(SV("-1_23_4#567$$$"), F(-1.234567e3));
2105 test<"{:$>14L}">(SV("$$$-1_23_4#567"), F(-1.234567e3));
2106 test<"{:$^14L}">(SV("$-1_23_4#567$$"), F(-1.234567e3));
2107 test<"{:014L}">(SV("-0001_23_4#567"), F(-1.234567e3));
2108
2109 test<"{:$<12L}">(SV("1,234.567$$$"), en_US, F(1.234567e3));
2110 test<"{:$>12L}">(SV("$$$1,234.567"), en_US, F(1.234567e3));
2111 test<"{:$^12L}">(SV("$1,234.567$$"), en_US, F(1.234567e3));
2112 test<"{:012L}">(SV("0001,234.567"), en_US, F(1.234567e3));
2113 test<"{:$<13L}">(SV("-1,234.567$$$"), en_US, F(-1.234567e3));
2114 test<"{:$>13L}">(SV("$$$-1,234.567"), en_US, F(-1.234567e3));
2115 test<"{:$^13L}">(SV("$-1,234.567$$"), en_US, F(-1.234567e3));
2116 test<"{:013L}">(SV("-0001,234.567"), en_US, F(-1.234567e3));
2117
2118 std::locale::global(en_US);
2119 test<"{:$<13L}">(SV("1_23_4#567$$$"), loc, F(1.234567e3));
2120 test<"{:$>13L}">(SV("$$$1_23_4#567"), loc, F(1.234567e3));
2121 test<"{:$^13L}">(SV("$1_23_4#567$$"), loc, F(1.234567e3));
2122 test<"{:013L}">(SV("0001_23_4#567"), loc, F(1.234567e3));
2123 test<"{:$<14L}">(SV("-1_23_4#567$$$"), loc, F(-1.234567e3));
2124 test<"{:$>14L}">(SV("$$$-1_23_4#567"), loc, F(-1.234567e3));
2125 test<"{:$^14L}">(SV("$-1_23_4#567$$"), loc, F(-1.234567e3));
2126 test<"{:014L}">(SV("-0001_23_4#567"), loc, F(-1.234567e3));
2127 }
2128
2129 template <class F, class CharT>
test_floating_point_default_precision()2130 void test_floating_point_default_precision() {
2131 std::locale loc = std::locale(std::locale(), new numpunct<CharT>());
2132 std::locale en_US = std::locale(LOCALE_en_US_UTF_8);
2133
2134 // *** Basic ***
2135 std::locale::global(en_US);
2136 test<"{:.6L}">(SV("1.23457e-06"), F(1.234567e-6));
2137 test<"{:.6L}">(SV("1.23457e-05"), F(1.234567e-5));
2138 test<"{:.6L}">(SV("0.000123457"), F(1.234567e-4));
2139 test<"{:.6L}">(SV("0.00123457"), F(1.234567e-3));
2140 test<"{:.6L}">(SV("0.0123457"), F(1.234567e-2));
2141 test<"{:.6L}">(SV("0.123457"), F(1.234567e-1));
2142 test<"{:.6L}">(SV("1.23457"), F(1.234567e0));
2143 test<"{:.6L}">(SV("12.3457"), F(1.234567e1));
2144 test<"{:.6L}">(SV("123.457"), F(1.234567e2));
2145 test<"{:.6L}">(SV("1,234.57"), F(1.234567e3));
2146 test<"{:.6L}">(SV("12,345.7"), F(1.234567e4));
2147 test<"{:.6L}">(SV("123,457"), F(1.234567e5));
2148 test<"{:.6L}">(SV("1.23457e+06"), F(1.234567e6));
2149 test<"{:.6L}">(SV("1.23457e+07"), F(1.234567e7));
2150 test<"{:.6L}">(SV("-1.23457e-06"), F(-1.234567e-6));
2151 test<"{:.6L}">(SV("-1.23457e-05"), F(-1.234567e-5));
2152 test<"{:.6L}">(SV("-0.000123457"), F(-1.234567e-4));
2153 test<"{:.6L}">(SV("-0.00123457"), F(-1.234567e-3));
2154 test<"{:.6L}">(SV("-0.0123457"), F(-1.234567e-2));
2155 test<"{:.6L}">(SV("-0.123457"), F(-1.234567e-1));
2156 test<"{:.6L}">(SV("-1.23457"), F(-1.234567e0));
2157 test<"{:.6L}">(SV("-12.3457"), F(-1.234567e1));
2158 test<"{:.6L}">(SV("-123.457"), F(-1.234567e2));
2159 test<"{:.6L}">(SV("-1,234.57"), F(-1.234567e3));
2160 test<"{:.6L}">(SV("-12,345.7"), F(-1.234567e4));
2161 test<"{:.6L}">(SV("-123,457"), F(-1.234567e5));
2162 test<"{:.6L}">(SV("-1.23457e+06"), F(-1.234567e6));
2163 test<"{:.6L}">(SV("-1.23457e+07"), F(-1.234567e7));
2164
2165 std::locale::global(loc);
2166 test<"{:.6L}">(SV("1#23457e-06"), F(1.234567e-6));
2167 test<"{:.6L}">(SV("1#23457e-05"), F(1.234567e-5));
2168 test<"{:.6L}">(SV("0#000123457"), F(1.234567e-4));
2169 test<"{:.6L}">(SV("0#00123457"), F(1.234567e-3));
2170 test<"{:.6L}">(SV("0#0123457"), F(1.234567e-2));
2171 test<"{:.6L}">(SV("0#123457"), F(1.234567e-1));
2172 test<"{:.6L}">(SV("1#23457"), F(1.234567e0));
2173 test<"{:.6L}">(SV("1_2#3457"), F(1.234567e1));
2174 test<"{:.6L}">(SV("12_3#457"), F(1.234567e2));
2175 test<"{:.6L}">(SV("1_23_4#57"), F(1.234567e3));
2176 test<"{:.6L}">(SV("12_34_5#7"), F(1.234567e4));
2177 test<"{:.6L}">(SV("123_45_7"), F(1.234567e5));
2178 test<"{:.6L}">(SV("1#23457e+06"), F(1.234567e6));
2179 test<"{:.6L}">(SV("1#23457e+07"), F(1.234567e7));
2180 test<"{:.6L}">(SV("-1#23457e-06"), F(-1.234567e-6));
2181 test<"{:.6L}">(SV("-1#23457e-05"), F(-1.234567e-5));
2182 test<"{:.6L}">(SV("-0#000123457"), F(-1.234567e-4));
2183 test<"{:.6L}">(SV("-0#00123457"), F(-1.234567e-3));
2184 test<"{:.6L}">(SV("-0#0123457"), F(-1.234567e-2));
2185 test<"{:.6L}">(SV("-0#123457"), F(-1.234567e-1));
2186 test<"{:.6L}">(SV("-1#23457"), F(-1.234567e0));
2187 test<"{:.6L}">(SV("-1_2#3457"), F(-1.234567e1));
2188 test<"{:.6L}">(SV("-12_3#457"), F(-1.234567e2));
2189 test<"{:.6L}">(SV("-1_23_4#57"), F(-1.234567e3));
2190 test<"{:.6L}">(SV("-12_34_5#7"), F(-1.234567e4));
2191 test<"{:.6L}">(SV("-123_45_7"), F(-1.234567e5));
2192 test<"{:.6L}">(SV("-1#23457e+06"), F(-1.234567e6));
2193 test<"{:.6L}">(SV("-1#23457e+07"), F(-1.234567e7));
2194
2195 test<"{:.6L}">(SV("1.23457e-06"), en_US, F(1.234567e-6));
2196 test<"{:.6L}">(SV("1.23457e-05"), en_US, F(1.234567e-5));
2197 test<"{:.6L}">(SV("0.000123457"), en_US, F(1.234567e-4));
2198 test<"{:.6L}">(SV("0.00123457"), en_US, F(1.234567e-3));
2199 test<"{:.6L}">(SV("0.0123457"), en_US, F(1.234567e-2));
2200 test<"{:.6L}">(SV("0.123457"), en_US, F(1.234567e-1));
2201 test<"{:.6L}">(SV("1.23457"), en_US, F(1.234567e0));
2202 test<"{:.6L}">(SV("12.3457"), en_US, F(1.234567e1));
2203 test<"{:.6L}">(SV("123.457"), en_US, F(1.234567e2));
2204 test<"{:.6L}">(SV("1,234.57"), en_US, F(1.234567e3));
2205 test<"{:.6L}">(SV("12,345.7"), en_US, F(1.234567e4));
2206 test<"{:.6L}">(SV("123,457"), en_US, F(1.234567e5));
2207 test<"{:.6L}">(SV("1.23457e+06"), en_US, F(1.234567e6));
2208 test<"{:.6L}">(SV("1.23457e+07"), en_US, F(1.234567e7));
2209 test<"{:.6L}">(SV("-1.23457e-06"), en_US, F(-1.234567e-6));
2210 test<"{:.6L}">(SV("-1.23457e-05"), en_US, F(-1.234567e-5));
2211 test<"{:.6L}">(SV("-0.000123457"), en_US, F(-1.234567e-4));
2212 test<"{:.6L}">(SV("-0.00123457"), en_US, F(-1.234567e-3));
2213 test<"{:.6L}">(SV("-0.0123457"), en_US, F(-1.234567e-2));
2214 test<"{:.6L}">(SV("-0.123457"), en_US, F(-1.234567e-1));
2215 test<"{:.6L}">(SV("-1.23457"), en_US, F(-1.234567e0));
2216 test<"{:.6L}">(SV("-12.3457"), en_US, F(-1.234567e1));
2217 test<"{:.6L}">(SV("-123.457"), en_US, F(-1.234567e2));
2218 test<"{:.6L}">(SV("-1,234.57"), en_US, F(-1.234567e3));
2219 test<"{:.6L}">(SV("-12,345.7"), en_US, F(-1.234567e4));
2220 test<"{:.6L}">(SV("-123,457"), en_US, F(-1.234567e5));
2221 test<"{:.6L}">(SV("-1.23457e+06"), en_US, F(-1.234567e6));
2222 test<"{:.6L}">(SV("-1.23457e+07"), en_US, F(-1.234567e7));
2223
2224 std::locale::global(en_US);
2225 test<"{:.6L}">(SV("1#23457e-06"), loc, F(1.234567e-6));
2226 test<"{:.6L}">(SV("1#23457e-05"), loc, F(1.234567e-5));
2227 test<"{:.6L}">(SV("0#000123457"), loc, F(1.234567e-4));
2228 test<"{:.6L}">(SV("0#00123457"), loc, F(1.234567e-3));
2229 test<"{:.6L}">(SV("0#0123457"), loc, F(1.234567e-2));
2230 test<"{:.6L}">(SV("0#123457"), loc, F(1.234567e-1));
2231 test<"{:.6L}">(SV("1#23457"), loc, F(1.234567e0));
2232 test<"{:.6L}">(SV("1_2#3457"), loc, F(1.234567e1));
2233 test<"{:.6L}">(SV("12_3#457"), loc, F(1.234567e2));
2234 test<"{:.6L}">(SV("1_23_4#57"), loc, F(1.234567e3));
2235 test<"{:.6L}">(SV("12_34_5#7"), loc, F(1.234567e4));
2236 test<"{:.6L}">(SV("123_45_7"), loc, F(1.234567e5));
2237 test<"{:.6L}">(SV("1#23457e+06"), loc, F(1.234567e6));
2238 test<"{:.6L}">(SV("1#23457e+07"), loc, F(1.234567e7));
2239 test<"{:.6L}">(SV("-1#23457e-06"), loc, F(-1.234567e-6));
2240 test<"{:.6L}">(SV("-1#23457e-05"), loc, F(-1.234567e-5));
2241 test<"{:.6L}">(SV("-0#000123457"), loc, F(-1.234567e-4));
2242 test<"{:.6L}">(SV("-0#00123457"), loc, F(-1.234567e-3));
2243 test<"{:.6L}">(SV("-0#0123457"), loc, F(-1.234567e-2));
2244 test<"{:.6L}">(SV("-0#123457"), loc, F(-1.234567e-1));
2245 test<"{:.6L}">(SV("-1#23457"), loc, F(-1.234567e0));
2246 test<"{:.6L}">(SV("-1_2#3457"), loc, F(-1.234567e1));
2247 test<"{:.6L}">(SV("-12_3#457"), loc, F(-1.234567e2));
2248 test<"{:.6L}">(SV("-1_23_4#57"), loc, F(-1.234567e3));
2249 test<"{:.6L}">(SV("-12_34_5#7"), loc, F(-1.234567e4));
2250 test<"{:.6L}">(SV("-123_45_7"), loc, F(-1.234567e5));
2251 test<"{:.6L}">(SV("-1#23457e+06"), loc, F(-1.234567e6));
2252 test<"{:.6L}">(SV("-1#23457e+07"), loc, F(-1.234567e7));
2253
2254 // *** Fill, align, zero padding ***
2255 std::locale::global(en_US);
2256 test<"{:$<11.6L}">(SV("1,234.57$$$"), F(1.234567e3));
2257 test<"{:$>11.6L}">(SV("$$$1,234.57"), F(1.234567e3));
2258 test<"{:$^11.6L}">(SV("$1,234.57$$"), F(1.234567e3));
2259 test<"{:011.6L}">(SV("0001,234.57"), F(1.234567e3));
2260 test<"{:$<12.6L}">(SV("-1,234.57$$$"), F(-1.234567e3));
2261 test<"{:$>12.6L}">(SV("$$$-1,234.57"), F(-1.234567e3));
2262 test<"{:$^12.6L}">(SV("$-1,234.57$$"), F(-1.234567e3));
2263 test<"{:012.6L}">(SV("-0001,234.57"), F(-1.234567e3));
2264
2265 std::locale::global(loc);
2266 test<"{:$<12.6L}">(SV("1_23_4#57$$$"), F(1.234567e3));
2267 test<"{:$>12.6L}">(SV("$$$1_23_4#57"), F(1.234567e3));
2268 test<"{:$^12.6L}">(SV("$1_23_4#57$$"), F(1.234567e3));
2269 test<"{:012.6L}">(SV("0001_23_4#57"), F(1.234567e3));
2270 test<"{:$<13.6L}">(SV("-1_23_4#57$$$"), F(-1.234567e3));
2271 test<"{:$>13.6L}">(SV("$$$-1_23_4#57"), F(-1.234567e3));
2272 test<"{:$^13.6L}">(SV("$-1_23_4#57$$"), F(-1.234567e3));
2273 test<"{:013.6L}">(SV("-0001_23_4#57"), F(-1.234567e3));
2274
2275 test<"{:$<11.6L}">(SV("1,234.57$$$"), en_US, F(1.234567e3));
2276 test<"{:$>11.6L}">(SV("$$$1,234.57"), en_US, F(1.234567e3));
2277 test<"{:$^11.6L}">(SV("$1,234.57$$"), en_US, F(1.234567e3));
2278 test<"{:011.6L}">(SV("0001,234.57"), en_US, F(1.234567e3));
2279 test<"{:$<12.6L}">(SV("-1,234.57$$$"), en_US, F(-1.234567e3));
2280 test<"{:$>12.6L}">(SV("$$$-1,234.57"), en_US, F(-1.234567e3));
2281 test<"{:$^12.6L}">(SV("$-1,234.57$$"), en_US, F(-1.234567e3));
2282 test<"{:012.6L}">(SV("-0001,234.57"), en_US, F(-1.234567e3));
2283
2284 std::locale::global(en_US);
2285 test<"{:$<12.6L}">(SV("1_23_4#57$$$"), loc, F(1.234567e3));
2286 test<"{:$>12.6L}">(SV("$$$1_23_4#57"), loc, F(1.234567e3));
2287 test<"{:$^12.6L}">(SV("$1_23_4#57$$"), loc, F(1.234567e3));
2288 test<"{:012.6L}">(SV("0001_23_4#57"), loc, F(1.234567e3));
2289 test<"{:$<13.6L}">(SV("-1_23_4#57$$$"), loc, F(-1.234567e3));
2290 test<"{:$>13.6L}">(SV("$$$-1_23_4#57"), loc, F(-1.234567e3));
2291 test<"{:$^13.6L}">(SV("$-1_23_4#57$$"), loc, F(-1.234567e3));
2292 test<"{:013.6L}">(SV("-0001_23_4#57"), loc, F(-1.234567e3));
2293 }
2294
2295 template <class F, class CharT >
test_floating_point()2296 void test_floating_point() {
2297 test_floating_point_hex_lower_case<F, CharT>();
2298 test_floating_point_hex_upper_case<F, CharT>();
2299 test_floating_point_hex_lower_case_precision<F, CharT>();
2300 test_floating_point_hex_upper_case_precision<F, CharT>();
2301
2302 test_floating_point_scientific_lower_case<F, CharT>();
2303 test_floating_point_scientific_upper_case<F, CharT>();
2304
2305 test_floating_point_fixed_lower_case<F, CharT>();
2306 test_floating_point_fixed_upper_case<F, CharT>();
2307
2308 test_floating_point_general_lower_case<F, CharT>();
2309 test_floating_point_general_upper_case<F, CharT>();
2310
2311 test_floating_point_default<F, CharT>();
2312 test_floating_point_default_precision<F, CharT>();
2313 }
2314
2315 template <class CharT>
test()2316 void test() {
2317 test_bool<CharT>();
2318 test_integer<CharT>();
2319 test_floating_point<float, CharT>();
2320 test_floating_point<double, CharT>();
2321 test_floating_point<long double, CharT>();
2322 }
2323
main(int,char **)2324 int main(int, char**) {
2325 test<char>();
2326 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
2327 test<wchar_t>();
2328 #endif
2329
2330 return 0;
2331 }
2332