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