12e5b6d6dSopenharmony_ci// Copyright 2012 the V8 project authors. All rights reserved. 22e5b6d6dSopenharmony_ci// Redistribution and use in source and binary forms, with or without 32e5b6d6dSopenharmony_ci// modification, are permitted provided that the following conditions are 42e5b6d6dSopenharmony_ci// met: 52e5b6d6dSopenharmony_ci// 62e5b6d6dSopenharmony_ci// * Redistributions of source code must retain the above copyright 72e5b6d6dSopenharmony_ci// notice, this list of conditions and the following disclaimer. 82e5b6d6dSopenharmony_ci// * Redistributions in binary form must reproduce the above 92e5b6d6dSopenharmony_ci// copyright notice, this list of conditions and the following 102e5b6d6dSopenharmony_ci// disclaimer in the documentation and/or other materials provided 112e5b6d6dSopenharmony_ci// with the distribution. 122e5b6d6dSopenharmony_ci// * Neither the name of Google Inc. nor the names of its 132e5b6d6dSopenharmony_ci// contributors may be used to endorse or promote products derived 142e5b6d6dSopenharmony_ci// from this software without specific prior written permission. 152e5b6d6dSopenharmony_ci// 162e5b6d6dSopenharmony_ci// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172e5b6d6dSopenharmony_ci// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182e5b6d6dSopenharmony_ci// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192e5b6d6dSopenharmony_ci// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202e5b6d6dSopenharmony_ci// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212e5b6d6dSopenharmony_ci// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222e5b6d6dSopenharmony_ci// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232e5b6d6dSopenharmony_ci// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242e5b6d6dSopenharmony_ci// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252e5b6d6dSopenharmony_ci// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262e5b6d6dSopenharmony_ci// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272e5b6d6dSopenharmony_ci 282e5b6d6dSopenharmony_ci#include <string.h> 292e5b6d6dSopenharmony_ci 302e5b6d6dSopenharmony_ci#include "cctest.h" 312e5b6d6dSopenharmony_ci#include "double-conversion/double-conversion.h" 322e5b6d6dSopenharmony_ci#include "double-conversion/ieee.h" 332e5b6d6dSopenharmony_ci#include "double-conversion/utils.h" 342e5b6d6dSopenharmony_ci 352e5b6d6dSopenharmony_ci// DoubleToString is already tested in test-dtoa.cc. 362e5b6d6dSopenharmony_ci 372e5b6d6dSopenharmony_ciusing namespace double_conversion; 382e5b6d6dSopenharmony_ci 392e5b6d6dSopenharmony_ci 402e5b6d6dSopenharmony_ciTEST(DoubleToShortest) { 412e5b6d6dSopenharmony_ci const int kBufferSize = 128; 422e5b6d6dSopenharmony_ci char buffer[kBufferSize]; 432e5b6d6dSopenharmony_ci StringBuilder builder(buffer, kBufferSize); 442e5b6d6dSopenharmony_ci int flags = DoubleToStringConverter::UNIQUE_ZERO | 452e5b6d6dSopenharmony_ci DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN; 462e5b6d6dSopenharmony_ci DoubleToStringConverter dc(flags, NULL, NULL, 'e', -6, 21, 0, 0); 472e5b6d6dSopenharmony_ci 482e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(0.0, &builder)); 492e5b6d6dSopenharmony_ci CHECK_EQ("0", builder.Finalize()); 502e5b6d6dSopenharmony_ci 512e5b6d6dSopenharmony_ci builder.Reset(); 522e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(12345.0, &builder)); 532e5b6d6dSopenharmony_ci CHECK_EQ("12345", builder.Finalize()); 542e5b6d6dSopenharmony_ci 552e5b6d6dSopenharmony_ci builder.Reset(); 562e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(12345e23, &builder)); 572e5b6d6dSopenharmony_ci CHECK_EQ("1.2345e+27", builder.Finalize()); 582e5b6d6dSopenharmony_ci 592e5b6d6dSopenharmony_ci builder.Reset(); 602e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(1e21, &builder)); 612e5b6d6dSopenharmony_ci CHECK_EQ("1e+21", builder.Finalize()); 622e5b6d6dSopenharmony_ci 632e5b6d6dSopenharmony_ci builder.Reset(); 642e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(1e-23, &builder)); 652e5b6d6dSopenharmony_ci CHECK_EQ("1e-23", builder.Finalize()); 662e5b6d6dSopenharmony_ci 672e5b6d6dSopenharmony_ci builder.Reset(); 682e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(1e20, &builder)); 692e5b6d6dSopenharmony_ci CHECK_EQ("100000000000000000000", builder.Finalize()); 702e5b6d6dSopenharmony_ci 712e5b6d6dSopenharmony_ci builder.Reset(); 722e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(111111111111111111111.0, &builder)); 732e5b6d6dSopenharmony_ci CHECK_EQ("111111111111111110000", builder.Finalize()); 742e5b6d6dSopenharmony_ci 752e5b6d6dSopenharmony_ci builder.Reset(); 762e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(1111111111111111111111.0, &builder)); 772e5b6d6dSopenharmony_ci CHECK_EQ("1.1111111111111111e+21", builder.Finalize()); 782e5b6d6dSopenharmony_ci 792e5b6d6dSopenharmony_ci builder.Reset(); 802e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(11111111111111111111111.0, &builder)); 812e5b6d6dSopenharmony_ci CHECK_EQ("1.1111111111111111e+22", builder.Finalize()); 822e5b6d6dSopenharmony_ci 832e5b6d6dSopenharmony_ci builder.Reset(); 842e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(-0.00001, &builder)); 852e5b6d6dSopenharmony_ci CHECK_EQ("-0.00001", builder.Finalize()); 862e5b6d6dSopenharmony_ci 872e5b6d6dSopenharmony_ci builder.Reset(); 882e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(-0.000001, &builder)); 892e5b6d6dSopenharmony_ci CHECK_EQ("-0.000001", builder.Finalize()); 902e5b6d6dSopenharmony_ci 912e5b6d6dSopenharmony_ci builder.Reset(); 922e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(-0.0000001, &builder)); 932e5b6d6dSopenharmony_ci CHECK_EQ("-1e-7", builder.Finalize()); 942e5b6d6dSopenharmony_ci 952e5b6d6dSopenharmony_ci builder.Reset(); 962e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(-0.0, &builder)); 972e5b6d6dSopenharmony_ci CHECK_EQ("0", builder.Finalize()); 982e5b6d6dSopenharmony_ci 992e5b6d6dSopenharmony_ci // Test min_exponent_width 1002e5b6d6dSopenharmony_ci flags = DoubleToStringConverter::UNIQUE_ZERO | 1012e5b6d6dSopenharmony_ci DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN; 1022e5b6d6dSopenharmony_ci DoubleToStringConverter dcExpWidth2(flags, NULL, NULL, 'e', -4, 6, 0, 0, 2); 1032e5b6d6dSopenharmony_ci 1042e5b6d6dSopenharmony_ci builder.Reset(); 1052e5b6d6dSopenharmony_ci CHECK(dcExpWidth2.ToShortest(11111111111.0, &builder)); 1062e5b6d6dSopenharmony_ci CHECK_EQ("1.1111111111e+10", builder.Finalize()); 1072e5b6d6dSopenharmony_ci 1082e5b6d6dSopenharmony_ci builder.Reset(); 1092e5b6d6dSopenharmony_ci CHECK(dcExpWidth2.ToShortest(1111111111.0, &builder)); 1102e5b6d6dSopenharmony_ci CHECK_EQ("1.111111111e+09", builder.Finalize()); 1112e5b6d6dSopenharmony_ci 1122e5b6d6dSopenharmony_ci builder.Reset(); 1132e5b6d6dSopenharmony_ci CHECK(dcExpWidth2.ToShortest(1111111.0, &builder)); 1142e5b6d6dSopenharmony_ci CHECK_EQ("1.111111e+06", builder.Finalize()); 1152e5b6d6dSopenharmony_ci 1162e5b6d6dSopenharmony_ci builder.Reset(); 1172e5b6d6dSopenharmony_ci CHECK(dcExpWidth2.ToShortest(111111.0, &builder)); 1182e5b6d6dSopenharmony_ci CHECK_EQ("111111", builder.Finalize()); 1192e5b6d6dSopenharmony_ci 1202e5b6d6dSopenharmony_ci builder.Reset(); 1212e5b6d6dSopenharmony_ci CHECK(dcExpWidth2.ToShortest(10000000000.0, &builder)); 1222e5b6d6dSopenharmony_ci CHECK_EQ("1e+10", builder.Finalize()); 1232e5b6d6dSopenharmony_ci 1242e5b6d6dSopenharmony_ci builder.Reset(); 1252e5b6d6dSopenharmony_ci CHECK(dcExpWidth2.ToShortest(1000000000.0, &builder)); 1262e5b6d6dSopenharmony_ci CHECK_EQ("1e+09", builder.Finalize()); 1272e5b6d6dSopenharmony_ci 1282e5b6d6dSopenharmony_ci DoubleToStringConverter dcExpWidth0(flags, NULL, NULL, 'e', -4, 6, 0, 0, 0); 1292e5b6d6dSopenharmony_ci 1302e5b6d6dSopenharmony_ci builder.Reset(); 1312e5b6d6dSopenharmony_ci CHECK(dcExpWidth0.ToShortest(11111111111.0, &builder)); 1322e5b6d6dSopenharmony_ci CHECK_EQ("1.1111111111e+10", builder.Finalize()); 1332e5b6d6dSopenharmony_ci 1342e5b6d6dSopenharmony_ci builder.Reset(); 1352e5b6d6dSopenharmony_ci CHECK(dcExpWidth0.ToShortest(1111111111.0, &builder)); 1362e5b6d6dSopenharmony_ci CHECK_EQ("1.111111111e+9", builder.Finalize()); 1372e5b6d6dSopenharmony_ci 1382e5b6d6dSopenharmony_ci builder.Reset(); 1392e5b6d6dSopenharmony_ci CHECK(dcExpWidth0.ToShortest(1111111.0, &builder)); 1402e5b6d6dSopenharmony_ci CHECK_EQ("1.111111e+6", builder.Finalize()); 1412e5b6d6dSopenharmony_ci 1422e5b6d6dSopenharmony_ci builder.Reset(); 1432e5b6d6dSopenharmony_ci CHECK(dcExpWidth0.ToShortest(111111.0, &builder)); 1442e5b6d6dSopenharmony_ci CHECK_EQ("111111", builder.Finalize()); 1452e5b6d6dSopenharmony_ci 1462e5b6d6dSopenharmony_ci builder.Reset(); 1472e5b6d6dSopenharmony_ci CHECK(dcExpWidth0.ToShortest(10000000000.0, &builder)); 1482e5b6d6dSopenharmony_ci CHECK_EQ("1e+10", builder.Finalize()); 1492e5b6d6dSopenharmony_ci 1502e5b6d6dSopenharmony_ci builder.Reset(); 1512e5b6d6dSopenharmony_ci CHECK(dcExpWidth0.ToShortest(1000000000.0, &builder)); 1522e5b6d6dSopenharmony_ci CHECK_EQ("1e+9", builder.Finalize()); 1532e5b6d6dSopenharmony_ci 1542e5b6d6dSopenharmony_ci // Set min_exponent_width to 100 is equal to 5, 1552e5b6d6dSopenharmony_ci // as kMaxExponentLength is defined to 5 in double-to-string.cc 1562e5b6d6dSopenharmony_ci DoubleToStringConverter dcExpWidth100(flags, NULL, NULL, 'e', -4, 6, 0, 0, 100); 1572e5b6d6dSopenharmony_ci 1582e5b6d6dSopenharmony_ci builder.Reset(); 1592e5b6d6dSopenharmony_ci CHECK(dcExpWidth100.ToShortest(11111111111.0, &builder)); 1602e5b6d6dSopenharmony_ci CHECK_EQ("1.1111111111e+00010", builder.Finalize()); 1612e5b6d6dSopenharmony_ci 1622e5b6d6dSopenharmony_ci builder.Reset(); 1632e5b6d6dSopenharmony_ci CHECK(dcExpWidth100.ToShortest(1111111111.0, &builder)); 1642e5b6d6dSopenharmony_ci CHECK_EQ("1.111111111e+00009", builder.Finalize()); 1652e5b6d6dSopenharmony_ci 1662e5b6d6dSopenharmony_ci builder.Reset(); 1672e5b6d6dSopenharmony_ci CHECK(dcExpWidth100.ToShortest(1111111.0, &builder)); 1682e5b6d6dSopenharmony_ci CHECK_EQ("1.111111e+00006", builder.Finalize()); 1692e5b6d6dSopenharmony_ci 1702e5b6d6dSopenharmony_ci builder.Reset(); 1712e5b6d6dSopenharmony_ci CHECK(dcExpWidth100.ToShortest(111111.0, &builder)); 1722e5b6d6dSopenharmony_ci CHECK_EQ("111111", builder.Finalize()); 1732e5b6d6dSopenharmony_ci 1742e5b6d6dSopenharmony_ci builder.Reset(); 1752e5b6d6dSopenharmony_ci CHECK(dcExpWidth100.ToShortest(10000000000.0, &builder)); 1762e5b6d6dSopenharmony_ci CHECK_EQ("1e+00010", builder.Finalize()); 1772e5b6d6dSopenharmony_ci 1782e5b6d6dSopenharmony_ci builder.Reset(); 1792e5b6d6dSopenharmony_ci CHECK(dcExpWidth100.ToShortest(1000000000.0, &builder)); 1802e5b6d6dSopenharmony_ci CHECK_EQ("1e+00009", builder.Finalize()); 1812e5b6d6dSopenharmony_ci // End of min_exponent_width testing 1822e5b6d6dSopenharmony_ci 1832e5b6d6dSopenharmony_ci flags = DoubleToStringConverter::NO_FLAGS; 1842e5b6d6dSopenharmony_ci DoubleToStringConverter dc2(flags, NULL, NULL, 'e', -1, 1, 0, 0); 1852e5b6d6dSopenharmony_ci builder.Reset(); 1862e5b6d6dSopenharmony_ci CHECK(dc2.ToShortest(0.1, &builder)); 1872e5b6d6dSopenharmony_ci CHECK_EQ("0.1", builder.Finalize()); 1882e5b6d6dSopenharmony_ci 1892e5b6d6dSopenharmony_ci builder.Reset(); 1902e5b6d6dSopenharmony_ci CHECK(dc2.ToShortest(0.01, &builder)); 1912e5b6d6dSopenharmony_ci CHECK_EQ("1e-2", builder.Finalize()); 1922e5b6d6dSopenharmony_ci 1932e5b6d6dSopenharmony_ci builder.Reset(); 1942e5b6d6dSopenharmony_ci CHECK(dc2.ToShortest(1.0, &builder)); 1952e5b6d6dSopenharmony_ci CHECK_EQ("1", builder.Finalize()); 1962e5b6d6dSopenharmony_ci 1972e5b6d6dSopenharmony_ci builder.Reset(); 1982e5b6d6dSopenharmony_ci CHECK(dc2.ToShortest(10.0, &builder)); 1992e5b6d6dSopenharmony_ci CHECK_EQ("1e1", builder.Finalize()); 2002e5b6d6dSopenharmony_ci 2012e5b6d6dSopenharmony_ci builder.Reset(); 2022e5b6d6dSopenharmony_ci CHECK(dc2.ToShortest(-0.0, &builder)); 2032e5b6d6dSopenharmony_ci CHECK_EQ("-0", builder.Finalize()); 2042e5b6d6dSopenharmony_ci 2052e5b6d6dSopenharmony_ci flags = DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT | 2062e5b6d6dSopenharmony_ci DoubleToStringConverter::EMIT_TRAILING_ZERO_AFTER_POINT; 2072e5b6d6dSopenharmony_ci DoubleToStringConverter dc3(flags, NULL, NULL, 'E', -5, 5, 0, 0); 2082e5b6d6dSopenharmony_ci 2092e5b6d6dSopenharmony_ci builder.Reset(); 2102e5b6d6dSopenharmony_ci CHECK(dc3.ToShortest(0.1, &builder)); 2112e5b6d6dSopenharmony_ci CHECK_EQ("0.1", builder.Finalize()); 2122e5b6d6dSopenharmony_ci 2132e5b6d6dSopenharmony_ci builder.Reset(); 2142e5b6d6dSopenharmony_ci CHECK(dc3.ToShortest(1.0, &builder)); 2152e5b6d6dSopenharmony_ci CHECK_EQ("1.0", builder.Finalize()); 2162e5b6d6dSopenharmony_ci 2172e5b6d6dSopenharmony_ci builder.Reset(); 2182e5b6d6dSopenharmony_ci CHECK(dc3.ToShortest(10000.0, &builder)); 2192e5b6d6dSopenharmony_ci CHECK_EQ("10000.0", builder.Finalize()); 2202e5b6d6dSopenharmony_ci 2212e5b6d6dSopenharmony_ci builder.Reset(); 2222e5b6d6dSopenharmony_ci CHECK(dc3.ToShortest(100000.0, &builder)); 2232e5b6d6dSopenharmony_ci CHECK_EQ("1E5", builder.Finalize()); 2242e5b6d6dSopenharmony_ci 2252e5b6d6dSopenharmony_ci // Test the examples in the comments of ToShortest. 2262e5b6d6dSopenharmony_ci flags = DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN; 2272e5b6d6dSopenharmony_ci DoubleToStringConverter dc4(flags, NULL, NULL, 'e', -6, 21, 0, 0); 2282e5b6d6dSopenharmony_ci 2292e5b6d6dSopenharmony_ci builder.Reset(); 2302e5b6d6dSopenharmony_ci CHECK(dc4.ToShortest(0.000001, &builder)); 2312e5b6d6dSopenharmony_ci CHECK_EQ("0.000001", builder.Finalize()); 2322e5b6d6dSopenharmony_ci 2332e5b6d6dSopenharmony_ci builder.Reset(); 2342e5b6d6dSopenharmony_ci CHECK(dc4.ToShortest(0.0000001, &builder)); 2352e5b6d6dSopenharmony_ci CHECK_EQ("1e-7", builder.Finalize()); 2362e5b6d6dSopenharmony_ci 2372e5b6d6dSopenharmony_ci builder.Reset(); 2382e5b6d6dSopenharmony_ci CHECK(dc4.ToShortest(111111111111111111111.0, &builder)); 2392e5b6d6dSopenharmony_ci CHECK_EQ("111111111111111110000", builder.Finalize()); 2402e5b6d6dSopenharmony_ci 2412e5b6d6dSopenharmony_ci builder.Reset(); 2422e5b6d6dSopenharmony_ci CHECK(dc4.ToShortest(100000000000000000000.0, &builder)); 2432e5b6d6dSopenharmony_ci CHECK_EQ("100000000000000000000", builder.Finalize()); 2442e5b6d6dSopenharmony_ci 2452e5b6d6dSopenharmony_ci builder.Reset(); 2462e5b6d6dSopenharmony_ci CHECK(dc4.ToShortest(1111111111111111111111.0, &builder)); 2472e5b6d6dSopenharmony_ci CHECK_EQ("1.1111111111111111e+21", builder.Finalize()); 2482e5b6d6dSopenharmony_ci 2492e5b6d6dSopenharmony_ci // Test special value handling. 2502e5b6d6dSopenharmony_ci DoubleToStringConverter dc5(flags, NULL, NULL, 'e', 0, 0, 0, 0); 2512e5b6d6dSopenharmony_ci 2522e5b6d6dSopenharmony_ci builder.Reset(); 2532e5b6d6dSopenharmony_ci CHECK(!dc5.ToShortest(Double::Infinity(), &builder)); 2542e5b6d6dSopenharmony_ci 2552e5b6d6dSopenharmony_ci builder.Reset(); 2562e5b6d6dSopenharmony_ci CHECK(!dc5.ToShortest(-Double::Infinity(), &builder)); 2572e5b6d6dSopenharmony_ci 2582e5b6d6dSopenharmony_ci builder.Reset(); 2592e5b6d6dSopenharmony_ci CHECK(!dc5.ToShortest(Double::NaN(), &builder)); 2602e5b6d6dSopenharmony_ci 2612e5b6d6dSopenharmony_ci builder.Reset(); 2622e5b6d6dSopenharmony_ci CHECK(!dc5.ToShortest(-Double::NaN(), &builder)); 2632e5b6d6dSopenharmony_ci 2642e5b6d6dSopenharmony_ci DoubleToStringConverter dc6(flags, "Infinity", "NaN", 'e', 0, 0, 0, 0); 2652e5b6d6dSopenharmony_ci 2662e5b6d6dSopenharmony_ci builder.Reset(); 2672e5b6d6dSopenharmony_ci CHECK(dc6.ToShortest(Double::Infinity(), &builder)); 2682e5b6d6dSopenharmony_ci CHECK_EQ("Infinity", builder.Finalize()); 2692e5b6d6dSopenharmony_ci 2702e5b6d6dSopenharmony_ci builder.Reset(); 2712e5b6d6dSopenharmony_ci CHECK(dc6.ToShortest(-Double::Infinity(), &builder)); 2722e5b6d6dSopenharmony_ci CHECK_EQ("-Infinity", builder.Finalize()); 2732e5b6d6dSopenharmony_ci 2742e5b6d6dSopenharmony_ci builder.Reset(); 2752e5b6d6dSopenharmony_ci CHECK(dc6.ToShortest(Double::NaN(), &builder)); 2762e5b6d6dSopenharmony_ci CHECK_EQ("NaN", builder.Finalize()); 2772e5b6d6dSopenharmony_ci 2782e5b6d6dSopenharmony_ci builder.Reset(); 2792e5b6d6dSopenharmony_ci CHECK(dc6.ToShortest(-Double::NaN(), &builder)); 2802e5b6d6dSopenharmony_ci CHECK_EQ("NaN", builder.Finalize()); 2812e5b6d6dSopenharmony_ci} 2822e5b6d6dSopenharmony_ci 2832e5b6d6dSopenharmony_ci 2842e5b6d6dSopenharmony_ciTEST(DoubleToShortestSingle) { 2852e5b6d6dSopenharmony_ci const int kBufferSize = 128; 2862e5b6d6dSopenharmony_ci char buffer[kBufferSize]; 2872e5b6d6dSopenharmony_ci StringBuilder builder(buffer, kBufferSize); 2882e5b6d6dSopenharmony_ci int flags = DoubleToStringConverter::UNIQUE_ZERO | 2892e5b6d6dSopenharmony_ci DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN; 2902e5b6d6dSopenharmony_ci DoubleToStringConverter dc(flags, NULL, NULL, 'e', -6, 21, 0, 0); 2912e5b6d6dSopenharmony_ci 2922e5b6d6dSopenharmony_ci CHECK(dc.ToShortestSingle(0.0f, &builder)); 2932e5b6d6dSopenharmony_ci CHECK_EQ("0", builder.Finalize()); 2942e5b6d6dSopenharmony_ci 2952e5b6d6dSopenharmony_ci builder.Reset(); 2962e5b6d6dSopenharmony_ci CHECK(dc.ToShortestSingle(12345.0f, &builder)); 2972e5b6d6dSopenharmony_ci CHECK_EQ("12345", builder.Finalize()); 2982e5b6d6dSopenharmony_ci 2992e5b6d6dSopenharmony_ci builder.Reset(); 3002e5b6d6dSopenharmony_ci CHECK(dc.ToShortestSingle(12345e23f, &builder)); 3012e5b6d6dSopenharmony_ci CHECK_EQ("1.2345e+27", builder.Finalize()); 3022e5b6d6dSopenharmony_ci 3032e5b6d6dSopenharmony_ci builder.Reset(); 3042e5b6d6dSopenharmony_ci CHECK(dc.ToShortestSingle(1e21f, &builder)); 3052e5b6d6dSopenharmony_ci CHECK_EQ("1e+21", builder.Finalize()); 3062e5b6d6dSopenharmony_ci 3072e5b6d6dSopenharmony_ci builder.Reset(); 3082e5b6d6dSopenharmony_ci CHECK(dc.ToShortestSingle(1e20f, &builder)); 3092e5b6d6dSopenharmony_ci CHECK_EQ("100000000000000000000", builder.Finalize()); 3102e5b6d6dSopenharmony_ci 3112e5b6d6dSopenharmony_ci builder.Reset(); 3122e5b6d6dSopenharmony_ci CHECK(dc.ToShortestSingle(111111111111111111111.0f, &builder)); 3132e5b6d6dSopenharmony_ci CHECK_EQ("111111110000000000000", builder.Finalize()); 3142e5b6d6dSopenharmony_ci 3152e5b6d6dSopenharmony_ci builder.Reset(); 3162e5b6d6dSopenharmony_ci CHECK(dc.ToShortestSingle(1111111111111111111111.0f, &builder)); 3172e5b6d6dSopenharmony_ci CHECK_EQ("1.11111114e+21", builder.Finalize()); 3182e5b6d6dSopenharmony_ci 3192e5b6d6dSopenharmony_ci builder.Reset(); 3202e5b6d6dSopenharmony_ci CHECK(dc.ToShortestSingle(11111111111111111111111.0f, &builder)); 3212e5b6d6dSopenharmony_ci CHECK_EQ("1.1111111e+22", builder.Finalize()); 3222e5b6d6dSopenharmony_ci 3232e5b6d6dSopenharmony_ci builder.Reset(); 3242e5b6d6dSopenharmony_ci CHECK(dc.ToShortestSingle(-0.00001f, &builder)); 3252e5b6d6dSopenharmony_ci CHECK_EQ("-0.00001", builder.Finalize()); 3262e5b6d6dSopenharmony_ci 3272e5b6d6dSopenharmony_ci builder.Reset(); 3282e5b6d6dSopenharmony_ci CHECK(dc.ToShortestSingle(-0.000001f, &builder)); 3292e5b6d6dSopenharmony_ci CHECK_EQ("-0.000001", builder.Finalize()); 3302e5b6d6dSopenharmony_ci 3312e5b6d6dSopenharmony_ci builder.Reset(); 3322e5b6d6dSopenharmony_ci CHECK(dc.ToShortestSingle(-0.0000001f, &builder)); 3332e5b6d6dSopenharmony_ci CHECK_EQ("-1e-7", builder.Finalize()); 3342e5b6d6dSopenharmony_ci 3352e5b6d6dSopenharmony_ci builder.Reset(); 3362e5b6d6dSopenharmony_ci CHECK(dc.ToShortestSingle(-0.0f, &builder)); 3372e5b6d6dSopenharmony_ci CHECK_EQ("0", builder.Finalize()); 3382e5b6d6dSopenharmony_ci 3392e5b6d6dSopenharmony_ci flags = DoubleToStringConverter::NO_FLAGS; 3402e5b6d6dSopenharmony_ci DoubleToStringConverter dc2(flags, NULL, NULL, 'e', -1, 1, 0, 0); 3412e5b6d6dSopenharmony_ci builder.Reset(); 3422e5b6d6dSopenharmony_ci CHECK(dc2.ToShortestSingle(0.1f, &builder)); 3432e5b6d6dSopenharmony_ci CHECK_EQ("0.1", builder.Finalize()); 3442e5b6d6dSopenharmony_ci 3452e5b6d6dSopenharmony_ci builder.Reset(); 3462e5b6d6dSopenharmony_ci CHECK(dc2.ToShortestSingle(0.01f, &builder)); 3472e5b6d6dSopenharmony_ci CHECK_EQ("1e-2", builder.Finalize()); 3482e5b6d6dSopenharmony_ci 3492e5b6d6dSopenharmony_ci builder.Reset(); 3502e5b6d6dSopenharmony_ci CHECK(dc2.ToShortestSingle(1.0f, &builder)); 3512e5b6d6dSopenharmony_ci CHECK_EQ("1", builder.Finalize()); 3522e5b6d6dSopenharmony_ci 3532e5b6d6dSopenharmony_ci builder.Reset(); 3542e5b6d6dSopenharmony_ci CHECK(dc2.ToShortestSingle(10.0f, &builder)); 3552e5b6d6dSopenharmony_ci CHECK_EQ("1e1", builder.Finalize()); 3562e5b6d6dSopenharmony_ci 3572e5b6d6dSopenharmony_ci builder.Reset(); 3582e5b6d6dSopenharmony_ci CHECK(dc2.ToShortestSingle(-0.0f, &builder)); 3592e5b6d6dSopenharmony_ci CHECK_EQ("-0", builder.Finalize()); 3602e5b6d6dSopenharmony_ci 3612e5b6d6dSopenharmony_ci flags = DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT | 3622e5b6d6dSopenharmony_ci DoubleToStringConverter::EMIT_TRAILING_ZERO_AFTER_POINT; 3632e5b6d6dSopenharmony_ci DoubleToStringConverter dc3(flags, NULL, NULL, 'E', -5, 5, 0, 0); 3642e5b6d6dSopenharmony_ci 3652e5b6d6dSopenharmony_ci builder.Reset(); 3662e5b6d6dSopenharmony_ci CHECK(dc3.ToShortestSingle(0.1f, &builder)); 3672e5b6d6dSopenharmony_ci CHECK_EQ("0.1", builder.Finalize()); 3682e5b6d6dSopenharmony_ci 3692e5b6d6dSopenharmony_ci builder.Reset(); 3702e5b6d6dSopenharmony_ci CHECK(dc3.ToShortestSingle(1.0f, &builder)); 3712e5b6d6dSopenharmony_ci CHECK_EQ("1.0", builder.Finalize()); 3722e5b6d6dSopenharmony_ci 3732e5b6d6dSopenharmony_ci builder.Reset(); 3742e5b6d6dSopenharmony_ci CHECK(dc3.ToShortestSingle(10000.0f, &builder)); 3752e5b6d6dSopenharmony_ci CHECK_EQ("10000.0", builder.Finalize()); 3762e5b6d6dSopenharmony_ci 3772e5b6d6dSopenharmony_ci builder.Reset(); 3782e5b6d6dSopenharmony_ci CHECK(dc3.ToShortestSingle(100000.0f, &builder)); 3792e5b6d6dSopenharmony_ci CHECK_EQ("1E5", builder.Finalize()); 3802e5b6d6dSopenharmony_ci 3812e5b6d6dSopenharmony_ci // Test the examples in the comments of ToShortestSingle. 3822e5b6d6dSopenharmony_ci flags = DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN; 3832e5b6d6dSopenharmony_ci DoubleToStringConverter dc4(flags, NULL, NULL, 'e', -6, 21, 0, 0); 3842e5b6d6dSopenharmony_ci 3852e5b6d6dSopenharmony_ci builder.Reset(); 3862e5b6d6dSopenharmony_ci CHECK(dc4.ToShortestSingle(0.000001f, &builder)); 3872e5b6d6dSopenharmony_ci CHECK_EQ("0.000001", builder.Finalize()); 3882e5b6d6dSopenharmony_ci 3892e5b6d6dSopenharmony_ci builder.Reset(); 3902e5b6d6dSopenharmony_ci CHECK(dc4.ToShortestSingle(0.0000001f, &builder)); 3912e5b6d6dSopenharmony_ci CHECK_EQ("1e-7", builder.Finalize()); 3922e5b6d6dSopenharmony_ci 3932e5b6d6dSopenharmony_ci builder.Reset(); 3942e5b6d6dSopenharmony_ci CHECK(dc4.ToShortestSingle(111111111111111111111.0f, &builder)); 3952e5b6d6dSopenharmony_ci CHECK_EQ("111111110000000000000", builder.Finalize()); 3962e5b6d6dSopenharmony_ci 3972e5b6d6dSopenharmony_ci builder.Reset(); 3982e5b6d6dSopenharmony_ci CHECK(dc4.ToShortestSingle(100000000000000000000.0f, &builder)); 3992e5b6d6dSopenharmony_ci CHECK_EQ("100000000000000000000", builder.Finalize()); 4002e5b6d6dSopenharmony_ci 4012e5b6d6dSopenharmony_ci builder.Reset(); 4022e5b6d6dSopenharmony_ci CHECK(dc4.ToShortestSingle(1111111111111111111111.0f, &builder)); 4032e5b6d6dSopenharmony_ci CHECK_EQ("1.11111114e+21", builder.Finalize()); 4042e5b6d6dSopenharmony_ci 4052e5b6d6dSopenharmony_ci // Test special value handling. 4062e5b6d6dSopenharmony_ci DoubleToStringConverter dc5(flags, NULL, NULL, 'e', 0, 0, 0, 0); 4072e5b6d6dSopenharmony_ci 4082e5b6d6dSopenharmony_ci builder.Reset(); 4092e5b6d6dSopenharmony_ci CHECK(!dc5.ToShortestSingle(Single::Infinity(), &builder)); 4102e5b6d6dSopenharmony_ci 4112e5b6d6dSopenharmony_ci builder.Reset(); 4122e5b6d6dSopenharmony_ci CHECK(!dc5.ToShortestSingle(-Single::Infinity(), &builder)); 4132e5b6d6dSopenharmony_ci 4142e5b6d6dSopenharmony_ci builder.Reset(); 4152e5b6d6dSopenharmony_ci CHECK(!dc5.ToShortestSingle(Single::NaN(), &builder)); 4162e5b6d6dSopenharmony_ci 4172e5b6d6dSopenharmony_ci builder.Reset(); 4182e5b6d6dSopenharmony_ci CHECK(!dc5.ToShortestSingle(-Single::NaN(), &builder)); 4192e5b6d6dSopenharmony_ci 4202e5b6d6dSopenharmony_ci DoubleToStringConverter dc6(flags, "Infinity", "NaN", 'e', 0, 0, 0, 0); 4212e5b6d6dSopenharmony_ci 4222e5b6d6dSopenharmony_ci builder.Reset(); 4232e5b6d6dSopenharmony_ci CHECK(dc6.ToShortestSingle(Single::Infinity(), &builder)); 4242e5b6d6dSopenharmony_ci CHECK_EQ("Infinity", builder.Finalize()); 4252e5b6d6dSopenharmony_ci 4262e5b6d6dSopenharmony_ci builder.Reset(); 4272e5b6d6dSopenharmony_ci CHECK(dc6.ToShortestSingle(-Single::Infinity(), &builder)); 4282e5b6d6dSopenharmony_ci CHECK_EQ("-Infinity", builder.Finalize()); 4292e5b6d6dSopenharmony_ci 4302e5b6d6dSopenharmony_ci builder.Reset(); 4312e5b6d6dSopenharmony_ci CHECK(dc6.ToShortestSingle(Single::NaN(), &builder)); 4322e5b6d6dSopenharmony_ci CHECK_EQ("NaN", builder.Finalize()); 4332e5b6d6dSopenharmony_ci 4342e5b6d6dSopenharmony_ci builder.Reset(); 4352e5b6d6dSopenharmony_ci CHECK(dc6.ToShortestSingle(-Single::NaN(), &builder)); 4362e5b6d6dSopenharmony_ci CHECK_EQ("NaN", builder.Finalize()); 4372e5b6d6dSopenharmony_ci} 4382e5b6d6dSopenharmony_ci 4392e5b6d6dSopenharmony_ci 4402e5b6d6dSopenharmony_ciTEST(DoubleToFixed) { 4412e5b6d6dSopenharmony_ci const int kBufferSize = 168; 4422e5b6d6dSopenharmony_ci char buffer[kBufferSize]; 4432e5b6d6dSopenharmony_ci StringBuilder builder(buffer, kBufferSize); 4442e5b6d6dSopenharmony_ci int flags = DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN | 4452e5b6d6dSopenharmony_ci DoubleToStringConverter::UNIQUE_ZERO; 4462e5b6d6dSopenharmony_ci DoubleToStringConverter dc(flags, "Infinity", "NaN", 'e', 4472e5b6d6dSopenharmony_ci 0, 0, 0, 0); // Padding zeroes. 4482e5b6d6dSopenharmony_ci 4492e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(0.0, 0, &builder)); 4502e5b6d6dSopenharmony_ci CHECK_EQ("0", builder.Finalize()); 4512e5b6d6dSopenharmony_ci 4522e5b6d6dSopenharmony_ci builder.Reset(); 4532e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-0.0, 0, &builder)); 4542e5b6d6dSopenharmony_ci CHECK_EQ("0", builder.Finalize()); 4552e5b6d6dSopenharmony_ci 4562e5b6d6dSopenharmony_ci builder.Reset(); 4572e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-0.0, 1, &builder)); 4582e5b6d6dSopenharmony_ci CHECK_EQ("0.0", builder.Finalize()); 4592e5b6d6dSopenharmony_ci 4602e5b6d6dSopenharmony_ci builder.Reset(); 4612e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-0.0, 1, &builder)); 4622e5b6d6dSopenharmony_ci CHECK_EQ("0.0", builder.Finalize()); 4632e5b6d6dSopenharmony_ci 4642e5b6d6dSopenharmony_ci DOUBLE_CONVERSION_ASSERT(DoubleToStringConverter::kMaxFixedDigitsBeforePoint == 60); 4652e5b6d6dSopenharmony_ci DOUBLE_CONVERSION_ASSERT(DoubleToStringConverter::kMaxFixedDigitsAfterPoint == 100); 4662e5b6d6dSopenharmony_ci 4672e5b6d6dSopenharmony_ci // Most of the 100 digit tests were copied from 4682e5b6d6dSopenharmony_ci // https://searchfox.org/mozilla-central/source/js/src/tests/non262/Number/toFixed-values.js. 4692e5b6d6dSopenharmony_ci 4702e5b6d6dSopenharmony_ci builder.Reset(); 4712e5b6d6dSopenharmony_ci CHECK(dc.ToFixed( 4722e5b6d6dSopenharmony_ci 0.0, DoubleToStringConverter::kMaxFixedDigitsAfterPoint, &builder)); 4732e5b6d6dSopenharmony_ci CHECK_EQ("0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 4742e5b6d6dSopenharmony_ci builder.Finalize()); 4752e5b6d6dSopenharmony_ci 4762e5b6d6dSopenharmony_ci builder.Reset(); 4772e5b6d6dSopenharmony_ci CHECK(dc.ToFixed( 4782e5b6d6dSopenharmony_ci 9e59, DoubleToStringConverter::kMaxFixedDigitsAfterPoint, &builder)); 4792e5b6d6dSopenharmony_ci CHECK_EQ("899999999999999918767229449717619953810131273674690656206848." 4802e5b6d6dSopenharmony_ci "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 4812e5b6d6dSopenharmony_ci builder.Finalize()); 4822e5b6d6dSopenharmony_ci 4832e5b6d6dSopenharmony_ci builder.Reset(); 4842e5b6d6dSopenharmony_ci CHECK(dc.ToFixed( 4852e5b6d6dSopenharmony_ci -9e59, DoubleToStringConverter::kMaxFixedDigitsAfterPoint, &builder)); 4862e5b6d6dSopenharmony_ci CHECK_EQ("-899999999999999918767229449717619953810131273674690656206848." 4872e5b6d6dSopenharmony_ci "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 4882e5b6d6dSopenharmony_ci builder.Finalize()); 4892e5b6d6dSopenharmony_ci 4902e5b6d6dSopenharmony_ci builder.Reset(); 4912e5b6d6dSopenharmony_ci CHECK(dc.ToFixed( 4922e5b6d6dSopenharmony_ci 1e-100, DoubleToStringConverter::kMaxFixedDigitsAfterPoint, &builder)); 4932e5b6d6dSopenharmony_ci CHECK_EQ("0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 4942e5b6d6dSopenharmony_ci builder.Finalize()); 4952e5b6d6dSopenharmony_ci 4962e5b6d6dSopenharmony_ci builder.Reset(); 4972e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(0.3000000000000000444089209850062616169452667236328125, 4982e5b6d6dSopenharmony_ci DoubleToStringConverter::kMaxFixedDigitsAfterPoint, 4992e5b6d6dSopenharmony_ci &builder)); 5002e5b6d6dSopenharmony_ci CHECK_EQ("0.3000000000000000444089209850062616169452667236328125000000000000000000000000000000000000000000000000", 5012e5b6d6dSopenharmony_ci builder.Finalize()); 5022e5b6d6dSopenharmony_ci 5032e5b6d6dSopenharmony_ci builder.Reset(); 5042e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(1.5e-100, 5052e5b6d6dSopenharmony_ci DoubleToStringConverter::kMaxFixedDigitsAfterPoint, 5062e5b6d6dSopenharmony_ci &builder)); 5072e5b6d6dSopenharmony_ci CHECK_EQ("0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002", 5082e5b6d6dSopenharmony_ci builder.Finalize()); 5092e5b6d6dSopenharmony_ci 5102e5b6d6dSopenharmony_ci builder.Reset(); 5112e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(1.15e-99, // In reality: 1.14999999999999992147301128036734... 5122e5b6d6dSopenharmony_ci DoubleToStringConverter::kMaxFixedDigitsAfterPoint, 5132e5b6d6dSopenharmony_ci &builder)); 5142e5b6d6dSopenharmony_ci CHECK_EQ("0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011", 5152e5b6d6dSopenharmony_ci builder.Finalize()); 5162e5b6d6dSopenharmony_ci 5172e5b6d6dSopenharmony_ci builder.Reset(); 5182e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(3.141592653589793, 5192e5b6d6dSopenharmony_ci DoubleToStringConverter::kMaxFixedDigitsAfterPoint, 5202e5b6d6dSopenharmony_ci &builder)); 5212e5b6d6dSopenharmony_ci CHECK_EQ("3.1415926535897931159979634685441851615905761718750000000000000000000000000000000000000000000000000000", 5222e5b6d6dSopenharmony_ci builder.Finalize()); 5232e5b6d6dSopenharmony_ci 5242e5b6d6dSopenharmony_ci builder.Reset(); 5252e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(1.0, 5262e5b6d6dSopenharmony_ci DoubleToStringConverter::kMaxFixedDigitsAfterPoint, 5272e5b6d6dSopenharmony_ci &builder)); 5282e5b6d6dSopenharmony_ci CHECK_EQ("1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 5292e5b6d6dSopenharmony_ci builder.Finalize()); 5302e5b6d6dSopenharmony_ci 5312e5b6d6dSopenharmony_ci builder.Reset(); 5322e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-123456.78, 5332e5b6d6dSopenharmony_ci DoubleToStringConverter::kMaxFixedDigitsAfterPoint, 5342e5b6d6dSopenharmony_ci &builder)); 5352e5b6d6dSopenharmony_ci CHECK_EQ("-123456.7799999999988358467817306518554687500000000000000000000000000000000000000000000000000000000000000000", 5362e5b6d6dSopenharmony_ci builder.Finalize()); 5372e5b6d6dSopenharmony_ci 5382e5b6d6dSopenharmony_ci builder.Reset(); 5392e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(123456.78, 5402e5b6d6dSopenharmony_ci DoubleToStringConverter::kMaxFixedDigitsAfterPoint, 5412e5b6d6dSopenharmony_ci &builder)); 5422e5b6d6dSopenharmony_ci CHECK_EQ("123456.7799999999988358467817306518554687500000000000000000000000000000000000000000000000000000000000000000", 5432e5b6d6dSopenharmony_ci builder.Finalize()); 5442e5b6d6dSopenharmony_ci 5452e5b6d6dSopenharmony_ci builder.Reset(); 5462e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(100000000000000000000.0, 5472e5b6d6dSopenharmony_ci DoubleToStringConverter::kMaxFixedDigitsAfterPoint, 5482e5b6d6dSopenharmony_ci &builder)); 5492e5b6d6dSopenharmony_ci CHECK_EQ("100000000000000000000.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 5502e5b6d6dSopenharmony_ci builder.Finalize()); 5512e5b6d6dSopenharmony_ci 5522e5b6d6dSopenharmony_ci builder.Reset(); 5532e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-100000000000000000000.0, 5542e5b6d6dSopenharmony_ci DoubleToStringConverter::kMaxFixedDigitsAfterPoint, 5552e5b6d6dSopenharmony_ci &builder)); 5562e5b6d6dSopenharmony_ci CHECK_EQ("-100000000000000000000.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 5572e5b6d6dSopenharmony_ci builder.Finalize()); 5582e5b6d6dSopenharmony_ci 5592e5b6d6dSopenharmony_ci builder.Reset(); 5602e5b6d6dSopenharmony_ci CHECK(!dc.ToFixed( 5612e5b6d6dSopenharmony_ci 1e60, DoubleToStringConverter::kMaxFixedDigitsAfterPoint, &builder)); 5622e5b6d6dSopenharmony_ci CHECK_EQ(0, builder.position()); 5632e5b6d6dSopenharmony_ci 5642e5b6d6dSopenharmony_ci builder.Reset(); 5652e5b6d6dSopenharmony_ci CHECK(!dc.ToFixed( 5662e5b6d6dSopenharmony_ci 9e59, DoubleToStringConverter::kMaxFixedDigitsAfterPoint + 1, &builder)); 5672e5b6d6dSopenharmony_ci CHECK_EQ(0, builder.position()); 5682e5b6d6dSopenharmony_ci 5692e5b6d6dSopenharmony_ci builder.Reset(); 5702e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(3.0, 0, &builder)); 5712e5b6d6dSopenharmony_ci CHECK_EQ("3", builder.Finalize()); 5722e5b6d6dSopenharmony_ci 5732e5b6d6dSopenharmony_ci builder.Reset(); 5742e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(3.23, 1, &builder)); 5752e5b6d6dSopenharmony_ci CHECK_EQ("3.2", builder.Finalize()); 5762e5b6d6dSopenharmony_ci 5772e5b6d6dSopenharmony_ci builder.Reset(); 5782e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(3.23, 3, &builder)); 5792e5b6d6dSopenharmony_ci CHECK_EQ("3.230", builder.Finalize()); 5802e5b6d6dSopenharmony_ci 5812e5b6d6dSopenharmony_ci builder.Reset(); 5822e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(0.0323, 2, &builder)); 5832e5b6d6dSopenharmony_ci CHECK_EQ("0.03", builder.Finalize()); 5842e5b6d6dSopenharmony_ci 5852e5b6d6dSopenharmony_ci builder.Reset(); 5862e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(0.0373, 2, &builder)); 5872e5b6d6dSopenharmony_ci CHECK_EQ("0.04", builder.Finalize()); 5882e5b6d6dSopenharmony_ci 5892e5b6d6dSopenharmony_ci builder.Reset(); 5902e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(0.0000373, 2, &builder)); 5912e5b6d6dSopenharmony_ci CHECK_EQ("0.00", builder.Finalize()); 5922e5b6d6dSopenharmony_ci 5932e5b6d6dSopenharmony_ci builder.Reset(); 5942e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(1.5, 0, &builder)); 5952e5b6d6dSopenharmony_ci CHECK_EQ("2", builder.Finalize()); 5962e5b6d6dSopenharmony_ci 5972e5b6d6dSopenharmony_ci builder.Reset(); 5982e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(2.5, 0, &builder)); 5992e5b6d6dSopenharmony_ci CHECK_EQ("3", builder.Finalize()); 6002e5b6d6dSopenharmony_ci 6012e5b6d6dSopenharmony_ci builder.Reset(); 6022e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(3.5, 0, &builder)); 6032e5b6d6dSopenharmony_ci CHECK_EQ("4", builder.Finalize()); 6042e5b6d6dSopenharmony_ci 6052e5b6d6dSopenharmony_ci builder.Reset(); 6062e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(0.15, 1, &builder)); 6072e5b6d6dSopenharmony_ci CHECK_EQ("0.1", builder.Finalize()); 6082e5b6d6dSopenharmony_ci 6092e5b6d6dSopenharmony_ci builder.Reset(); 6102e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(0.25, 1, &builder)); 6112e5b6d6dSopenharmony_ci CHECK_EQ("0.3", builder.Finalize()); 6122e5b6d6dSopenharmony_ci 6132e5b6d6dSopenharmony_ci builder.Reset(); 6142e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(0.35, 1, &builder)); 6152e5b6d6dSopenharmony_ci CHECK_EQ("0.3", builder.Finalize()); 6162e5b6d6dSopenharmony_ci 6172e5b6d6dSopenharmony_ci builder.Reset(); 6182e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(0.45, 1, &builder)); 6192e5b6d6dSopenharmony_ci CHECK_EQ("0.5", builder.Finalize()); 6202e5b6d6dSopenharmony_ci 6212e5b6d6dSopenharmony_ci builder.Reset(); 6222e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(0.55, 1, &builder)); 6232e5b6d6dSopenharmony_ci CHECK_EQ("0.6", builder.Finalize()); 6242e5b6d6dSopenharmony_ci 6252e5b6d6dSopenharmony_ci // Test positive/negative zeroes. 6262e5b6d6dSopenharmony_ci int flags2 = DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN; 6272e5b6d6dSopenharmony_ci DoubleToStringConverter dc2(flags2, "Infinity", "NaN", 'e', 6282e5b6d6dSopenharmony_ci 0, 0, 0, 0); // Padding zeroes. 6292e5b6d6dSopenharmony_ci builder.Reset(); 6302e5b6d6dSopenharmony_ci CHECK(dc2.ToFixed(0.0, 1, &builder)); 6312e5b6d6dSopenharmony_ci CHECK_EQ("0.0", builder.Finalize()); 6322e5b6d6dSopenharmony_ci 6332e5b6d6dSopenharmony_ci builder.Reset(); 6342e5b6d6dSopenharmony_ci CHECK(dc2.ToFixed(-0.0, 1, &builder)); 6352e5b6d6dSopenharmony_ci CHECK_EQ("-0.0", builder.Finalize()); 6362e5b6d6dSopenharmony_ci 6372e5b6d6dSopenharmony_ci // Verify the trailing dot is emitted. 6382e5b6d6dSopenharmony_ci int flags3 = DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN | 6392e5b6d6dSopenharmony_ci DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT; 6402e5b6d6dSopenharmony_ci DoubleToStringConverter dc3(flags3, "Infinity", "NaN", 'e', 6412e5b6d6dSopenharmony_ci 0, 0, 0, 0); // Padding zeroes. 6422e5b6d6dSopenharmony_ci builder.Reset(); 6432e5b6d6dSopenharmony_ci CHECK(dc3.ToFixed(0.0, 0, &builder)); 6442e5b6d6dSopenharmony_ci CHECK_EQ("0.", builder.Finalize()); 6452e5b6d6dSopenharmony_ci 6462e5b6d6dSopenharmony_ci builder.Reset(); 6472e5b6d6dSopenharmony_ci CHECK(dc3.ToFixed(-0.0, 0, &builder)); 6482e5b6d6dSopenharmony_ci CHECK_EQ("-0.", builder.Finalize()); 6492e5b6d6dSopenharmony_ci 6502e5b6d6dSopenharmony_ci builder.Reset(); 6512e5b6d6dSopenharmony_ci CHECK(dc3.ToFixed(1.0, 0, &builder)); 6522e5b6d6dSopenharmony_ci CHECK_EQ("1.", builder.Finalize()); 6532e5b6d6dSopenharmony_ci 6542e5b6d6dSopenharmony_ci builder.Reset(); 6552e5b6d6dSopenharmony_ci CHECK(dc3.ToFixed(-1.0, 0, &builder)); 6562e5b6d6dSopenharmony_ci CHECK_EQ("-1.", builder.Finalize()); 6572e5b6d6dSopenharmony_ci 6582e5b6d6dSopenharmony_ci // Verify no trailing zero is emitted, even if the configuration is set. 6592e5b6d6dSopenharmony_ci // The given parameter takes precedence. 6602e5b6d6dSopenharmony_ci int flags4 = DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN | 6612e5b6d6dSopenharmony_ci DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT | 6622e5b6d6dSopenharmony_ci DoubleToStringConverter::EMIT_TRAILING_ZERO_AFTER_POINT; 6632e5b6d6dSopenharmony_ci DoubleToStringConverter dc4(flags4, "Infinity", "NaN", 'e', 6642e5b6d6dSopenharmony_ci 0, 0, 0, 0); // Padding zeroes. 6652e5b6d6dSopenharmony_ci builder.Reset(); 6662e5b6d6dSopenharmony_ci CHECK(dc4.ToFixed(0.0, 0, &builder)); 6672e5b6d6dSopenharmony_ci CHECK_EQ("0.0", builder.Finalize()); 6682e5b6d6dSopenharmony_ci 6692e5b6d6dSopenharmony_ci builder.Reset(); 6702e5b6d6dSopenharmony_ci CHECK(dc4.ToFixed(-0.0, 0, &builder)); 6712e5b6d6dSopenharmony_ci CHECK_EQ("-0.0", builder.Finalize()); 6722e5b6d6dSopenharmony_ci 6732e5b6d6dSopenharmony_ci builder.Reset(); 6742e5b6d6dSopenharmony_ci CHECK(dc4.ToFixed(1.0, 0, &builder)); 6752e5b6d6dSopenharmony_ci CHECK_EQ("1.0", builder.Finalize()); 6762e5b6d6dSopenharmony_ci 6772e5b6d6dSopenharmony_ci builder.Reset(); 6782e5b6d6dSopenharmony_ci CHECK(dc4.ToFixed(-1.0, 0, &builder)); 6792e5b6d6dSopenharmony_ci CHECK_EQ("-1.0", builder.Finalize()); 6802e5b6d6dSopenharmony_ci 6812e5b6d6dSopenharmony_ci // Test the examples in the comments of ToFixed. 6822e5b6d6dSopenharmony_ci flags = DoubleToStringConverter::NO_FLAGS; 6832e5b6d6dSopenharmony_ci DoubleToStringConverter dc5(flags, NULL, NULL, 'e', 0, 0, 0, 0); 6842e5b6d6dSopenharmony_ci 6852e5b6d6dSopenharmony_ci builder.Reset(); 6862e5b6d6dSopenharmony_ci CHECK(dc5.ToFixed(3.12, 1, &builder)); 6872e5b6d6dSopenharmony_ci CHECK_EQ("3.1", builder.Finalize()); 6882e5b6d6dSopenharmony_ci 6892e5b6d6dSopenharmony_ci builder.Reset(); 6902e5b6d6dSopenharmony_ci CHECK(dc5.ToFixed(3.1415, 3, &builder)); 6912e5b6d6dSopenharmony_ci CHECK_EQ("3.142", builder.Finalize()); 6922e5b6d6dSopenharmony_ci 6932e5b6d6dSopenharmony_ci builder.Reset(); 6942e5b6d6dSopenharmony_ci CHECK(dc5.ToFixed(1234.56789, 4, &builder)); 6952e5b6d6dSopenharmony_ci CHECK_EQ("1234.5679", builder.Finalize()); 6962e5b6d6dSopenharmony_ci 6972e5b6d6dSopenharmony_ci builder.Reset(); 6982e5b6d6dSopenharmony_ci CHECK(dc5.ToFixed(1.23, 5, &builder)); 6992e5b6d6dSopenharmony_ci CHECK_EQ("1.23000", builder.Finalize()); 7002e5b6d6dSopenharmony_ci 7012e5b6d6dSopenharmony_ci builder.Reset(); 7022e5b6d6dSopenharmony_ci CHECK(dc5.ToFixed(0.1, 4, &builder)); 7032e5b6d6dSopenharmony_ci CHECK_EQ("0.1000", builder.Finalize()); 7042e5b6d6dSopenharmony_ci 7052e5b6d6dSopenharmony_ci builder.Reset(); 7062e5b6d6dSopenharmony_ci CHECK(dc5.ToFixed(1e30, 2, &builder)); 7072e5b6d6dSopenharmony_ci CHECK_EQ("1000000000000000019884624838656.00", builder.Finalize()); 7082e5b6d6dSopenharmony_ci 7092e5b6d6dSopenharmony_ci builder.Reset(); 7102e5b6d6dSopenharmony_ci CHECK(dc5.ToFixed(0.1, 30, &builder)); 7112e5b6d6dSopenharmony_ci CHECK_EQ("0.100000000000000005551115123126", builder.Finalize()); 7122e5b6d6dSopenharmony_ci 7132e5b6d6dSopenharmony_ci builder.Reset(); 7142e5b6d6dSopenharmony_ci CHECK(dc5.ToFixed(0.1, 100, &builder)); 7152e5b6d6dSopenharmony_ci CHECK_EQ("0.1000000000000000055511151231257827021181583404541015625000000000000000000000000000000000000000000000", builder.Finalize()); 7162e5b6d6dSopenharmony_ci 7172e5b6d6dSopenharmony_ci builder.Reset(); 7182e5b6d6dSopenharmony_ci CHECK(dc5.ToFixed(0.1, 17, &builder)); 7192e5b6d6dSopenharmony_ci CHECK_EQ("0.10000000000000001", builder.Finalize()); 7202e5b6d6dSopenharmony_ci 7212e5b6d6dSopenharmony_ci builder.Reset(); 7222e5b6d6dSopenharmony_ci CHECK(dc5.ToFixed(123.45, 0, &builder)); 7232e5b6d6dSopenharmony_ci CHECK_EQ("123", builder.Finalize()); 7242e5b6d6dSopenharmony_ci 7252e5b6d6dSopenharmony_ci builder.Reset(); 7262e5b6d6dSopenharmony_ci CHECK(dc5.ToFixed(0.678, 0, &builder)); 7272e5b6d6dSopenharmony_ci CHECK_EQ("1", builder.Finalize()); 7282e5b6d6dSopenharmony_ci 7292e5b6d6dSopenharmony_ci flags = DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT; 7302e5b6d6dSopenharmony_ci DoubleToStringConverter dc6(flags, NULL, NULL, 'e', 0, 0, 0, 0); 7312e5b6d6dSopenharmony_ci 7322e5b6d6dSopenharmony_ci builder.Reset(); 7332e5b6d6dSopenharmony_ci CHECK(dc6.ToFixed(123.45, 0, &builder)); 7342e5b6d6dSopenharmony_ci CHECK_EQ("123.", builder.Finalize()); 7352e5b6d6dSopenharmony_ci 7362e5b6d6dSopenharmony_ci builder.Reset(); 7372e5b6d6dSopenharmony_ci CHECK(dc6.ToFixed(0.678, 0, &builder)); 7382e5b6d6dSopenharmony_ci CHECK_EQ("1.", builder.Finalize()); 7392e5b6d6dSopenharmony_ci 7402e5b6d6dSopenharmony_ci flags = DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT | 7412e5b6d6dSopenharmony_ci DoubleToStringConverter::EMIT_TRAILING_ZERO_AFTER_POINT; 7422e5b6d6dSopenharmony_ci DoubleToStringConverter dc7(flags, NULL, NULL, 'e', 0, 0, 0, 0); 7432e5b6d6dSopenharmony_ci 7442e5b6d6dSopenharmony_ci builder.Reset(); 7452e5b6d6dSopenharmony_ci CHECK(dc7.ToFixed(123.45, 0, &builder)); 7462e5b6d6dSopenharmony_ci CHECK_EQ("123.0", builder.Finalize()); 7472e5b6d6dSopenharmony_ci 7482e5b6d6dSopenharmony_ci builder.Reset(); 7492e5b6d6dSopenharmony_ci CHECK(dc7.ToFixed(0.678, 0, &builder)); 7502e5b6d6dSopenharmony_ci CHECK_EQ("1.0", builder.Finalize()); 7512e5b6d6dSopenharmony_ci 7522e5b6d6dSopenharmony_ci // Test special value handling. 7532e5b6d6dSopenharmony_ci DoubleToStringConverter dc8(flags, NULL, NULL, 'e', 0, 0, 0, 0); 7542e5b6d6dSopenharmony_ci 7552e5b6d6dSopenharmony_ci builder.Reset(); 7562e5b6d6dSopenharmony_ci CHECK(!dc8.ToFixed(Double::Infinity(), 1, &builder)); 7572e5b6d6dSopenharmony_ci 7582e5b6d6dSopenharmony_ci builder.Reset(); 7592e5b6d6dSopenharmony_ci CHECK(!dc8.ToFixed(-Double::Infinity(), 1, &builder)); 7602e5b6d6dSopenharmony_ci 7612e5b6d6dSopenharmony_ci builder.Reset(); 7622e5b6d6dSopenharmony_ci CHECK(!dc8.ToFixed(Double::NaN(), 1, &builder)); 7632e5b6d6dSopenharmony_ci 7642e5b6d6dSopenharmony_ci builder.Reset(); 7652e5b6d6dSopenharmony_ci CHECK(!dc8.ToFixed(-Double::NaN(), 1, &builder)); 7662e5b6d6dSopenharmony_ci 7672e5b6d6dSopenharmony_ci DoubleToStringConverter dc9(flags, "Infinity", "NaN", 'e', 0, 0, 0, 0); 7682e5b6d6dSopenharmony_ci 7692e5b6d6dSopenharmony_ci builder.Reset(); 7702e5b6d6dSopenharmony_ci CHECK(dc9.ToFixed(Double::Infinity(), 1, &builder)); 7712e5b6d6dSopenharmony_ci CHECK_EQ("Infinity", builder.Finalize()); 7722e5b6d6dSopenharmony_ci 7732e5b6d6dSopenharmony_ci builder.Reset(); 7742e5b6d6dSopenharmony_ci CHECK(dc9.ToFixed(-Double::Infinity(), 1, &builder)); 7752e5b6d6dSopenharmony_ci CHECK_EQ("-Infinity", builder.Finalize()); 7762e5b6d6dSopenharmony_ci 7772e5b6d6dSopenharmony_ci builder.Reset(); 7782e5b6d6dSopenharmony_ci CHECK(dc9.ToFixed(Double::NaN(), 1, &builder)); 7792e5b6d6dSopenharmony_ci CHECK_EQ("NaN", builder.Finalize()); 7802e5b6d6dSopenharmony_ci 7812e5b6d6dSopenharmony_ci builder.Reset(); 7822e5b6d6dSopenharmony_ci CHECK(dc9.ToFixed(-Double::NaN(), 1, &builder)); 7832e5b6d6dSopenharmony_ci CHECK_EQ("NaN", builder.Finalize()); 7842e5b6d6dSopenharmony_ci} 7852e5b6d6dSopenharmony_ci 7862e5b6d6dSopenharmony_ci 7872e5b6d6dSopenharmony_ciTEST(DoubleToExponential) { 7882e5b6d6dSopenharmony_ci const int kBufferSize = 256; 7892e5b6d6dSopenharmony_ci char buffer[kBufferSize]; 7902e5b6d6dSopenharmony_ci int flags = DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN | 7912e5b6d6dSopenharmony_ci DoubleToStringConverter::UNIQUE_ZERO; 7922e5b6d6dSopenharmony_ci StringBuilder builder(buffer, kBufferSize); 7932e5b6d6dSopenharmony_ci DoubleToStringConverter dc(flags, "Infinity", "NaN", 'e', 0, 0, 0, 0); 7942e5b6d6dSopenharmony_ci 7952e5b6d6dSopenharmony_ci builder.Reset(); 7962e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.0, 5, &builder)); 7972e5b6d6dSopenharmony_ci CHECK_EQ("0.00000e+0", builder.Finalize()); 7982e5b6d6dSopenharmony_ci 7992e5b6d6dSopenharmony_ci builder.Reset(); 8002e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.0, 0, &builder)); 8012e5b6d6dSopenharmony_ci CHECK_EQ("0e+0", builder.Finalize()); 8022e5b6d6dSopenharmony_ci 8032e5b6d6dSopenharmony_ci builder.Reset(); 8042e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.0, 1, &builder)); 8052e5b6d6dSopenharmony_ci CHECK_EQ("0.0e+0", builder.Finalize()); 8062e5b6d6dSopenharmony_ci 8072e5b6d6dSopenharmony_ci builder.Reset(); 8082e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.123456, 5, &builder)); 8092e5b6d6dSopenharmony_ci CHECK_EQ("1.23456e-1", builder.Finalize()); 8102e5b6d6dSopenharmony_ci 8112e5b6d6dSopenharmony_ci builder.Reset(); 8122e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(1.2, 1, &builder)); 8132e5b6d6dSopenharmony_ci CHECK_EQ("1.2e+0", builder.Finalize()); 8142e5b6d6dSopenharmony_ci 8152e5b6d6dSopenharmony_ci builder.Reset(); 8162e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-0.0, 1, &builder)); 8172e5b6d6dSopenharmony_ci CHECK_EQ("0.0e+0", builder.Finalize()); 8182e5b6d6dSopenharmony_ci 8192e5b6d6dSopenharmony_ci builder.Reset(); 8202e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.0, 2, &builder)); 8212e5b6d6dSopenharmony_ci CHECK_EQ("0.00e+0", builder.Finalize()); 8222e5b6d6dSopenharmony_ci 8232e5b6d6dSopenharmony_ci builder.Reset(); 8242e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-0.0, 2, &builder)); 8252e5b6d6dSopenharmony_ci CHECK_EQ("0.00e+0", builder.Finalize()); 8262e5b6d6dSopenharmony_ci 8272e5b6d6dSopenharmony_ci DOUBLE_CONVERSION_ASSERT(DoubleToStringConverter::kMaxExponentialDigits == 120); 8282e5b6d6dSopenharmony_ci builder.Reset(); 8292e5b6d6dSopenharmony_ci CHECK(dc.ToExponential( 8302e5b6d6dSopenharmony_ci 0.0, DoubleToStringConverter::kMaxExponentialDigits, &builder)); 8312e5b6d6dSopenharmony_ci CHECK_EQ("0.00000000000000000000000000000000000000000000000000000000000" 8322e5b6d6dSopenharmony_ci "0000000000000000000000000000000000000000000000000000000000000e+0", 8332e5b6d6dSopenharmony_ci builder.Finalize()); 8342e5b6d6dSopenharmony_ci 8352e5b6d6dSopenharmony_ci builder.Reset(); 8362e5b6d6dSopenharmony_ci CHECK(dc.ToExponential( 8372e5b6d6dSopenharmony_ci 9e59, DoubleToStringConverter::kMaxExponentialDigits, &builder)); 8382e5b6d6dSopenharmony_ci CHECK_EQ("8.99999999999999918767229449717619953810131273674690656206848" 8392e5b6d6dSopenharmony_ci "0000000000000000000000000000000000000000000000000000000000000e+59", 8402e5b6d6dSopenharmony_ci builder.Finalize()); 8412e5b6d6dSopenharmony_ci 8422e5b6d6dSopenharmony_ci builder.Reset(); 8432e5b6d6dSopenharmony_ci CHECK(dc.ToExponential( 8442e5b6d6dSopenharmony_ci -9e59, DoubleToStringConverter::kMaxExponentialDigits, &builder)); 8452e5b6d6dSopenharmony_ci CHECK_EQ("-8.99999999999999918767229449717619953810131273674690656206848" 8462e5b6d6dSopenharmony_ci "0000000000000000000000000000000000000000000000000000000000000e+59", 8472e5b6d6dSopenharmony_ci builder.Finalize()); 8482e5b6d6dSopenharmony_ci 8492e5b6d6dSopenharmony_ci const double max_double = 1.7976931348623157e308; 8502e5b6d6dSopenharmony_ci builder.Reset(); 8512e5b6d6dSopenharmony_ci CHECK(dc.ToExponential( 8522e5b6d6dSopenharmony_ci max_double, DoubleToStringConverter::kMaxExponentialDigits, &builder)); 8532e5b6d6dSopenharmony_ci CHECK_EQ("1.79769313486231570814527423731704356798070567525844996598917" 8542e5b6d6dSopenharmony_ci "4768031572607800285387605895586327668781715404589535143824642e+308", 8552e5b6d6dSopenharmony_ci builder.Finalize()); 8562e5b6d6dSopenharmony_ci 8572e5b6d6dSopenharmony_ci builder.Reset(); 8582e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.000001, 2, &builder)); 8592e5b6d6dSopenharmony_ci CHECK_EQ("1.00e-6", builder.Finalize()); 8602e5b6d6dSopenharmony_ci 8612e5b6d6dSopenharmony_ci builder.Reset(); 8622e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.0000001, 2, &builder)); 8632e5b6d6dSopenharmony_ci CHECK_EQ("1.00e-7", builder.Finalize()); 8642e5b6d6dSopenharmony_ci 8652e5b6d6dSopenharmony_ci // Test the examples in the comments of ToExponential. 8662e5b6d6dSopenharmony_ci flags = DoubleToStringConverter::NO_FLAGS; 8672e5b6d6dSopenharmony_ci DoubleToStringConverter dc2(flags, "Infinity", "NaN", 'e', 0, 0, 0, 0); 8682e5b6d6dSopenharmony_ci 8692e5b6d6dSopenharmony_ci builder.Reset(); 8702e5b6d6dSopenharmony_ci CHECK(dc2.ToExponential(3.12, 1, &builder)); 8712e5b6d6dSopenharmony_ci CHECK_EQ("3.1e0", builder.Finalize()); 8722e5b6d6dSopenharmony_ci 8732e5b6d6dSopenharmony_ci builder.Reset(); 8742e5b6d6dSopenharmony_ci CHECK(dc2.ToExponential(5.0, 3, &builder)); 8752e5b6d6dSopenharmony_ci CHECK_EQ("5.000e0", builder.Finalize()); 8762e5b6d6dSopenharmony_ci 8772e5b6d6dSopenharmony_ci builder.Reset(); 8782e5b6d6dSopenharmony_ci CHECK(dc2.ToExponential(0.001, 2, &builder)); 8792e5b6d6dSopenharmony_ci CHECK_EQ("1.00e-3", builder.Finalize()); 8802e5b6d6dSopenharmony_ci 8812e5b6d6dSopenharmony_ci builder.Reset(); 8822e5b6d6dSopenharmony_ci CHECK(dc2.ToExponential(3.1415, -1, &builder)); 8832e5b6d6dSopenharmony_ci CHECK_EQ("3.1415e0", builder.Finalize()); 8842e5b6d6dSopenharmony_ci 8852e5b6d6dSopenharmony_ci builder.Reset(); 8862e5b6d6dSopenharmony_ci CHECK(dc2.ToExponential(3.1415, 4, &builder)); 8872e5b6d6dSopenharmony_ci CHECK_EQ("3.1415e0", builder.Finalize()); 8882e5b6d6dSopenharmony_ci 8892e5b6d6dSopenharmony_ci builder.Reset(); 8902e5b6d6dSopenharmony_ci CHECK(dc2.ToExponential(3.1415, 3, &builder)); 8912e5b6d6dSopenharmony_ci CHECK_EQ("3.142e0", builder.Finalize()); 8922e5b6d6dSopenharmony_ci 8932e5b6d6dSopenharmony_ci builder.Reset(); 8942e5b6d6dSopenharmony_ci CHECK(dc2.ToExponential(123456789000000, 3, &builder)); 8952e5b6d6dSopenharmony_ci CHECK_EQ("1.235e14", builder.Finalize()); 8962e5b6d6dSopenharmony_ci 8972e5b6d6dSopenharmony_ci builder.Reset(); 8982e5b6d6dSopenharmony_ci CHECK(dc2.ToExponential(1000000000000000019884624838656.0, -1, &builder)); 8992e5b6d6dSopenharmony_ci CHECK_EQ("1e30", builder.Finalize()); 9002e5b6d6dSopenharmony_ci 9012e5b6d6dSopenharmony_ci builder.Reset(); 9022e5b6d6dSopenharmony_ci CHECK(dc2.ToExponential(1000000000000000019884624838656.0, 32, &builder)); 9032e5b6d6dSopenharmony_ci CHECK_EQ("1.00000000000000001988462483865600e30", builder.Finalize()); 9042e5b6d6dSopenharmony_ci 9052e5b6d6dSopenharmony_ci builder.Reset(); 9062e5b6d6dSopenharmony_ci CHECK(dc2.ToExponential(1234, 0, &builder)); 9072e5b6d6dSopenharmony_ci CHECK_EQ("1e3", builder.Finalize()); 9082e5b6d6dSopenharmony_ci 9092e5b6d6dSopenharmony_ci // Test special value handling. 9102e5b6d6dSopenharmony_ci DoubleToStringConverter dc3(flags, NULL, NULL, 'e', 0, 0, 0, 0); 9112e5b6d6dSopenharmony_ci 9122e5b6d6dSopenharmony_ci builder.Reset(); 9132e5b6d6dSopenharmony_ci CHECK(!dc3.ToExponential(Double::Infinity(), 1, &builder)); 9142e5b6d6dSopenharmony_ci 9152e5b6d6dSopenharmony_ci builder.Reset(); 9162e5b6d6dSopenharmony_ci CHECK(!dc3.ToExponential(-Double::Infinity(), 1, &builder)); 9172e5b6d6dSopenharmony_ci 9182e5b6d6dSopenharmony_ci builder.Reset(); 9192e5b6d6dSopenharmony_ci CHECK(!dc3.ToExponential(Double::NaN(), 1, &builder)); 9202e5b6d6dSopenharmony_ci 9212e5b6d6dSopenharmony_ci builder.Reset(); 9222e5b6d6dSopenharmony_ci CHECK(!dc3.ToExponential(-Double::NaN(), 1, &builder)); 9232e5b6d6dSopenharmony_ci 9242e5b6d6dSopenharmony_ci DoubleToStringConverter dc4(flags, "Infinity", "NaN", 'e', 0, 0, 0, 0); 9252e5b6d6dSopenharmony_ci 9262e5b6d6dSopenharmony_ci builder.Reset(); 9272e5b6d6dSopenharmony_ci CHECK(dc4.ToExponential(Double::Infinity(), 1, &builder)); 9282e5b6d6dSopenharmony_ci CHECK_EQ("Infinity", builder.Finalize()); 9292e5b6d6dSopenharmony_ci 9302e5b6d6dSopenharmony_ci builder.Reset(); 9312e5b6d6dSopenharmony_ci CHECK(dc4.ToExponential(-Double::Infinity(), 1, &builder)); 9322e5b6d6dSopenharmony_ci CHECK_EQ("-Infinity", builder.Finalize()); 9332e5b6d6dSopenharmony_ci 9342e5b6d6dSopenharmony_ci builder.Reset(); 9352e5b6d6dSopenharmony_ci CHECK(dc4.ToExponential(Double::NaN(), 1, &builder)); 9362e5b6d6dSopenharmony_ci CHECK_EQ("NaN", builder.Finalize()); 9372e5b6d6dSopenharmony_ci 9382e5b6d6dSopenharmony_ci builder.Reset(); 9392e5b6d6dSopenharmony_ci CHECK(dc4.ToExponential(-Double::NaN(), 1, &builder)); 9402e5b6d6dSopenharmony_ci CHECK_EQ("NaN", builder.Finalize()); 9412e5b6d6dSopenharmony_ci 9422e5b6d6dSopenharmony_ci // Test min_exponent_width 9432e5b6d6dSopenharmony_ci DoubleToStringConverter dc5(flags, NULL, NULL, 'e', 0, 0, 0, 0, 2); 9442e5b6d6dSopenharmony_ci 9452e5b6d6dSopenharmony_ci builder.Reset(); 9462e5b6d6dSopenharmony_ci CHECK(dc5.ToExponential(11111111111.0, 6, &builder)); 9472e5b6d6dSopenharmony_ci CHECK_EQ("1.111111e10", builder.Finalize()); 9482e5b6d6dSopenharmony_ci 9492e5b6d6dSopenharmony_ci builder.Reset(); 9502e5b6d6dSopenharmony_ci CHECK(dc5.ToExponential(1111111111.0, 6, &builder)); 9512e5b6d6dSopenharmony_ci CHECK_EQ("1.111111e09", builder.Finalize()); 9522e5b6d6dSopenharmony_ci 9532e5b6d6dSopenharmony_ci builder.Reset(); 9542e5b6d6dSopenharmony_ci CHECK(dc5.ToExponential(1111111.0, 6, &builder)); 9552e5b6d6dSopenharmony_ci CHECK_EQ("1.111111e06", builder.Finalize()); 9562e5b6d6dSopenharmony_ci 9572e5b6d6dSopenharmony_ci builder.Reset(); 9582e5b6d6dSopenharmony_ci CHECK(dc5.ToExponential(10000000000.0, 6, &builder)); 9592e5b6d6dSopenharmony_ci CHECK_EQ("1.000000e10", builder.Finalize()); 9602e5b6d6dSopenharmony_ci 9612e5b6d6dSopenharmony_ci builder.Reset(); 9622e5b6d6dSopenharmony_ci CHECK(dc5.ToExponential(1000000000.0, 6, &builder)); 9632e5b6d6dSopenharmony_ci CHECK_EQ("1.000000e09", builder.Finalize()); 9642e5b6d6dSopenharmony_ci 9652e5b6d6dSopenharmony_ci builder.Reset(); 9662e5b6d6dSopenharmony_ci CHECK(dc5.ToExponential(1.0, 6, &builder)); 9672e5b6d6dSopenharmony_ci CHECK_EQ("1.000000e00", builder.Finalize()); 9682e5b6d6dSopenharmony_ci} 9692e5b6d6dSopenharmony_ci 9702e5b6d6dSopenharmony_ci 9712e5b6d6dSopenharmony_ciTEST(DoubleToPrecision) { 9722e5b6d6dSopenharmony_ci const int kBufferSize = 256; 9732e5b6d6dSopenharmony_ci char buffer[kBufferSize]; 9742e5b6d6dSopenharmony_ci int flags = DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN | 9752e5b6d6dSopenharmony_ci DoubleToStringConverter::UNIQUE_ZERO; 9762e5b6d6dSopenharmony_ci StringBuilder builder(buffer, kBufferSize); 9772e5b6d6dSopenharmony_ci DoubleToStringConverter dc(flags, "Infinity", "NaN", 'e', 9782e5b6d6dSopenharmony_ci 0, 0, // Padding zeroes for shortest mode. 9792e5b6d6dSopenharmony_ci 6, 0); // Padding zeroes for precision mode. 9802e5b6d6dSopenharmony_ci 9812e5b6d6dSopenharmony_ci DOUBLE_CONVERSION_ASSERT(DoubleToStringConverter::kMinPrecisionDigits == 1); 9822e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(0.0, 1, &builder)); 9832e5b6d6dSopenharmony_ci CHECK_EQ("0", builder.Finalize()); 9842e5b6d6dSopenharmony_ci 9852e5b6d6dSopenharmony_ci builder.Reset(); 9862e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(-0.0, 1, &builder)); 9872e5b6d6dSopenharmony_ci CHECK_EQ("0", builder.Finalize()); 9882e5b6d6dSopenharmony_ci 9892e5b6d6dSopenharmony_ci builder.Reset(); 9902e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(0.0, 2, &builder)); 9912e5b6d6dSopenharmony_ci CHECK_EQ("0.0", builder.Finalize()); 9922e5b6d6dSopenharmony_ci 9932e5b6d6dSopenharmony_ci builder.Reset(); 9942e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(-0.0, 2, &builder)); 9952e5b6d6dSopenharmony_ci CHECK_EQ("0.0", builder.Finalize()); 9962e5b6d6dSopenharmony_ci 9972e5b6d6dSopenharmony_ci DOUBLE_CONVERSION_ASSERT(DoubleToStringConverter::kMaxPrecisionDigits == 120); 9982e5b6d6dSopenharmony_ci builder.Reset(); 9992e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision( 10002e5b6d6dSopenharmony_ci 0.0, DoubleToStringConverter::kMaxPrecisionDigits, &builder)); 10012e5b6d6dSopenharmony_ci CHECK_EQ("0.00000000000000000000000000000000000000000000000000000000000" 10022e5b6d6dSopenharmony_ci "000000000000000000000000000000000000000000000000000000000000", 10032e5b6d6dSopenharmony_ci builder.Finalize()); 10042e5b6d6dSopenharmony_ci 10052e5b6d6dSopenharmony_ci builder.Reset(); 10062e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision( 10072e5b6d6dSopenharmony_ci 9e59, DoubleToStringConverter::kMaxPrecisionDigits, &builder)); 10082e5b6d6dSopenharmony_ci CHECK_EQ("899999999999999918767229449717619953810131273674690656206848." 10092e5b6d6dSopenharmony_ci "000000000000000000000000000000000000000000000000000000000000", 10102e5b6d6dSopenharmony_ci builder.Finalize()); 10112e5b6d6dSopenharmony_ci 10122e5b6d6dSopenharmony_ci builder.Reset(); 10132e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision( 10142e5b6d6dSopenharmony_ci -9e59, DoubleToStringConverter::kMaxPrecisionDigits, &builder)); 10152e5b6d6dSopenharmony_ci CHECK_EQ("-899999999999999918767229449717619953810131273674690656206848." 10162e5b6d6dSopenharmony_ci "000000000000000000000000000000000000000000000000000000000000", 10172e5b6d6dSopenharmony_ci builder.Finalize()); 10182e5b6d6dSopenharmony_ci 10192e5b6d6dSopenharmony_ci const double max_double = 1.7976931348623157e308; 10202e5b6d6dSopenharmony_ci builder.Reset(); 10212e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision( 10222e5b6d6dSopenharmony_ci max_double, DoubleToStringConverter::kMaxPrecisionDigits, &builder)); 10232e5b6d6dSopenharmony_ci CHECK_EQ("1.79769313486231570814527423731704356798070567525844996598917" 10242e5b6d6dSopenharmony_ci "476803157260780028538760589558632766878171540458953514382464e+308", 10252e5b6d6dSopenharmony_ci builder.Finalize()); 10262e5b6d6dSopenharmony_ci 10272e5b6d6dSopenharmony_ci builder.Reset(); 10282e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(0.000001, 2, &builder)); 10292e5b6d6dSopenharmony_ci CHECK_EQ("0.0000010", builder.Finalize()); 10302e5b6d6dSopenharmony_ci 10312e5b6d6dSopenharmony_ci builder.Reset(); 10322e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(0.0000001, 2, &builder)); 10332e5b6d6dSopenharmony_ci CHECK_EQ("1.0e-7", builder.Finalize()); 10342e5b6d6dSopenharmony_ci 10352e5b6d6dSopenharmony_ci flags = DoubleToStringConverter::NO_FLAGS; 10362e5b6d6dSopenharmony_ci DoubleToStringConverter dc2(flags, NULL, NULL, 'e', 0, 0, 0, 1); 10372e5b6d6dSopenharmony_ci builder.Reset(); 10382e5b6d6dSopenharmony_ci CHECK(dc2.ToPrecision(230.0, 2, &builder)); 10392e5b6d6dSopenharmony_ci CHECK_EQ("230", builder.Finalize()); 10402e5b6d6dSopenharmony_ci 10412e5b6d6dSopenharmony_ci builder.Reset(); 10422e5b6d6dSopenharmony_ci CHECK(dc2.ToPrecision(23.0, 2, &builder)); 10432e5b6d6dSopenharmony_ci CHECK_EQ("23", builder.Finalize()); 10442e5b6d6dSopenharmony_ci 10452e5b6d6dSopenharmony_ci builder.Reset(); 10462e5b6d6dSopenharmony_ci CHECK(dc2.ToPrecision(2.30, 2, &builder)); 10472e5b6d6dSopenharmony_ci CHECK_EQ("2.3", builder.Finalize()); 10482e5b6d6dSopenharmony_ci 10492e5b6d6dSopenharmony_ci builder.Reset(); 10502e5b6d6dSopenharmony_ci CHECK(dc2.ToPrecision(2300.0, 2, &builder)); 10512e5b6d6dSopenharmony_ci CHECK_EQ("2.3e3", builder.Finalize()); 10522e5b6d6dSopenharmony_ci 10532e5b6d6dSopenharmony_ci flags = DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT; 10542e5b6d6dSopenharmony_ci DoubleToStringConverter dc3(flags, NULL, NULL, 'e', 0, 0, 0, 1); 10552e5b6d6dSopenharmony_ci builder.Reset(); 10562e5b6d6dSopenharmony_ci CHECK(dc3.ToPrecision(230.0, 2, &builder)); 10572e5b6d6dSopenharmony_ci CHECK_EQ("230.", builder.Finalize()); 10582e5b6d6dSopenharmony_ci 10592e5b6d6dSopenharmony_ci builder.Reset(); 10602e5b6d6dSopenharmony_ci CHECK(dc3.ToPrecision(23.0, 2, &builder)); 10612e5b6d6dSopenharmony_ci CHECK_EQ("23.", builder.Finalize()); 10622e5b6d6dSopenharmony_ci 10632e5b6d6dSopenharmony_ci builder.Reset(); 10642e5b6d6dSopenharmony_ci CHECK(dc3.ToPrecision(2.30, 2, &builder)); 10652e5b6d6dSopenharmony_ci CHECK_EQ("2.3", builder.Finalize()); 10662e5b6d6dSopenharmony_ci 10672e5b6d6dSopenharmony_ci builder.Reset(); 10682e5b6d6dSopenharmony_ci CHECK(dc3.ToPrecision(2300.0, 2, &builder)); 10692e5b6d6dSopenharmony_ci CHECK_EQ("2.3e3", builder.Finalize()); 10702e5b6d6dSopenharmony_ci 10712e5b6d6dSopenharmony_ci flags = DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT | 10722e5b6d6dSopenharmony_ci DoubleToStringConverter::EMIT_TRAILING_ZERO_AFTER_POINT; 10732e5b6d6dSopenharmony_ci DoubleToStringConverter dc4(flags, NULL, NULL, 'e', 0, 0, 0, 1); 10742e5b6d6dSopenharmony_ci builder.Reset(); 10752e5b6d6dSopenharmony_ci CHECK(dc4.ToPrecision(230.0, 2, &builder)); 10762e5b6d6dSopenharmony_ci CHECK_EQ("2.3e2", builder.Finalize()); 10772e5b6d6dSopenharmony_ci 10782e5b6d6dSopenharmony_ci builder.Reset(); 10792e5b6d6dSopenharmony_ci CHECK(dc4.ToPrecision(23.0, 2, &builder)); 10802e5b6d6dSopenharmony_ci CHECK_EQ("23.0", builder.Finalize()); 10812e5b6d6dSopenharmony_ci 10822e5b6d6dSopenharmony_ci builder.Reset(); 10832e5b6d6dSopenharmony_ci CHECK(dc4.ToPrecision(2.30, 2, &builder)); 10842e5b6d6dSopenharmony_ci CHECK_EQ("2.3", builder.Finalize()); 10852e5b6d6dSopenharmony_ci 10862e5b6d6dSopenharmony_ci builder.Reset(); 10872e5b6d6dSopenharmony_ci CHECK(dc4.ToPrecision(2300.0, 2, &builder)); 10882e5b6d6dSopenharmony_ci CHECK_EQ("2.3e3", builder.Finalize()); 10892e5b6d6dSopenharmony_ci 10902e5b6d6dSopenharmony_ci // Test the examples in the comments of ToPrecision. 10912e5b6d6dSopenharmony_ci flags = DoubleToStringConverter::NO_FLAGS; 10922e5b6d6dSopenharmony_ci DoubleToStringConverter dc5(flags, "Infinity", "NaN", 'e', 0, 0, 6, 1); 10932e5b6d6dSopenharmony_ci flags = DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT; 10942e5b6d6dSopenharmony_ci DoubleToStringConverter dc6(flags, "Infinity", "NaN", 'e', 0, 0, 6, 1); 10952e5b6d6dSopenharmony_ci flags = DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT | 10962e5b6d6dSopenharmony_ci DoubleToStringConverter::EMIT_TRAILING_ZERO_AFTER_POINT; 10972e5b6d6dSopenharmony_ci DoubleToStringConverter dc7(flags, "Infinity", "NaN", 'e', 0, 0, 6, 1); 10982e5b6d6dSopenharmony_ci 10992e5b6d6dSopenharmony_ci builder.Reset(); 11002e5b6d6dSopenharmony_ci CHECK(dc5.ToPrecision(0.0000012345, 2, &builder)); 11012e5b6d6dSopenharmony_ci CHECK_EQ("0.0000012", builder.Finalize()); 11022e5b6d6dSopenharmony_ci 11032e5b6d6dSopenharmony_ci builder.Reset(); 11042e5b6d6dSopenharmony_ci CHECK(dc5.ToPrecision(0.00000012345, 2, &builder)); 11052e5b6d6dSopenharmony_ci CHECK_EQ("1.2e-7", builder.Finalize()); 11062e5b6d6dSopenharmony_ci 11072e5b6d6dSopenharmony_ci builder.Reset(); 11082e5b6d6dSopenharmony_ci CHECK(dc5.ToPrecision(230.0, 2, &builder)); 11092e5b6d6dSopenharmony_ci CHECK_EQ("230", builder.Finalize()); 11102e5b6d6dSopenharmony_ci 11112e5b6d6dSopenharmony_ci builder.Reset(); 11122e5b6d6dSopenharmony_ci CHECK(dc6.ToPrecision(230.0, 2, &builder)); 11132e5b6d6dSopenharmony_ci CHECK_EQ("230.", builder.Finalize()); 11142e5b6d6dSopenharmony_ci 11152e5b6d6dSopenharmony_ci builder.Reset(); 11162e5b6d6dSopenharmony_ci CHECK(dc7.ToPrecision(230.0, 2, &builder)); 11172e5b6d6dSopenharmony_ci CHECK_EQ("2.3e2", builder.Finalize()); 11182e5b6d6dSopenharmony_ci 11192e5b6d6dSopenharmony_ci flags = DoubleToStringConverter::NO_FLAGS; 11202e5b6d6dSopenharmony_ci DoubleToStringConverter dc8(flags, NULL, NULL, 'e', 0, 0, 6, 3); 11212e5b6d6dSopenharmony_ci 11222e5b6d6dSopenharmony_ci builder.Reset(); 11232e5b6d6dSopenharmony_ci CHECK(dc8.ToPrecision(123450.0, 6, &builder)); 11242e5b6d6dSopenharmony_ci CHECK_EQ("123450", builder.Finalize()); 11252e5b6d6dSopenharmony_ci 11262e5b6d6dSopenharmony_ci builder.Reset(); 11272e5b6d6dSopenharmony_ci CHECK(dc8.ToPrecision(123450.0, 5, &builder)); 11282e5b6d6dSopenharmony_ci CHECK_EQ("123450", builder.Finalize()); 11292e5b6d6dSopenharmony_ci 11302e5b6d6dSopenharmony_ci builder.Reset(); 11312e5b6d6dSopenharmony_ci CHECK(dc8.ToPrecision(123450.0, 4, &builder)); 11322e5b6d6dSopenharmony_ci CHECK_EQ("123500", builder.Finalize()); 11332e5b6d6dSopenharmony_ci 11342e5b6d6dSopenharmony_ci builder.Reset(); 11352e5b6d6dSopenharmony_ci CHECK(dc8.ToPrecision(123450.0, 3, &builder)); 11362e5b6d6dSopenharmony_ci CHECK_EQ("123000", builder.Finalize()); 11372e5b6d6dSopenharmony_ci 11382e5b6d6dSopenharmony_ci builder.Reset(); 11392e5b6d6dSopenharmony_ci CHECK(dc8.ToPrecision(123450.0, 2, &builder)); 11402e5b6d6dSopenharmony_ci CHECK_EQ("1.2e5", builder.Finalize()); 11412e5b6d6dSopenharmony_ci 11422e5b6d6dSopenharmony_ci // Test special value handling. 11432e5b6d6dSopenharmony_ci builder.Reset(); 11442e5b6d6dSopenharmony_ci CHECK(!dc8.ToPrecision(Double::Infinity(), 1, &builder)); 11452e5b6d6dSopenharmony_ci 11462e5b6d6dSopenharmony_ci builder.Reset(); 11472e5b6d6dSopenharmony_ci CHECK(!dc8.ToPrecision(-Double::Infinity(), 1, &builder)); 11482e5b6d6dSopenharmony_ci 11492e5b6d6dSopenharmony_ci builder.Reset(); 11502e5b6d6dSopenharmony_ci CHECK(!dc8.ToPrecision(Double::NaN(), 1, &builder)); 11512e5b6d6dSopenharmony_ci 11522e5b6d6dSopenharmony_ci builder.Reset(); 11532e5b6d6dSopenharmony_ci CHECK(!dc8.ToPrecision(-Double::NaN(), 1, &builder)); 11542e5b6d6dSopenharmony_ci 11552e5b6d6dSopenharmony_ci builder.Reset(); 11562e5b6d6dSopenharmony_ci CHECK(dc7.ToPrecision(Double::Infinity(), 1, &builder)); 11572e5b6d6dSopenharmony_ci CHECK_EQ("Infinity", builder.Finalize()); 11582e5b6d6dSopenharmony_ci 11592e5b6d6dSopenharmony_ci builder.Reset(); 11602e5b6d6dSopenharmony_ci CHECK(dc7.ToPrecision(-Double::Infinity(), 1, &builder)); 11612e5b6d6dSopenharmony_ci CHECK_EQ("-Infinity", builder.Finalize()); 11622e5b6d6dSopenharmony_ci 11632e5b6d6dSopenharmony_ci builder.Reset(); 11642e5b6d6dSopenharmony_ci CHECK(dc7.ToPrecision(Double::NaN(), 1, &builder)); 11652e5b6d6dSopenharmony_ci CHECK_EQ("NaN", builder.Finalize()); 11662e5b6d6dSopenharmony_ci 11672e5b6d6dSopenharmony_ci builder.Reset(); 11682e5b6d6dSopenharmony_ci CHECK(dc7.ToPrecision(-Double::NaN(), 1, &builder)); 11692e5b6d6dSopenharmony_ci CHECK_EQ("NaN", builder.Finalize()); 11702e5b6d6dSopenharmony_ci 11712e5b6d6dSopenharmony_ci // Test NO_TRAILING_ZERO and its interaction with other flags. 11722e5b6d6dSopenharmony_ci flags = DoubleToStringConverter::NO_TRAILING_ZERO; 11732e5b6d6dSopenharmony_ci DoubleToStringConverter dc9(flags, "Infinity", "NaN", 'e', 0, 0, 6, 1); 11742e5b6d6dSopenharmony_ci flags = DoubleToStringConverter::NO_TRAILING_ZERO | 11752e5b6d6dSopenharmony_ci DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT; 11762e5b6d6dSopenharmony_ci DoubleToStringConverter dc10(flags, "Infinity", "NaN", 'e', 0, 0, 6, 1); 11772e5b6d6dSopenharmony_ci flags = DoubleToStringConverter::NO_TRAILING_ZERO | 11782e5b6d6dSopenharmony_ci DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT | 11792e5b6d6dSopenharmony_ci DoubleToStringConverter::EMIT_TRAILING_ZERO_AFTER_POINT; 11802e5b6d6dSopenharmony_ci DoubleToStringConverter dc11(flags, "Infinity", "NaN", 'e', 0, 0, 6, 1); 11812e5b6d6dSopenharmony_ci 11822e5b6d6dSopenharmony_ci builder.Reset(); 11832e5b6d6dSopenharmony_ci CHECK(dc9.ToPrecision(230.001, 5, &builder)); 11842e5b6d6dSopenharmony_ci CHECK_EQ("230", builder.Finalize()); 11852e5b6d6dSopenharmony_ci 11862e5b6d6dSopenharmony_ci builder.Reset(); 11872e5b6d6dSopenharmony_ci CHECK(dc10.ToPrecision(230.001, 5, &builder)); 11882e5b6d6dSopenharmony_ci CHECK_EQ("230.", builder.Finalize()); 11892e5b6d6dSopenharmony_ci 11902e5b6d6dSopenharmony_ci builder.Reset(); 11912e5b6d6dSopenharmony_ci CHECK(dc11.ToPrecision(230.001, 5, &builder)); 11922e5b6d6dSopenharmony_ci CHECK_EQ("230.0", builder.Finalize()); 11932e5b6d6dSopenharmony_ci 11942e5b6d6dSopenharmony_ci builder.Reset(); 11952e5b6d6dSopenharmony_ci CHECK(dc5.ToPrecision(230.001, 5, &builder)); 11962e5b6d6dSopenharmony_ci CHECK_EQ("230.00", builder.Finalize()); 11972e5b6d6dSopenharmony_ci 11982e5b6d6dSopenharmony_ci builder.Reset(); 11992e5b6d6dSopenharmony_ci CHECK(dc9.ToPrecision(2300010, 5, &builder)); 12002e5b6d6dSopenharmony_ci CHECK_EQ("2.3e6", builder.Finalize()); 12012e5b6d6dSopenharmony_ci 12022e5b6d6dSopenharmony_ci builder.Reset(); 12032e5b6d6dSopenharmony_ci CHECK(dc10.ToPrecision(2300010, 5, &builder)); 12042e5b6d6dSopenharmony_ci CHECK_EQ("2.3e6", builder.Finalize()); 12052e5b6d6dSopenharmony_ci 12062e5b6d6dSopenharmony_ci builder.Reset(); 12072e5b6d6dSopenharmony_ci CHECK(dc11.ToPrecision(2300010, 5, &builder)); 12082e5b6d6dSopenharmony_ci CHECK_EQ("2.3e6", builder.Finalize()); 12092e5b6d6dSopenharmony_ci 12102e5b6d6dSopenharmony_ci builder.Reset(); 12112e5b6d6dSopenharmony_ci CHECK(dc5.ToPrecision(2300010, 5, &builder)); 12122e5b6d6dSopenharmony_ci CHECK_EQ("2.3000e6", builder.Finalize()); 12132e5b6d6dSopenharmony_ci 12142e5b6d6dSopenharmony_ci builder.Reset(); 12152e5b6d6dSopenharmony_ci CHECK(dc9.ToPrecision(0.02300010, 5, &builder)); 12162e5b6d6dSopenharmony_ci CHECK_EQ("0.023", builder.Finalize()); 12172e5b6d6dSopenharmony_ci 12182e5b6d6dSopenharmony_ci builder.Reset(); 12192e5b6d6dSopenharmony_ci CHECK(dc10.ToPrecision(0.02300010, 5, &builder)); 12202e5b6d6dSopenharmony_ci CHECK_EQ("0.023", builder.Finalize()); 12212e5b6d6dSopenharmony_ci 12222e5b6d6dSopenharmony_ci builder.Reset(); 12232e5b6d6dSopenharmony_ci CHECK(dc11.ToPrecision(0.02300010, 5, &builder)); 12242e5b6d6dSopenharmony_ci CHECK_EQ("0.023", builder.Finalize()); 12252e5b6d6dSopenharmony_ci 12262e5b6d6dSopenharmony_ci builder.Reset(); 12272e5b6d6dSopenharmony_ci CHECK(dc5.ToPrecision(0.02300010, 5, &builder)); 12282e5b6d6dSopenharmony_ci CHECK_EQ("0.023000", builder.Finalize()); 12292e5b6d6dSopenharmony_ci 12302e5b6d6dSopenharmony_ci builder.Reset(); 12312e5b6d6dSopenharmony_ci CHECK(dc9.ToPrecision(2000010, 5, &builder)); 12322e5b6d6dSopenharmony_ci CHECK_EQ("2e6", builder.Finalize()); 12332e5b6d6dSopenharmony_ci 12342e5b6d6dSopenharmony_ci builder.Reset(); 12352e5b6d6dSopenharmony_ci CHECK(dc10.ToPrecision(2000010, 5, &builder)); 12362e5b6d6dSopenharmony_ci CHECK_EQ("2e6", builder.Finalize()); 12372e5b6d6dSopenharmony_ci 12382e5b6d6dSopenharmony_ci builder.Reset(); 12392e5b6d6dSopenharmony_ci CHECK(dc11.ToPrecision(2000010, 5, &builder)); 12402e5b6d6dSopenharmony_ci CHECK_EQ("2e6", builder.Finalize()); 12412e5b6d6dSopenharmony_ci 12422e5b6d6dSopenharmony_ci builder.Reset(); 12432e5b6d6dSopenharmony_ci CHECK(dc5.ToPrecision(2000010, 5, &builder)); 12442e5b6d6dSopenharmony_ci CHECK_EQ("2.0000e6", builder.Finalize()); 12452e5b6d6dSopenharmony_ci 12462e5b6d6dSopenharmony_ci // Test that rounding up still works with NO_TRAILING_ZERO 12472e5b6d6dSopenharmony_ci builder.Reset(); 12482e5b6d6dSopenharmony_ci CHECK(dc9.ToPrecision(2000080, 5, &builder)); 12492e5b6d6dSopenharmony_ci CHECK_EQ("2.0001e6", builder.Finalize()); 12502e5b6d6dSopenharmony_ci 12512e5b6d6dSopenharmony_ci builder.Reset(); 12522e5b6d6dSopenharmony_ci CHECK(dc10.ToPrecision(2000080, 5, &builder)); 12532e5b6d6dSopenharmony_ci CHECK_EQ("2.0001e6", builder.Finalize()); 12542e5b6d6dSopenharmony_ci 12552e5b6d6dSopenharmony_ci builder.Reset(); 12562e5b6d6dSopenharmony_ci CHECK(dc11.ToPrecision(2000080, 5, &builder)); 12572e5b6d6dSopenharmony_ci CHECK_EQ("2.0001e6", builder.Finalize()); 12582e5b6d6dSopenharmony_ci 12592e5b6d6dSopenharmony_ci builder.Reset(); 12602e5b6d6dSopenharmony_ci CHECK(dc5.ToPrecision(2000080, 5, &builder)); 12612e5b6d6dSopenharmony_ci CHECK_EQ("2.0001e6", builder.Finalize()); 12622e5b6d6dSopenharmony_ci} 12632e5b6d6dSopenharmony_ci 12642e5b6d6dSopenharmony_ci 12652e5b6d6dSopenharmony_ciTEST(DoubleToStringJavaScript) { 12662e5b6d6dSopenharmony_ci const int kBufferSize = 128; 12672e5b6d6dSopenharmony_ci char buffer[kBufferSize]; 12682e5b6d6dSopenharmony_ci StringBuilder builder(buffer, kBufferSize); 12692e5b6d6dSopenharmony_ci const DoubleToStringConverter& dc = 12702e5b6d6dSopenharmony_ci DoubleToStringConverter::EcmaScriptConverter(); 12712e5b6d6dSopenharmony_ci 12722e5b6d6dSopenharmony_ci builder.Reset(); 12732e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(Double::NaN(), &builder)); 12742e5b6d6dSopenharmony_ci CHECK_EQ("NaN", builder.Finalize()); 12752e5b6d6dSopenharmony_ci 12762e5b6d6dSopenharmony_ci builder.Reset(); 12772e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(Double::Infinity(), &builder)); 12782e5b6d6dSopenharmony_ci CHECK_EQ("Infinity", builder.Finalize()); 12792e5b6d6dSopenharmony_ci 12802e5b6d6dSopenharmony_ci builder.Reset(); 12812e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(-Double::Infinity(), &builder)); 12822e5b6d6dSopenharmony_ci CHECK_EQ("-Infinity", builder.Finalize()); 12832e5b6d6dSopenharmony_ci 12842e5b6d6dSopenharmony_ci builder.Reset(); 12852e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(0.0, &builder)); 12862e5b6d6dSopenharmony_ci CHECK_EQ("0", builder.Finalize()); 12872e5b6d6dSopenharmony_ci 12882e5b6d6dSopenharmony_ci builder.Reset(); 12892e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(9.0, &builder)); 12902e5b6d6dSopenharmony_ci CHECK_EQ("9", builder.Finalize()); 12912e5b6d6dSopenharmony_ci 12922e5b6d6dSopenharmony_ci builder.Reset(); 12932e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(90.0, &builder)); 12942e5b6d6dSopenharmony_ci CHECK_EQ("90", builder.Finalize()); 12952e5b6d6dSopenharmony_ci 12962e5b6d6dSopenharmony_ci builder.Reset(); 12972e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(90.12, &builder)); 12982e5b6d6dSopenharmony_ci CHECK_EQ("90.12", builder.Finalize()); 12992e5b6d6dSopenharmony_ci 13002e5b6d6dSopenharmony_ci builder.Reset(); 13012e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(0.1, &builder)); 13022e5b6d6dSopenharmony_ci CHECK_EQ("0.1", builder.Finalize()); 13032e5b6d6dSopenharmony_ci 13042e5b6d6dSopenharmony_ci builder.Reset(); 13052e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(0.01, &builder)); 13062e5b6d6dSopenharmony_ci CHECK_EQ("0.01", builder.Finalize()); 13072e5b6d6dSopenharmony_ci 13082e5b6d6dSopenharmony_ci builder.Reset(); 13092e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(0.0123, &builder)); 13102e5b6d6dSopenharmony_ci CHECK_EQ("0.0123", builder.Finalize()); 13112e5b6d6dSopenharmony_ci 13122e5b6d6dSopenharmony_ci builder.Reset(); 13132e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(111111111111111111111.0, &builder)); 13142e5b6d6dSopenharmony_ci CHECK_EQ("111111111111111110000", builder.Finalize()); 13152e5b6d6dSopenharmony_ci 13162e5b6d6dSopenharmony_ci builder.Reset(); 13172e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(100000000000000000000.0, &builder)); 13182e5b6d6dSopenharmony_ci CHECK_EQ("100000000000000000000", builder.Finalize()); 13192e5b6d6dSopenharmony_ci 13202e5b6d6dSopenharmony_ci builder.Reset(); 13212e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(1111111111111111111111.0, &builder)); 13222e5b6d6dSopenharmony_ci CHECK_EQ("1.1111111111111111e+21", builder.Finalize()); 13232e5b6d6dSopenharmony_ci 13242e5b6d6dSopenharmony_ci builder.Reset(); 13252e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(11111111111111111111111.0, &builder)); 13262e5b6d6dSopenharmony_ci CHECK_EQ("1.1111111111111111e+22", builder.Finalize()); 13272e5b6d6dSopenharmony_ci 13282e5b6d6dSopenharmony_ci builder.Reset(); 13292e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(0.00001, &builder)); 13302e5b6d6dSopenharmony_ci CHECK_EQ("0.00001", builder.Finalize()); 13312e5b6d6dSopenharmony_ci 13322e5b6d6dSopenharmony_ci builder.Reset(); 13332e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(0.000001, &builder)); 13342e5b6d6dSopenharmony_ci CHECK_EQ("0.000001", builder.Finalize()); 13352e5b6d6dSopenharmony_ci 13362e5b6d6dSopenharmony_ci builder.Reset(); 13372e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(0.0000001, &builder)); 13382e5b6d6dSopenharmony_ci CHECK_EQ("1e-7", builder.Finalize()); 13392e5b6d6dSopenharmony_ci 13402e5b6d6dSopenharmony_ci builder.Reset(); 13412e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(0.00000012, &builder)); 13422e5b6d6dSopenharmony_ci CHECK_EQ("1.2e-7", builder.Finalize()); 13432e5b6d6dSopenharmony_ci 13442e5b6d6dSopenharmony_ci builder.Reset(); 13452e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(0.000000123, &builder)); 13462e5b6d6dSopenharmony_ci CHECK_EQ("1.23e-7", builder.Finalize()); 13472e5b6d6dSopenharmony_ci 13482e5b6d6dSopenharmony_ci builder.Reset(); 13492e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(0.00000001, &builder)); 13502e5b6d6dSopenharmony_ci CHECK_EQ("1e-8", builder.Finalize()); 13512e5b6d6dSopenharmony_ci 13522e5b6d6dSopenharmony_ci builder.Reset(); 13532e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(0.000000012, &builder)); 13542e5b6d6dSopenharmony_ci CHECK_EQ("1.2e-8", builder.Finalize()); 13552e5b6d6dSopenharmony_ci 13562e5b6d6dSopenharmony_ci builder.Reset(); 13572e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(0.000000012, &builder)); 13582e5b6d6dSopenharmony_ci CHECK_EQ("1.2e-8", builder.Finalize()); 13592e5b6d6dSopenharmony_ci 13602e5b6d6dSopenharmony_ci builder.Reset(); 13612e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(0.0000000123, &builder)); 13622e5b6d6dSopenharmony_ci CHECK_EQ("1.23e-8", builder.Finalize()); 13632e5b6d6dSopenharmony_ci 13642e5b6d6dSopenharmony_ci builder.Reset(); 13652e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(-0.0, &builder)); 13662e5b6d6dSopenharmony_ci CHECK_EQ("0", builder.Finalize()); 13672e5b6d6dSopenharmony_ci 13682e5b6d6dSopenharmony_ci builder.Reset(); 13692e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(-9.0, &builder)); 13702e5b6d6dSopenharmony_ci CHECK_EQ("-9", builder.Finalize()); 13712e5b6d6dSopenharmony_ci 13722e5b6d6dSopenharmony_ci builder.Reset(); 13732e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(-90.0, &builder)); 13742e5b6d6dSopenharmony_ci CHECK_EQ("-90", builder.Finalize()); 13752e5b6d6dSopenharmony_ci 13762e5b6d6dSopenharmony_ci builder.Reset(); 13772e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(-90.12, &builder)); 13782e5b6d6dSopenharmony_ci CHECK_EQ("-90.12", builder.Finalize()); 13792e5b6d6dSopenharmony_ci 13802e5b6d6dSopenharmony_ci builder.Reset(); 13812e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(-0.1, &builder)); 13822e5b6d6dSopenharmony_ci CHECK_EQ("-0.1", builder.Finalize()); 13832e5b6d6dSopenharmony_ci 13842e5b6d6dSopenharmony_ci builder.Reset(); 13852e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(-0.01, &builder)); 13862e5b6d6dSopenharmony_ci CHECK_EQ("-0.01", builder.Finalize()); 13872e5b6d6dSopenharmony_ci 13882e5b6d6dSopenharmony_ci builder.Reset(); 13892e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(-0.0123, &builder)); 13902e5b6d6dSopenharmony_ci CHECK_EQ("-0.0123", builder.Finalize()); 13912e5b6d6dSopenharmony_ci 13922e5b6d6dSopenharmony_ci builder.Reset(); 13932e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(-111111111111111111111.0, &builder)); 13942e5b6d6dSopenharmony_ci CHECK_EQ("-111111111111111110000", builder.Finalize()); 13952e5b6d6dSopenharmony_ci 13962e5b6d6dSopenharmony_ci builder.Reset(); 13972e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(-1111111111111111111111.0, &builder)); 13982e5b6d6dSopenharmony_ci CHECK_EQ("-1.1111111111111111e+21", builder.Finalize()); 13992e5b6d6dSopenharmony_ci 14002e5b6d6dSopenharmony_ci builder.Reset(); 14012e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(-11111111111111111111111.0, &builder)); 14022e5b6d6dSopenharmony_ci CHECK_EQ("-1.1111111111111111e+22", builder.Finalize()); 14032e5b6d6dSopenharmony_ci 14042e5b6d6dSopenharmony_ci builder.Reset(); 14052e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(-0.00001, &builder)); 14062e5b6d6dSopenharmony_ci CHECK_EQ("-0.00001", builder.Finalize()); 14072e5b6d6dSopenharmony_ci 14082e5b6d6dSopenharmony_ci builder.Reset(); 14092e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(-0.000001, &builder)); 14102e5b6d6dSopenharmony_ci CHECK_EQ("-0.000001", builder.Finalize()); 14112e5b6d6dSopenharmony_ci 14122e5b6d6dSopenharmony_ci builder.Reset(); 14132e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(-0.0000001, &builder)); 14142e5b6d6dSopenharmony_ci CHECK_EQ("-1e-7", builder.Finalize()); 14152e5b6d6dSopenharmony_ci 14162e5b6d6dSopenharmony_ci builder.Reset(); 14172e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(-0.00000012, &builder)); 14182e5b6d6dSopenharmony_ci CHECK_EQ("-1.2e-7", builder.Finalize()); 14192e5b6d6dSopenharmony_ci 14202e5b6d6dSopenharmony_ci builder.Reset(); 14212e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(-0.000000123, &builder)); 14222e5b6d6dSopenharmony_ci CHECK_EQ("-1.23e-7", builder.Finalize()); 14232e5b6d6dSopenharmony_ci 14242e5b6d6dSopenharmony_ci builder.Reset(); 14252e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(-0.00000001, &builder)); 14262e5b6d6dSopenharmony_ci CHECK_EQ("-1e-8", builder.Finalize()); 14272e5b6d6dSopenharmony_ci 14282e5b6d6dSopenharmony_ci builder.Reset(); 14292e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(-0.000000012, &builder)); 14302e5b6d6dSopenharmony_ci CHECK_EQ("-1.2e-8", builder.Finalize()); 14312e5b6d6dSopenharmony_ci 14322e5b6d6dSopenharmony_ci builder.Reset(); 14332e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(-0.000000012, &builder)); 14342e5b6d6dSopenharmony_ci CHECK_EQ("-1.2e-8", builder.Finalize()); 14352e5b6d6dSopenharmony_ci 14362e5b6d6dSopenharmony_ci builder.Reset(); 14372e5b6d6dSopenharmony_ci CHECK(dc.ToShortest(-0.0000000123, &builder)); 14382e5b6d6dSopenharmony_ci CHECK_EQ("-1.23e-8", builder.Finalize()); 14392e5b6d6dSopenharmony_ci 14402e5b6d6dSopenharmony_ci builder.Reset(); 14412e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(Double::NaN(), 2, &builder)); 14422e5b6d6dSopenharmony_ci CHECK_EQ("NaN", builder.Finalize()); 14432e5b6d6dSopenharmony_ci 14442e5b6d6dSopenharmony_ci builder.Reset(); 14452e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(Double::Infinity(), 2, &builder)); 14462e5b6d6dSopenharmony_ci CHECK_EQ("Infinity", builder.Finalize()); 14472e5b6d6dSopenharmony_ci 14482e5b6d6dSopenharmony_ci builder.Reset(); 14492e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-Double::Infinity(), 2, &builder)); 14502e5b6d6dSopenharmony_ci CHECK_EQ("-Infinity", builder.Finalize()); 14512e5b6d6dSopenharmony_ci 14522e5b6d6dSopenharmony_ci builder.Reset(); 14532e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-0.1, 1, &builder)); 14542e5b6d6dSopenharmony_ci CHECK_EQ("-0.1", builder.Finalize()); 14552e5b6d6dSopenharmony_ci 14562e5b6d6dSopenharmony_ci builder.Reset(); 14572e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-0.1, 2, &builder)); 14582e5b6d6dSopenharmony_ci CHECK_EQ("-0.10", builder.Finalize()); 14592e5b6d6dSopenharmony_ci 14602e5b6d6dSopenharmony_ci builder.Reset(); 14612e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-0.1, 3, &builder)); 14622e5b6d6dSopenharmony_ci CHECK_EQ("-0.100", builder.Finalize()); 14632e5b6d6dSopenharmony_ci 14642e5b6d6dSopenharmony_ci builder.Reset(); 14652e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-0.01, 2, &builder)); 14662e5b6d6dSopenharmony_ci CHECK_EQ("-0.01", builder.Finalize()); 14672e5b6d6dSopenharmony_ci 14682e5b6d6dSopenharmony_ci builder.Reset(); 14692e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-0.01, 3, &builder)); 14702e5b6d6dSopenharmony_ci CHECK_EQ("-0.010", builder.Finalize()); 14712e5b6d6dSopenharmony_ci 14722e5b6d6dSopenharmony_ci builder.Reset(); 14732e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-0.01, 4, &builder)); 14742e5b6d6dSopenharmony_ci CHECK_EQ("-0.0100", builder.Finalize()); 14752e5b6d6dSopenharmony_ci 14762e5b6d6dSopenharmony_ci builder.Reset(); 14772e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-0.001, 2, &builder)); 14782e5b6d6dSopenharmony_ci CHECK_EQ("-0.00", builder.Finalize()); 14792e5b6d6dSopenharmony_ci 14802e5b6d6dSopenharmony_ci builder.Reset(); 14812e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-0.001, 3, &builder)); 14822e5b6d6dSopenharmony_ci CHECK_EQ("-0.001", builder.Finalize()); 14832e5b6d6dSopenharmony_ci 14842e5b6d6dSopenharmony_ci builder.Reset(); 14852e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-0.001, 4, &builder)); 14862e5b6d6dSopenharmony_ci CHECK_EQ("-0.0010", builder.Finalize()); 14872e5b6d6dSopenharmony_ci 14882e5b6d6dSopenharmony_ci builder.Reset(); 14892e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-1.0, 4, &builder)); 14902e5b6d6dSopenharmony_ci CHECK_EQ("-1.0000", builder.Finalize()); 14912e5b6d6dSopenharmony_ci 14922e5b6d6dSopenharmony_ci builder.Reset(); 14932e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-1.0, 1, &builder)); 14942e5b6d6dSopenharmony_ci CHECK_EQ("-1.0", builder.Finalize()); 14952e5b6d6dSopenharmony_ci 14962e5b6d6dSopenharmony_ci builder.Reset(); 14972e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-1.0, 0, &builder)); 14982e5b6d6dSopenharmony_ci CHECK_EQ("-1", builder.Finalize()); 14992e5b6d6dSopenharmony_ci 15002e5b6d6dSopenharmony_ci builder.Reset(); 15012e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-12.0, 0, &builder)); 15022e5b6d6dSopenharmony_ci CHECK_EQ("-12", builder.Finalize()); 15032e5b6d6dSopenharmony_ci 15042e5b6d6dSopenharmony_ci builder.Reset(); 15052e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-1.1, 0, &builder)); 15062e5b6d6dSopenharmony_ci CHECK_EQ("-1", builder.Finalize()); 15072e5b6d6dSopenharmony_ci 15082e5b6d6dSopenharmony_ci builder.Reset(); 15092e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-12.1, 0, &builder)); 15102e5b6d6dSopenharmony_ci CHECK_EQ("-12", builder.Finalize()); 15112e5b6d6dSopenharmony_ci 15122e5b6d6dSopenharmony_ci builder.Reset(); 15132e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-1.12, 0, &builder)); 15142e5b6d6dSopenharmony_ci CHECK_EQ("-1", builder.Finalize()); 15152e5b6d6dSopenharmony_ci 15162e5b6d6dSopenharmony_ci builder.Reset(); 15172e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-12.12, 0, &builder)); 15182e5b6d6dSopenharmony_ci CHECK_EQ("-12", builder.Finalize()); 15192e5b6d6dSopenharmony_ci 15202e5b6d6dSopenharmony_ci builder.Reset(); 15212e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-0.0000006, 7, &builder)); 15222e5b6d6dSopenharmony_ci CHECK_EQ("-0.0000006", builder.Finalize()); 15232e5b6d6dSopenharmony_ci 15242e5b6d6dSopenharmony_ci builder.Reset(); 15252e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-0.00000006, 8, &builder)); 15262e5b6d6dSopenharmony_ci CHECK_EQ("-0.00000006", builder.Finalize()); 15272e5b6d6dSopenharmony_ci 15282e5b6d6dSopenharmony_ci builder.Reset(); 15292e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-0.00000006, 9, &builder)); 15302e5b6d6dSopenharmony_ci CHECK_EQ("-0.000000060", builder.Finalize()); 15312e5b6d6dSopenharmony_ci 15322e5b6d6dSopenharmony_ci builder.Reset(); 15332e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-0.00000006, 10, &builder)); 15342e5b6d6dSopenharmony_ci CHECK_EQ("-0.0000000600", builder.Finalize()); 15352e5b6d6dSopenharmony_ci 15362e5b6d6dSopenharmony_ci builder.Reset(); 15372e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-0, 0, &builder)); 15382e5b6d6dSopenharmony_ci CHECK_EQ("0", builder.Finalize()); 15392e5b6d6dSopenharmony_ci 15402e5b6d6dSopenharmony_ci builder.Reset(); 15412e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-0, 1, &builder)); 15422e5b6d6dSopenharmony_ci CHECK_EQ("0.0", builder.Finalize()); 15432e5b6d6dSopenharmony_ci 15442e5b6d6dSopenharmony_ci builder.Reset(); 15452e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-0, 2, &builder)); 15462e5b6d6dSopenharmony_ci CHECK_EQ("0.00", builder.Finalize()); 15472e5b6d6dSopenharmony_ci 15482e5b6d6dSopenharmony_ci builder.Reset(); 15492e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(1000, 0, &builder)); 15502e5b6d6dSopenharmony_ci CHECK_EQ("1000", builder.Finalize()); 15512e5b6d6dSopenharmony_ci 15522e5b6d6dSopenharmony_ci builder.Reset(); 15532e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(0.00001, 0, &builder)); 15542e5b6d6dSopenharmony_ci CHECK_EQ("0", builder.Finalize()); 15552e5b6d6dSopenharmony_ci 15562e5b6d6dSopenharmony_ci builder.Reset(); 15572e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(0.00001, 5, &builder)); 15582e5b6d6dSopenharmony_ci CHECK_EQ("0.00001", builder.Finalize()); 15592e5b6d6dSopenharmony_ci 15602e5b6d6dSopenharmony_ci builder.Reset(); 15612e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(0.0000000000000000001, 20, &builder)); 15622e5b6d6dSopenharmony_ci CHECK_EQ("0.00000000000000000010", builder.Finalize()); 15632e5b6d6dSopenharmony_ci 15642e5b6d6dSopenharmony_ci builder.Reset(); 15652e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(0.00001, 17, &builder)); 15662e5b6d6dSopenharmony_ci CHECK_EQ("0.00001000000000000", builder.Finalize()); 15672e5b6d6dSopenharmony_ci 15682e5b6d6dSopenharmony_ci builder.Reset(); 15692e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(1000000000000000128.0, 0, &builder)); 15702e5b6d6dSopenharmony_ci CHECK_EQ("1000000000000000128", builder.Finalize()); 15712e5b6d6dSopenharmony_ci 15722e5b6d6dSopenharmony_ci builder.Reset(); 15732e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(1000000000000000128.0, 1, &builder)); 15742e5b6d6dSopenharmony_ci CHECK_EQ("1000000000000000128.0", builder.Finalize()); 15752e5b6d6dSopenharmony_ci 15762e5b6d6dSopenharmony_ci builder.Reset(); 15772e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(1000000000000000128.0, 2, &builder)); 15782e5b6d6dSopenharmony_ci CHECK_EQ("1000000000000000128.00", builder.Finalize()); 15792e5b6d6dSopenharmony_ci 15802e5b6d6dSopenharmony_ci builder.Reset(); 15812e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(1000000000000000128.0, 20, &builder)); 15822e5b6d6dSopenharmony_ci CHECK_EQ("1000000000000000128.00000000000000000000", builder.Finalize()); 15832e5b6d6dSopenharmony_ci 15842e5b6d6dSopenharmony_ci builder.Reset(); 15852e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(0.0, 0, &builder)); 15862e5b6d6dSopenharmony_ci CHECK_EQ("0", builder.Finalize()); 15872e5b6d6dSopenharmony_ci 15882e5b6d6dSopenharmony_ci builder.Reset(); 15892e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-42.0, 3, &builder)); 15902e5b6d6dSopenharmony_ci CHECK_EQ("-42.000", builder.Finalize()); 15912e5b6d6dSopenharmony_ci 15922e5b6d6dSopenharmony_ci builder.Reset(); 15932e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-1000000000000000128.0, 0, &builder)); 15942e5b6d6dSopenharmony_ci CHECK_EQ("-1000000000000000128", builder.Finalize()); 15952e5b6d6dSopenharmony_ci 15962e5b6d6dSopenharmony_ci builder.Reset(); 15972e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-0.0000000000000000001, 20, &builder)); 15982e5b6d6dSopenharmony_ci CHECK_EQ("-0.00000000000000000010", builder.Finalize()); 15992e5b6d6dSopenharmony_ci 16002e5b6d6dSopenharmony_ci builder.Reset(); 16012e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(0.123123123123123, 20, &builder)); 16022e5b6d6dSopenharmony_ci CHECK_EQ("0.12312312312312299889", builder.Finalize()); 16032e5b6d6dSopenharmony_ci 16042e5b6d6dSopenharmony_ci builder.Reset(); 16052e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(0.5, 0, &builder)); 16062e5b6d6dSopenharmony_ci CHECK_EQ("1", builder.Finalize()); 16072e5b6d6dSopenharmony_ci 16082e5b6d6dSopenharmony_ci builder.Reset(); 16092e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(-0.5, 0, &builder)); 16102e5b6d6dSopenharmony_ci CHECK_EQ("-1", builder.Finalize()); 16112e5b6d6dSopenharmony_ci 16122e5b6d6dSopenharmony_ci builder.Reset(); 16132e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(1.25, 1, &builder)); 16142e5b6d6dSopenharmony_ci CHECK_EQ("1.3", builder.Finalize()); 16152e5b6d6dSopenharmony_ci 16162e5b6d6dSopenharmony_ci builder.Reset(); 16172e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(234.20405, 4, &builder)); 16182e5b6d6dSopenharmony_ci CHECK_EQ("234.2040", builder.Finalize()); 16192e5b6d6dSopenharmony_ci 16202e5b6d6dSopenharmony_ci builder.Reset(); 16212e5b6d6dSopenharmony_ci CHECK(dc.ToFixed(234.2040506, 4, &builder)); 16222e5b6d6dSopenharmony_ci CHECK_EQ("234.2041", builder.Finalize()); 16232e5b6d6dSopenharmony_ci 16242e5b6d6dSopenharmony_ci builder.Reset(); 16252e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(1.0, -1, &builder)); 16262e5b6d6dSopenharmony_ci CHECK_EQ("1e+0", builder.Finalize()); 16272e5b6d6dSopenharmony_ci 16282e5b6d6dSopenharmony_ci builder.Reset(); 16292e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(11.0, -1, &builder)); 16302e5b6d6dSopenharmony_ci CHECK_EQ("1.1e+1", builder.Finalize()); 16312e5b6d6dSopenharmony_ci 16322e5b6d6dSopenharmony_ci builder.Reset(); 16332e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(112.0, -1, &builder)); 16342e5b6d6dSopenharmony_ci CHECK_EQ("1.12e+2", builder.Finalize()); 16352e5b6d6dSopenharmony_ci 16362e5b6d6dSopenharmony_ci builder.Reset(); 16372e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(1.0, 0, &builder)); 16382e5b6d6dSopenharmony_ci CHECK_EQ("1e+0", builder.Finalize()); 16392e5b6d6dSopenharmony_ci 16402e5b6d6dSopenharmony_ci builder.Reset(); 16412e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(11.0, 0, &builder)); 16422e5b6d6dSopenharmony_ci CHECK_EQ("1e+1", builder.Finalize()); 16432e5b6d6dSopenharmony_ci 16442e5b6d6dSopenharmony_ci builder.Reset(); 16452e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(112.0, 0, &builder)); 16462e5b6d6dSopenharmony_ci CHECK_EQ("1e+2", builder.Finalize()); 16472e5b6d6dSopenharmony_ci 16482e5b6d6dSopenharmony_ci builder.Reset(); 16492e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(1.0, 1, &builder)); 16502e5b6d6dSopenharmony_ci CHECK_EQ("1.0e+0", builder.Finalize()); 16512e5b6d6dSopenharmony_ci 16522e5b6d6dSopenharmony_ci builder.Reset(); 16532e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(11.0, 1, &builder)); 16542e5b6d6dSopenharmony_ci CHECK_EQ("1.1e+1", builder.Finalize()); 16552e5b6d6dSopenharmony_ci 16562e5b6d6dSopenharmony_ci builder.Reset(); 16572e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(112.0, 1, &builder)); 16582e5b6d6dSopenharmony_ci CHECK_EQ("1.1e+2", builder.Finalize()); 16592e5b6d6dSopenharmony_ci 16602e5b6d6dSopenharmony_ci builder.Reset(); 16612e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(1.0, 2, &builder)); 16622e5b6d6dSopenharmony_ci CHECK_EQ("1.00e+0", builder.Finalize()); 16632e5b6d6dSopenharmony_ci 16642e5b6d6dSopenharmony_ci builder.Reset(); 16652e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(11.0, 2, &builder)); 16662e5b6d6dSopenharmony_ci CHECK_EQ("1.10e+1", builder.Finalize()); 16672e5b6d6dSopenharmony_ci 16682e5b6d6dSopenharmony_ci builder.Reset(); 16692e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(112.0, 2, &builder)); 16702e5b6d6dSopenharmony_ci CHECK_EQ("1.12e+2", builder.Finalize()); 16712e5b6d6dSopenharmony_ci 16722e5b6d6dSopenharmony_ci builder.Reset(); 16732e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(1.0, 3, &builder)); 16742e5b6d6dSopenharmony_ci CHECK_EQ("1.000e+0", builder.Finalize()); 16752e5b6d6dSopenharmony_ci 16762e5b6d6dSopenharmony_ci builder.Reset(); 16772e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(11.0, 3, &builder)); 16782e5b6d6dSopenharmony_ci CHECK_EQ("1.100e+1", builder.Finalize()); 16792e5b6d6dSopenharmony_ci 16802e5b6d6dSopenharmony_ci builder.Reset(); 16812e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(112.0, 3, &builder)); 16822e5b6d6dSopenharmony_ci CHECK_EQ("1.120e+2", builder.Finalize()); 16832e5b6d6dSopenharmony_ci 16842e5b6d6dSopenharmony_ci builder.Reset(); 16852e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.1, -1, &builder)); 16862e5b6d6dSopenharmony_ci CHECK_EQ("1e-1", builder.Finalize()); 16872e5b6d6dSopenharmony_ci 16882e5b6d6dSopenharmony_ci builder.Reset(); 16892e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.11, -1, &builder)); 16902e5b6d6dSopenharmony_ci CHECK_EQ("1.1e-1", builder.Finalize()); 16912e5b6d6dSopenharmony_ci 16922e5b6d6dSopenharmony_ci builder.Reset(); 16932e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.112, -1, &builder)); 16942e5b6d6dSopenharmony_ci CHECK_EQ("1.12e-1", builder.Finalize()); 16952e5b6d6dSopenharmony_ci 16962e5b6d6dSopenharmony_ci builder.Reset(); 16972e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.1, 0, &builder)); 16982e5b6d6dSopenharmony_ci CHECK_EQ("1e-1", builder.Finalize()); 16992e5b6d6dSopenharmony_ci 17002e5b6d6dSopenharmony_ci builder.Reset(); 17012e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.11, 0, &builder)); 17022e5b6d6dSopenharmony_ci CHECK_EQ("1e-1", builder.Finalize()); 17032e5b6d6dSopenharmony_ci 17042e5b6d6dSopenharmony_ci builder.Reset(); 17052e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.112, 0, &builder)); 17062e5b6d6dSopenharmony_ci CHECK_EQ("1e-1", builder.Finalize()); 17072e5b6d6dSopenharmony_ci 17082e5b6d6dSopenharmony_ci builder.Reset(); 17092e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.1, 1, &builder)); 17102e5b6d6dSopenharmony_ci CHECK_EQ("1.0e-1", builder.Finalize()); 17112e5b6d6dSopenharmony_ci 17122e5b6d6dSopenharmony_ci builder.Reset(); 17132e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.11, 1, &builder)); 17142e5b6d6dSopenharmony_ci CHECK_EQ("1.1e-1", builder.Finalize()); 17152e5b6d6dSopenharmony_ci 17162e5b6d6dSopenharmony_ci builder.Reset(); 17172e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.112, 1, &builder)); 17182e5b6d6dSopenharmony_ci CHECK_EQ("1.1e-1", builder.Finalize()); 17192e5b6d6dSopenharmony_ci 17202e5b6d6dSopenharmony_ci builder.Reset(); 17212e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.1, 2, &builder)); 17222e5b6d6dSopenharmony_ci CHECK_EQ("1.00e-1", builder.Finalize()); 17232e5b6d6dSopenharmony_ci 17242e5b6d6dSopenharmony_ci builder.Reset(); 17252e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.11, 2, &builder)); 17262e5b6d6dSopenharmony_ci CHECK_EQ("1.10e-1", builder.Finalize()); 17272e5b6d6dSopenharmony_ci 17282e5b6d6dSopenharmony_ci builder.Reset(); 17292e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.112, 2, &builder)); 17302e5b6d6dSopenharmony_ci CHECK_EQ("1.12e-1", builder.Finalize()); 17312e5b6d6dSopenharmony_ci 17322e5b6d6dSopenharmony_ci builder.Reset(); 17332e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.1, 3, &builder)); 17342e5b6d6dSopenharmony_ci CHECK_EQ("1.000e-1", builder.Finalize()); 17352e5b6d6dSopenharmony_ci 17362e5b6d6dSopenharmony_ci builder.Reset(); 17372e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.11, 3, &builder)); 17382e5b6d6dSopenharmony_ci CHECK_EQ("1.100e-1", builder.Finalize()); 17392e5b6d6dSopenharmony_ci 17402e5b6d6dSopenharmony_ci builder.Reset(); 17412e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.112, 3, &builder)); 17422e5b6d6dSopenharmony_ci CHECK_EQ("1.120e-1", builder.Finalize()); 17432e5b6d6dSopenharmony_ci 17442e5b6d6dSopenharmony_ci builder.Reset(); 17452e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-1.0, -1, &builder)); 17462e5b6d6dSopenharmony_ci CHECK_EQ("-1e+0", builder.Finalize()); 17472e5b6d6dSopenharmony_ci 17482e5b6d6dSopenharmony_ci builder.Reset(); 17492e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-11.0, -1, &builder)); 17502e5b6d6dSopenharmony_ci CHECK_EQ("-1.1e+1", builder.Finalize()); 17512e5b6d6dSopenharmony_ci 17522e5b6d6dSopenharmony_ci builder.Reset(); 17532e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-112.0, -1, &builder)); 17542e5b6d6dSopenharmony_ci CHECK_EQ("-1.12e+2", builder.Finalize()); 17552e5b6d6dSopenharmony_ci 17562e5b6d6dSopenharmony_ci builder.Reset(); 17572e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-1.0, 0, &builder)); 17582e5b6d6dSopenharmony_ci CHECK_EQ("-1e+0", builder.Finalize()); 17592e5b6d6dSopenharmony_ci 17602e5b6d6dSopenharmony_ci builder.Reset(); 17612e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-11.0, 0, &builder)); 17622e5b6d6dSopenharmony_ci CHECK_EQ("-1e+1", builder.Finalize()); 17632e5b6d6dSopenharmony_ci 17642e5b6d6dSopenharmony_ci builder.Reset(); 17652e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-112.0, 0, &builder)); 17662e5b6d6dSopenharmony_ci CHECK_EQ("-1e+2", builder.Finalize()); 17672e5b6d6dSopenharmony_ci 17682e5b6d6dSopenharmony_ci builder.Reset(); 17692e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-1.0, 1, &builder)); 17702e5b6d6dSopenharmony_ci CHECK_EQ("-1.0e+0", builder.Finalize()); 17712e5b6d6dSopenharmony_ci 17722e5b6d6dSopenharmony_ci builder.Reset(); 17732e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-11.0, 1, &builder)); 17742e5b6d6dSopenharmony_ci CHECK_EQ("-1.1e+1", builder.Finalize()); 17752e5b6d6dSopenharmony_ci 17762e5b6d6dSopenharmony_ci builder.Reset(); 17772e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-112.0, 1, &builder)); 17782e5b6d6dSopenharmony_ci CHECK_EQ("-1.1e+2", builder.Finalize()); 17792e5b6d6dSopenharmony_ci 17802e5b6d6dSopenharmony_ci builder.Reset(); 17812e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-1.0, 2, &builder)); 17822e5b6d6dSopenharmony_ci CHECK_EQ("-1.00e+0", builder.Finalize()); 17832e5b6d6dSopenharmony_ci 17842e5b6d6dSopenharmony_ci builder.Reset(); 17852e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-11.0, 2, &builder)); 17862e5b6d6dSopenharmony_ci CHECK_EQ("-1.10e+1", builder.Finalize()); 17872e5b6d6dSopenharmony_ci 17882e5b6d6dSopenharmony_ci builder.Reset(); 17892e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-112.0, 2, &builder)); 17902e5b6d6dSopenharmony_ci CHECK_EQ("-1.12e+2", builder.Finalize()); 17912e5b6d6dSopenharmony_ci 17922e5b6d6dSopenharmony_ci builder.Reset(); 17932e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-1.0, 3, &builder)); 17942e5b6d6dSopenharmony_ci CHECK_EQ("-1.000e+0", builder.Finalize()); 17952e5b6d6dSopenharmony_ci 17962e5b6d6dSopenharmony_ci builder.Reset(); 17972e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-11.0, 3, &builder)); 17982e5b6d6dSopenharmony_ci CHECK_EQ("-1.100e+1", builder.Finalize()); 17992e5b6d6dSopenharmony_ci 18002e5b6d6dSopenharmony_ci builder.Reset(); 18012e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-112.0, 3, &builder)); 18022e5b6d6dSopenharmony_ci CHECK_EQ("-1.120e+2", builder.Finalize()); 18032e5b6d6dSopenharmony_ci 18042e5b6d6dSopenharmony_ci builder.Reset(); 18052e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-0.1, -1, &builder)); 18062e5b6d6dSopenharmony_ci CHECK_EQ("-1e-1", builder.Finalize()); 18072e5b6d6dSopenharmony_ci 18082e5b6d6dSopenharmony_ci builder.Reset(); 18092e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-0.11, -1, &builder)); 18102e5b6d6dSopenharmony_ci CHECK_EQ("-1.1e-1", builder.Finalize()); 18112e5b6d6dSopenharmony_ci 18122e5b6d6dSopenharmony_ci builder.Reset(); 18132e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-0.112, -1, &builder)); 18142e5b6d6dSopenharmony_ci CHECK_EQ("-1.12e-1", builder.Finalize()); 18152e5b6d6dSopenharmony_ci 18162e5b6d6dSopenharmony_ci builder.Reset(); 18172e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-0.1, 0, &builder)); 18182e5b6d6dSopenharmony_ci CHECK_EQ("-1e-1", builder.Finalize()); 18192e5b6d6dSopenharmony_ci 18202e5b6d6dSopenharmony_ci builder.Reset(); 18212e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-0.11, 0, &builder)); 18222e5b6d6dSopenharmony_ci CHECK_EQ("-1e-1", builder.Finalize()); 18232e5b6d6dSopenharmony_ci 18242e5b6d6dSopenharmony_ci builder.Reset(); 18252e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-0.112, 0, &builder)); 18262e5b6d6dSopenharmony_ci CHECK_EQ("-1e-1", builder.Finalize()); 18272e5b6d6dSopenharmony_ci 18282e5b6d6dSopenharmony_ci builder.Reset(); 18292e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-0.1, 1, &builder)); 18302e5b6d6dSopenharmony_ci CHECK_EQ("-1.0e-1", builder.Finalize()); 18312e5b6d6dSopenharmony_ci 18322e5b6d6dSopenharmony_ci builder.Reset(); 18332e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-0.11, 1, &builder)); 18342e5b6d6dSopenharmony_ci CHECK_EQ("-1.1e-1", builder.Finalize()); 18352e5b6d6dSopenharmony_ci 18362e5b6d6dSopenharmony_ci builder.Reset(); 18372e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-0.112, 1, &builder)); 18382e5b6d6dSopenharmony_ci CHECK_EQ("-1.1e-1", builder.Finalize()); 18392e5b6d6dSopenharmony_ci 18402e5b6d6dSopenharmony_ci builder.Reset(); 18412e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-0.1, 2, &builder)); 18422e5b6d6dSopenharmony_ci CHECK_EQ("-1.00e-1", builder.Finalize()); 18432e5b6d6dSopenharmony_ci 18442e5b6d6dSopenharmony_ci builder.Reset(); 18452e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-0.11, 2, &builder)); 18462e5b6d6dSopenharmony_ci CHECK_EQ("-1.10e-1", builder.Finalize()); 18472e5b6d6dSopenharmony_ci 18482e5b6d6dSopenharmony_ci builder.Reset(); 18492e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-0.112, 2, &builder)); 18502e5b6d6dSopenharmony_ci CHECK_EQ("-1.12e-1", builder.Finalize()); 18512e5b6d6dSopenharmony_ci 18522e5b6d6dSopenharmony_ci builder.Reset(); 18532e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-0.1, 3, &builder)); 18542e5b6d6dSopenharmony_ci CHECK_EQ("-1.000e-1", builder.Finalize()); 18552e5b6d6dSopenharmony_ci 18562e5b6d6dSopenharmony_ci builder.Reset(); 18572e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-0.11, 3, &builder)); 18582e5b6d6dSopenharmony_ci CHECK_EQ("-1.100e-1", builder.Finalize()); 18592e5b6d6dSopenharmony_ci 18602e5b6d6dSopenharmony_ci builder.Reset(); 18612e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-0.112, 3, &builder)); 18622e5b6d6dSopenharmony_ci CHECK_EQ("-1.120e-1", builder.Finalize()); 18632e5b6d6dSopenharmony_ci 18642e5b6d6dSopenharmony_ci builder.Reset(); 18652e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(Double::NaN(), 2, &builder)); 18662e5b6d6dSopenharmony_ci CHECK_EQ("NaN", builder.Finalize()); 18672e5b6d6dSopenharmony_ci 18682e5b6d6dSopenharmony_ci builder.Reset(); 18692e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(Double::Infinity(), 2, &builder)); 18702e5b6d6dSopenharmony_ci CHECK_EQ("Infinity", builder.Finalize()); 18712e5b6d6dSopenharmony_ci 18722e5b6d6dSopenharmony_ci builder.Reset(); 18732e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-Double::Infinity(), 2, &builder)); 18742e5b6d6dSopenharmony_ci CHECK_EQ("-Infinity", builder.Finalize()); 18752e5b6d6dSopenharmony_ci 18762e5b6d6dSopenharmony_ci builder.Reset(); 18772e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(1.0, 0, &builder)); 18782e5b6d6dSopenharmony_ci CHECK_EQ("1e+0", builder.Finalize()); 18792e5b6d6dSopenharmony_ci 18802e5b6d6dSopenharmony_ci builder.Reset(); 18812e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.0, -1, &builder)); 18822e5b6d6dSopenharmony_ci CHECK_EQ("0e+0", builder.Finalize()); 18832e5b6d6dSopenharmony_ci 18842e5b6d6dSopenharmony_ci builder.Reset(); 18852e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.0, 2, &builder)); 18862e5b6d6dSopenharmony_ci CHECK_EQ("0.00e+0", builder.Finalize()); 18872e5b6d6dSopenharmony_ci 18882e5b6d6dSopenharmony_ci builder.Reset(); 18892e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(11.2356, 0, &builder)); 18902e5b6d6dSopenharmony_ci CHECK_EQ("1e+1", builder.Finalize()); 18912e5b6d6dSopenharmony_ci 18922e5b6d6dSopenharmony_ci builder.Reset(); 18932e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(11.2356, 4, &builder)); 18942e5b6d6dSopenharmony_ci CHECK_EQ("1.1236e+1", builder.Finalize()); 18952e5b6d6dSopenharmony_ci 18962e5b6d6dSopenharmony_ci builder.Reset(); 18972e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.000112356, 4, &builder)); 18982e5b6d6dSopenharmony_ci CHECK_EQ("1.1236e-4", builder.Finalize()); 18992e5b6d6dSopenharmony_ci 19002e5b6d6dSopenharmony_ci builder.Reset(); 19012e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-0.000112356, 4, &builder)); 19022e5b6d6dSopenharmony_ci CHECK_EQ("-1.1236e-4", builder.Finalize()); 19032e5b6d6dSopenharmony_ci 19042e5b6d6dSopenharmony_ci builder.Reset(); 19052e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(0.000112356, -1, &builder)); 19062e5b6d6dSopenharmony_ci CHECK_EQ("1.12356e-4", builder.Finalize()); 19072e5b6d6dSopenharmony_ci 19082e5b6d6dSopenharmony_ci builder.Reset(); 19092e5b6d6dSopenharmony_ci CHECK(dc.ToExponential(-0.000112356, -1, &builder)); 19102e5b6d6dSopenharmony_ci CHECK_EQ("-1.12356e-4", builder.Finalize()); 19112e5b6d6dSopenharmony_ci 19122e5b6d6dSopenharmony_ci builder.Reset(); 19132e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(Double::NaN(), 1, &builder)); 19142e5b6d6dSopenharmony_ci CHECK_EQ("NaN", builder.Finalize()); 19152e5b6d6dSopenharmony_ci 19162e5b6d6dSopenharmony_ci builder.Reset(); 19172e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(Double::Infinity(), 2, &builder)); 19182e5b6d6dSopenharmony_ci CHECK_EQ("Infinity", builder.Finalize()); 19192e5b6d6dSopenharmony_ci 19202e5b6d6dSopenharmony_ci builder.Reset(); 19212e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(-Double::Infinity(), 2, &builder)); 19222e5b6d6dSopenharmony_ci CHECK_EQ("-Infinity", builder.Finalize()); 19232e5b6d6dSopenharmony_ci 19242e5b6d6dSopenharmony_ci builder.Reset(); 19252e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(0.000555, 15, &builder)); 19262e5b6d6dSopenharmony_ci CHECK_EQ("0.000555000000000000", builder.Finalize()); 19272e5b6d6dSopenharmony_ci 19282e5b6d6dSopenharmony_ci builder.Reset(); 19292e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(0.000000555, 15, &builder)); 19302e5b6d6dSopenharmony_ci CHECK_EQ("5.55000000000000e-7", builder.Finalize()); 19312e5b6d6dSopenharmony_ci 19322e5b6d6dSopenharmony_ci builder.Reset(); 19332e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(-0.000000555, 15, &builder)); 19342e5b6d6dSopenharmony_ci CHECK_EQ("-5.55000000000000e-7", builder.Finalize()); 19352e5b6d6dSopenharmony_ci 19362e5b6d6dSopenharmony_ci builder.Reset(); 19372e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(123456789.0, 1, &builder)); 19382e5b6d6dSopenharmony_ci CHECK_EQ("1e+8", builder.Finalize()); 19392e5b6d6dSopenharmony_ci 19402e5b6d6dSopenharmony_ci builder.Reset(); 19412e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(123456789.0, 9, &builder)); 19422e5b6d6dSopenharmony_ci CHECK_EQ("123456789", builder.Finalize()); 19432e5b6d6dSopenharmony_ci 19442e5b6d6dSopenharmony_ci builder.Reset(); 19452e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(123456789.0, 8, &builder)); 19462e5b6d6dSopenharmony_ci CHECK_EQ("1.2345679e+8", builder.Finalize()); 19472e5b6d6dSopenharmony_ci 19482e5b6d6dSopenharmony_ci builder.Reset(); 19492e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(123456789.0, 7, &builder)); 19502e5b6d6dSopenharmony_ci CHECK_EQ("1.234568e+8", builder.Finalize()); 19512e5b6d6dSopenharmony_ci 19522e5b6d6dSopenharmony_ci builder.Reset(); 19532e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(-123456789.0, 7, &builder)); 19542e5b6d6dSopenharmony_ci CHECK_EQ("-1.234568e+8", builder.Finalize()); 19552e5b6d6dSopenharmony_ci 19562e5b6d6dSopenharmony_ci builder.Reset(); 19572e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(-.0000000012345, 2, &builder)); 19582e5b6d6dSopenharmony_ci CHECK_EQ("-1.2e-9", builder.Finalize()); 19592e5b6d6dSopenharmony_ci 19602e5b6d6dSopenharmony_ci builder.Reset(); 19612e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(-.000000012345, 2, &builder)); 19622e5b6d6dSopenharmony_ci CHECK_EQ("-1.2e-8", builder.Finalize()); 19632e5b6d6dSopenharmony_ci 19642e5b6d6dSopenharmony_ci builder.Reset(); 19652e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(-.00000012345, 2, &builder)); 19662e5b6d6dSopenharmony_ci CHECK_EQ("-1.2e-7", builder.Finalize()); 19672e5b6d6dSopenharmony_ci 19682e5b6d6dSopenharmony_ci builder.Reset(); 19692e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(-.0000012345, 2, &builder)); 19702e5b6d6dSopenharmony_ci CHECK_EQ("-0.0000012", builder.Finalize()); 19712e5b6d6dSopenharmony_ci 19722e5b6d6dSopenharmony_ci builder.Reset(); 19732e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(-.000012345, 2, &builder)); 19742e5b6d6dSopenharmony_ci CHECK_EQ("-0.000012", builder.Finalize()); 19752e5b6d6dSopenharmony_ci 19762e5b6d6dSopenharmony_ci builder.Reset(); 19772e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(-.00012345, 2, &builder)); 19782e5b6d6dSopenharmony_ci CHECK_EQ("-0.00012", builder.Finalize()); 19792e5b6d6dSopenharmony_ci 19802e5b6d6dSopenharmony_ci builder.Reset(); 19812e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(-.0012345, 2, &builder)); 19822e5b6d6dSopenharmony_ci CHECK_EQ("-0.0012", builder.Finalize()); 19832e5b6d6dSopenharmony_ci 19842e5b6d6dSopenharmony_ci builder.Reset(); 19852e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(-.012345, 2, &builder)); 19862e5b6d6dSopenharmony_ci CHECK_EQ("-0.012", builder.Finalize()); 19872e5b6d6dSopenharmony_ci 19882e5b6d6dSopenharmony_ci builder.Reset(); 19892e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(-.12345, 2, &builder)); 19902e5b6d6dSopenharmony_ci CHECK_EQ("-0.12", builder.Finalize()); 19912e5b6d6dSopenharmony_ci 19922e5b6d6dSopenharmony_ci builder.Reset(); 19932e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(-1.2345, 2, &builder)); 19942e5b6d6dSopenharmony_ci CHECK_EQ("-1.2", builder.Finalize()); 19952e5b6d6dSopenharmony_ci 19962e5b6d6dSopenharmony_ci builder.Reset(); 19972e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(-12.345, 2, &builder)); 19982e5b6d6dSopenharmony_ci CHECK_EQ("-12", builder.Finalize()); 19992e5b6d6dSopenharmony_ci 20002e5b6d6dSopenharmony_ci builder.Reset(); 20012e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(-123.45, 2, &builder)); 20022e5b6d6dSopenharmony_ci CHECK_EQ("-1.2e+2", builder.Finalize()); 20032e5b6d6dSopenharmony_ci 20042e5b6d6dSopenharmony_ci builder.Reset(); 20052e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(-1234.5, 2, &builder)); 20062e5b6d6dSopenharmony_ci CHECK_EQ("-1.2e+3", builder.Finalize()); 20072e5b6d6dSopenharmony_ci 20082e5b6d6dSopenharmony_ci builder.Reset(); 20092e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(-12345.0, 2, &builder)); 20102e5b6d6dSopenharmony_ci CHECK_EQ("-1.2e+4", builder.Finalize()); 20112e5b6d6dSopenharmony_ci 20122e5b6d6dSopenharmony_ci builder.Reset(); 20132e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(-12345.67, 4, &builder)); 20142e5b6d6dSopenharmony_ci CHECK_EQ("-1.235e+4", builder.Finalize()); 20152e5b6d6dSopenharmony_ci 20162e5b6d6dSopenharmony_ci builder.Reset(); 20172e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(-12344.67, 4, &builder)); 20182e5b6d6dSopenharmony_ci CHECK_EQ("-1.234e+4", builder.Finalize()); 20192e5b6d6dSopenharmony_ci 20202e5b6d6dSopenharmony_ci builder.Reset(); 20212e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(1.25, 2, &builder)); 20222e5b6d6dSopenharmony_ci CHECK_EQ("1.3", builder.Finalize()); 20232e5b6d6dSopenharmony_ci 20242e5b6d6dSopenharmony_ci builder.Reset(); 20252e5b6d6dSopenharmony_ci CHECK(dc.ToPrecision(1.35, 2, &builder)); 20262e5b6d6dSopenharmony_ci CHECK_EQ("1.4", builder.Finalize()); 20272e5b6d6dSopenharmony_ci} 20282e5b6d6dSopenharmony_ci 20292e5b6d6dSopenharmony_ci 20302e5b6d6dSopenharmony_cistatic double StrToD16(const uc16* str16, int length, int flags, 20312e5b6d6dSopenharmony_ci double empty_string_value, 20322e5b6d6dSopenharmony_ci int* processed_characters_count, bool* processed_all, 20332e5b6d6dSopenharmony_ci uc16 separator = StringToDoubleConverter::kNoSeparator) { 20342e5b6d6dSopenharmony_ci StringToDoubleConverter converter(flags, empty_string_value, Double::NaN(), 20352e5b6d6dSopenharmony_ci NULL, NULL, separator); 20362e5b6d6dSopenharmony_ci double result = 20372e5b6d6dSopenharmony_ci converter.StringToDouble(str16, length, processed_characters_count); 20382e5b6d6dSopenharmony_ci *processed_all = (length == *processed_characters_count); 20392e5b6d6dSopenharmony_ci return result; 20402e5b6d6dSopenharmony_ci} 20412e5b6d6dSopenharmony_ci 20422e5b6d6dSopenharmony_ci 20432e5b6d6dSopenharmony_cistatic double StrToD16(const char* str, int flags, 20442e5b6d6dSopenharmony_ci double empty_string_value, 20452e5b6d6dSopenharmony_ci int* processed_characters_count, bool* processed_all, 20462e5b6d6dSopenharmony_ci char char_separator, uc16 separator) { 20472e5b6d6dSopenharmony_ci uc16 str16[256]; 20482e5b6d6dSopenharmony_ci int length = -1; 20492e5b6d6dSopenharmony_ci for (int i = 0;; i++) { 20502e5b6d6dSopenharmony_ci if (str[i] == char_separator) { 20512e5b6d6dSopenharmony_ci str16[i] = separator; 20522e5b6d6dSopenharmony_ci } else { 20532e5b6d6dSopenharmony_ci str16[i] = str[i]; 20542e5b6d6dSopenharmony_ci } 20552e5b6d6dSopenharmony_ci if (str[i] == '\0') { 20562e5b6d6dSopenharmony_ci length = i; 20572e5b6d6dSopenharmony_ci break; 20582e5b6d6dSopenharmony_ci } 20592e5b6d6dSopenharmony_ci } 20602e5b6d6dSopenharmony_ci DOUBLE_CONVERSION_ASSERT(length < 256); 20612e5b6d6dSopenharmony_ci StringToDoubleConverter converter(flags, empty_string_value, Double::NaN(), 20622e5b6d6dSopenharmony_ci NULL, NULL, separator); 20632e5b6d6dSopenharmony_ci double result = 20642e5b6d6dSopenharmony_ci converter.StringToDouble(str16, length, processed_characters_count); 20652e5b6d6dSopenharmony_ci *processed_all = (length == *processed_characters_count); 20662e5b6d6dSopenharmony_ci return result; 20672e5b6d6dSopenharmony_ci} 20682e5b6d6dSopenharmony_ci 20692e5b6d6dSopenharmony_ci 20702e5b6d6dSopenharmony_cistatic double StrToD(const char* str, int flags, double empty_string_value, 20712e5b6d6dSopenharmony_ci int* processed_characters_count, bool* processed_all, 20722e5b6d6dSopenharmony_ci uc16 separator = StringToDoubleConverter::kNoSeparator) { 20732e5b6d6dSopenharmony_ci StringToDoubleConverter converter(flags, empty_string_value, Double::NaN(), 20742e5b6d6dSopenharmony_ci NULL, NULL, separator); 20752e5b6d6dSopenharmony_ci int len = static_cast<int>(strlen(str)); 20762e5b6d6dSopenharmony_ci double result = converter.StringToDouble(str, len, 20772e5b6d6dSopenharmony_ci processed_characters_count); 20782e5b6d6dSopenharmony_ci *processed_all = 20792e5b6d6dSopenharmony_ci ((strlen(str) == static_cast<unsigned>(*processed_characters_count))); 20802e5b6d6dSopenharmony_ci 20812e5b6d6dSopenharmony_ci uc16 buffer16[256]; 20822e5b6d6dSopenharmony_ci DOUBLE_CONVERSION_ASSERT(strlen(str) < DOUBLE_CONVERSION_ARRAY_SIZE(buffer16)); 20832e5b6d6dSopenharmony_ci for (int i = 0; i < len; i++) { 20842e5b6d6dSopenharmony_ci buffer16[i] = str[i]; 20852e5b6d6dSopenharmony_ci } 20862e5b6d6dSopenharmony_ci int processed_characters_count16; 20872e5b6d6dSopenharmony_ci bool processed_all16; 20882e5b6d6dSopenharmony_ci double result16 = StrToD16(buffer16, len, flags, empty_string_value, 20892e5b6d6dSopenharmony_ci &processed_characters_count16, &processed_all16, 20902e5b6d6dSopenharmony_ci separator); 20912e5b6d6dSopenharmony_ci CHECK_EQ(result, result16); 20922e5b6d6dSopenharmony_ci CHECK_EQ(*processed_characters_count, processed_characters_count16); 20932e5b6d6dSopenharmony_ci return result; 20942e5b6d6dSopenharmony_ci} 20952e5b6d6dSopenharmony_ci 20962e5b6d6dSopenharmony_ci 20972e5b6d6dSopenharmony_ciTEST(StringToDoubleVarious) { 20982e5b6d6dSopenharmony_ci int flags; 20992e5b6d6dSopenharmony_ci int processed; 21002e5b6d6dSopenharmony_ci bool all_used; 21012e5b6d6dSopenharmony_ci 21022e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_LEADING_SPACES | 21032e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN | 21042e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_SPACES; 21052e5b6d6dSopenharmony_ci 21062e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("", flags, 0.0, &processed, &all_used)); 21072e5b6d6dSopenharmony_ci CHECK(all_used); 21082e5b6d6dSopenharmony_ci 21092e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD("", flags, 1.0, &processed, &all_used)); 21102e5b6d6dSopenharmony_ci CHECK(all_used); 21112e5b6d6dSopenharmony_ci 21122e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD(" ", flags, 0.0, &processed, &all_used)); 21132e5b6d6dSopenharmony_ci CHECK(all_used); 21142e5b6d6dSopenharmony_ci 21152e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD(" ", flags, 1.0, &processed, &all_used)); 21162e5b6d6dSopenharmony_ci CHECK(all_used); 21172e5b6d6dSopenharmony_ci 21182e5b6d6dSopenharmony_ci CHECK_EQ(42.0, StrToD("42", flags, 0.0, &processed, &all_used)); 21192e5b6d6dSopenharmony_ci CHECK(all_used); 21202e5b6d6dSopenharmony_ci 21212e5b6d6dSopenharmony_ci CHECK_EQ(42.0, StrToD(" + 42 ", flags, 0.0, &processed, &all_used)); 21222e5b6d6dSopenharmony_ci CHECK(all_used); 21232e5b6d6dSopenharmony_ci 21242e5b6d6dSopenharmony_ci CHECK_EQ(-42.0, StrToD(" - 42 ", flags, 0.0, &processed, &all_used)); 21252e5b6d6dSopenharmony_ci CHECK(all_used); 21262e5b6d6dSopenharmony_ci 21272e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("x", flags, 1.0, &processed, &all_used)); 21282e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 21292e5b6d6dSopenharmony_ci 21302e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" x", flags, 1.0, &processed, &all_used)); 21312e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 21322e5b6d6dSopenharmony_ci 21332e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("42x", flags, 0.0, &processed, &all_used)); 21342e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 21352e5b6d6dSopenharmony_ci 21362e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("42 x", flags, 0.0, &processed, &all_used)); 21372e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 21382e5b6d6dSopenharmony_ci 21392e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" + 42 x", flags, 0.0, &processed, &all_used)); 21402e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 21412e5b6d6dSopenharmony_ci 21422e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" - 42 x", flags, 0.0, &processed, &all_used)); 21432e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 21442e5b6d6dSopenharmony_ci 21452e5b6d6dSopenharmony_ci 21462e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_TRAILING_JUNK; 21472e5b6d6dSopenharmony_ci 21482e5b6d6dSopenharmony_ci CHECK_EQ(123.0, StrToD("123e", flags, 0.0, &processed, &all_used)); 21492e5b6d6dSopenharmony_ci CHECK_EQ(processed, 3); 21502e5b6d6dSopenharmony_ci 21512e5b6d6dSopenharmony_ci CHECK_EQ(123.0, StrToD("123e-", flags, 0.0, &processed, &all_used)); 21522e5b6d6dSopenharmony_ci CHECK_EQ(processed, 3); 21532e5b6d6dSopenharmony_ci 21542e5b6d6dSopenharmony_ci CHECK_EQ(123.0, StrToD("123e-a", flags, 0.0, &processed, &all_used)); 21552e5b6d6dSopenharmony_ci CHECK_EQ(processed, 3); 21562e5b6d6dSopenharmony_ci 21572e5b6d6dSopenharmony_ci 21582e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_LEADING_SPACES | 21592e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN | 21602e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_SPACES | 21612e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_JUNK; 21622e5b6d6dSopenharmony_ci 21632e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("", flags, 0.0, &processed, &all_used)); 21642e5b6d6dSopenharmony_ci CHECK(all_used); 21652e5b6d6dSopenharmony_ci 21662e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD("", flags, 1.0, &processed, &all_used)); 21672e5b6d6dSopenharmony_ci CHECK(all_used); 21682e5b6d6dSopenharmony_ci 21692e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD(" ", flags, 0.0, &processed, &all_used)); 21702e5b6d6dSopenharmony_ci CHECK(all_used); 21712e5b6d6dSopenharmony_ci 21722e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD(" ", flags, 1.0, &processed, &all_used)); 21732e5b6d6dSopenharmony_ci CHECK(all_used); 21742e5b6d6dSopenharmony_ci 21752e5b6d6dSopenharmony_ci CHECK_EQ(42.0, StrToD("42", flags, 0.0, &processed, &all_used)); 21762e5b6d6dSopenharmony_ci CHECK(all_used); 21772e5b6d6dSopenharmony_ci 21782e5b6d6dSopenharmony_ci CHECK_EQ(42.0, StrToD(" + 42 ", flags, 0.0, &processed, &all_used)); 21792e5b6d6dSopenharmony_ci CHECK(all_used); 21802e5b6d6dSopenharmony_ci 21812e5b6d6dSopenharmony_ci CHECK_EQ(-42.0, StrToD(" - 42 ", flags, 0.0, &processed, &all_used)); 21822e5b6d6dSopenharmony_ci CHECK(all_used); 21832e5b6d6dSopenharmony_ci 21842e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("x", flags, 1.0, &processed, &all_used)); 21852e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 21862e5b6d6dSopenharmony_ci 21872e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" x", flags, 1.0, &processed, &all_used)); 21882e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 21892e5b6d6dSopenharmony_ci 21902e5b6d6dSopenharmony_ci CHECK_EQ(42.0, StrToD("42x", flags, 0.0, &processed, &all_used)); 21912e5b6d6dSopenharmony_ci CHECK_EQ(2, processed); 21922e5b6d6dSopenharmony_ci 21932e5b6d6dSopenharmony_ci CHECK_EQ(42.0, StrToD("42 x", flags, 0.0, &processed, &all_used)); 21942e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 21952e5b6d6dSopenharmony_ci 21962e5b6d6dSopenharmony_ci CHECK_EQ(42.0, StrToD(" + 42 x", flags, 0.0, &processed, &all_used)); 21972e5b6d6dSopenharmony_ci CHECK_EQ(6, processed); 21982e5b6d6dSopenharmony_ci 21992e5b6d6dSopenharmony_ci CHECK_EQ(-42.0, StrToD(" - 42 x", flags, 0.0, &processed, &all_used)); 22002e5b6d6dSopenharmony_ci CHECK_EQ(6, processed); 22012e5b6d6dSopenharmony_ci 22022e5b6d6dSopenharmony_ci 22032e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_LEADING_SPACES | 22042e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN | 22052e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_JUNK; 22062e5b6d6dSopenharmony_ci 22072e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("", flags, 0.0, &processed, &all_used)); 22082e5b6d6dSopenharmony_ci CHECK(all_used); 22092e5b6d6dSopenharmony_ci 22102e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD("", flags, 1.0, &processed, &all_used)); 22112e5b6d6dSopenharmony_ci CHECK(all_used); 22122e5b6d6dSopenharmony_ci 22132e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD(" ", flags, 0.0, &processed, &all_used)); 22142e5b6d6dSopenharmony_ci CHECK(all_used); 22152e5b6d6dSopenharmony_ci 22162e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD(" ", flags, 1.0, &processed, &all_used)); 22172e5b6d6dSopenharmony_ci CHECK(all_used); 22182e5b6d6dSopenharmony_ci 22192e5b6d6dSopenharmony_ci CHECK_EQ(42.0, StrToD("42", flags, 0.0, &processed, &all_used)); 22202e5b6d6dSopenharmony_ci CHECK(all_used); 22212e5b6d6dSopenharmony_ci 22222e5b6d6dSopenharmony_ci CHECK_EQ(42.0, StrToD(" + 42 ", flags, 0.0, &processed, &all_used)); 22232e5b6d6dSopenharmony_ci CHECK_EQ(5, processed); 22242e5b6d6dSopenharmony_ci 22252e5b6d6dSopenharmony_ci CHECK_EQ(-42.0, StrToD(" - 42 ", flags, 0.0, &processed, &all_used)); 22262e5b6d6dSopenharmony_ci CHECK_EQ(5, processed); 22272e5b6d6dSopenharmony_ci 22282e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("x", flags, 1.0, &processed, &all_used)); 22292e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 22302e5b6d6dSopenharmony_ci 22312e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" x", flags, 1.0, &processed, &all_used)); 22322e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 22332e5b6d6dSopenharmony_ci 22342e5b6d6dSopenharmony_ci CHECK_EQ(42.0, StrToD("42x", flags, 0.0, &processed, &all_used)); 22352e5b6d6dSopenharmony_ci CHECK_EQ(2, processed); 22362e5b6d6dSopenharmony_ci 22372e5b6d6dSopenharmony_ci CHECK_EQ(42.0, StrToD("42 x", flags, 0.0, &processed, &all_used)); 22382e5b6d6dSopenharmony_ci CHECK_EQ(2, processed); 22392e5b6d6dSopenharmony_ci 22402e5b6d6dSopenharmony_ci CHECK_EQ(42.0, StrToD(" + 42 x", flags, 0.0, &processed, &all_used)); 22412e5b6d6dSopenharmony_ci CHECK_EQ(5, processed); 22422e5b6d6dSopenharmony_ci 22432e5b6d6dSopenharmony_ci CHECK_EQ(-42.0, StrToD(" - 42 x", flags, 0.0, &processed, &all_used)); 22442e5b6d6dSopenharmony_ci CHECK_EQ(5, processed); 22452e5b6d6dSopenharmony_ci 22462e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_LEADING_SPACES | 22472e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_JUNK; 22482e5b6d6dSopenharmony_ci 22492e5b6d6dSopenharmony_ci CHECK_EQ(42.0, StrToD(" +42 ", flags, 0.0, &processed, &all_used)); 22502e5b6d6dSopenharmony_ci CHECK_EQ(4, processed); 22512e5b6d6dSopenharmony_ci 22522e5b6d6dSopenharmony_ci CHECK_EQ(-42.0, StrToD(" -42 ", flags, 0.0, &processed, &all_used)); 22532e5b6d6dSopenharmony_ci CHECK_EQ(4, processed); 22542e5b6d6dSopenharmony_ci 22552e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" + 42 ", flags, 0.0, &processed, &all_used)); 22562e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 22572e5b6d6dSopenharmony_ci 22582e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" - 42 ", flags, 0.0, &processed, &all_used)); 22592e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 22602e5b6d6dSopenharmony_ci 22612e5b6d6dSopenharmony_ci 22622e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::NO_FLAGS; 22632e5b6d6dSopenharmony_ci 22642e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("", flags, 0.0, &processed, &all_used)); 22652e5b6d6dSopenharmony_ci CHECK(all_used); 22662e5b6d6dSopenharmony_ci 22672e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD("", flags, 1.0, &processed, &all_used)); 22682e5b6d6dSopenharmony_ci CHECK(all_used); 22692e5b6d6dSopenharmony_ci 22702e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" ", flags, 0.0, &processed, &all_used)); 22712e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 22722e5b6d6dSopenharmony_ci 22732e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" ", flags, 1.0, &processed, &all_used)); 22742e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 22752e5b6d6dSopenharmony_ci 22762e5b6d6dSopenharmony_ci CHECK_EQ(42.0, StrToD("42", flags, 0.0, &processed, &all_used)); 22772e5b6d6dSopenharmony_ci CHECK(all_used); 22782e5b6d6dSopenharmony_ci 22792e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" + 42 ", flags, 0.0, &processed, &all_used)); 22802e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 22812e5b6d6dSopenharmony_ci 22822e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" - 42 ", flags, 0.0, &processed, &all_used)); 22832e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 22842e5b6d6dSopenharmony_ci 22852e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("x", flags, 1.0, &processed, &all_used)); 22862e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 22872e5b6d6dSopenharmony_ci 22882e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" x", flags, 1.0, &processed, &all_used)); 22892e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 22902e5b6d6dSopenharmony_ci 22912e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("42x", flags, 0.0, &processed, &all_used)); 22922e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 22932e5b6d6dSopenharmony_ci 22942e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("42 x", flags, 0.0, &processed, &all_used)); 22952e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 22962e5b6d6dSopenharmony_ci 22972e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" + 42 x", flags, 0.0, &processed, &all_used)); 22982e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 22992e5b6d6dSopenharmony_ci 23002e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" - 42 x", flags, 0.0, &processed, &all_used)); 23012e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 23022e5b6d6dSopenharmony_ci 23032e5b6d6dSopenharmony_ci 23042e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_LEADING_SPACES; 23052e5b6d6dSopenharmony_ci 23062e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD(" ", flags, 0.0, &processed, &all_used)); 23072e5b6d6dSopenharmony_ci CHECK(all_used); 23082e5b6d6dSopenharmony_ci 23092e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD(" ", flags, 1.0, &processed, &all_used)); 23102e5b6d6dSopenharmony_ci CHECK(all_used); 23112e5b6d6dSopenharmony_ci 23122e5b6d6dSopenharmony_ci CHECK_EQ(42.0, StrToD(" 42", flags, 0.0, &processed, &all_used)); 23132e5b6d6dSopenharmony_ci CHECK(all_used); 23142e5b6d6dSopenharmony_ci 23152e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("42 ", flags, 0.0, &processed, &all_used)); 23162e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 23172e5b6d6dSopenharmony_ci 23182e5b6d6dSopenharmony_ci 23192e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_TRAILING_SPACES; 23202e5b6d6dSopenharmony_ci 23212e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD(" ", flags, 0.0, &processed, &all_used)); 23222e5b6d6dSopenharmony_ci CHECK(all_used); 23232e5b6d6dSopenharmony_ci 23242e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD(" ", flags, 1.0, &processed, &all_used)); 23252e5b6d6dSopenharmony_ci CHECK(all_used); 23262e5b6d6dSopenharmony_ci 23272e5b6d6dSopenharmony_ci CHECK_EQ(42.0, StrToD("42 ", flags, 0.0, &processed, &all_used)); 23282e5b6d6dSopenharmony_ci CHECK(all_used); 23292e5b6d6dSopenharmony_ci 23302e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 42", flags, 0.0, &processed, &all_used)); 23312e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 23322e5b6d6dSopenharmony_ci} 23332e5b6d6dSopenharmony_ci 23342e5b6d6dSopenharmony_ci 23352e5b6d6dSopenharmony_ciTEST(StringToDoubleEmptyString) { 23362e5b6d6dSopenharmony_ci int flags; 23372e5b6d6dSopenharmony_ci int processed; 23382e5b6d6dSopenharmony_ci bool all_used; 23392e5b6d6dSopenharmony_ci 23402e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::NO_FLAGS; 23412e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("", flags, 0.0, &processed, &all_used)); 23422e5b6d6dSopenharmony_ci CHECK(all_used); 23432e5b6d6dSopenharmony_ci 23442e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD("", flags, 1.0, &processed, &all_used)); 23452e5b6d6dSopenharmony_ci CHECK(all_used); 23462e5b6d6dSopenharmony_ci 23472e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("", flags, Double::NaN(), 23482e5b6d6dSopenharmony_ci &processed, &all_used)); 23492e5b6d6dSopenharmony_ci CHECK(all_used); 23502e5b6d6dSopenharmony_ci 23512e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" ", flags, 0.0, &processed, &all_used)); 23522e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 23532e5b6d6dSopenharmony_ci 23542e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" ", flags, 1.0, &processed, &all_used)); 23552e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 23562e5b6d6dSopenharmony_ci 23572e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" ", flags, Double::NaN(), 23582e5b6d6dSopenharmony_ci &processed, &all_used)); 23592e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 23602e5b6d6dSopenharmony_ci 23612e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN; 23622e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("", flags, 0.0, &processed, &all_used)); 23632e5b6d6dSopenharmony_ci CHECK(all_used); 23642e5b6d6dSopenharmony_ci 23652e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD("", flags, 1.0, &processed, &all_used)); 23662e5b6d6dSopenharmony_ci CHECK(all_used); 23672e5b6d6dSopenharmony_ci 23682e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("", flags, Double::NaN(), 23692e5b6d6dSopenharmony_ci &processed, &all_used)); 23702e5b6d6dSopenharmony_ci CHECK(all_used); 23712e5b6d6dSopenharmony_ci 23722e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" ", flags, 0.0, &processed, &all_used)); 23732e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 23742e5b6d6dSopenharmony_ci 23752e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" ", flags, 1.0, &processed, &all_used)); 23762e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 23772e5b6d6dSopenharmony_ci 23782e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" ", flags, Double::NaN(), 23792e5b6d6dSopenharmony_ci &processed, &all_used)); 23802e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 23812e5b6d6dSopenharmony_ci 23822e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_LEADING_SPACES; 23832e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("", flags, 0.0, &processed, &all_used)); 23842e5b6d6dSopenharmony_ci CHECK(all_used); 23852e5b6d6dSopenharmony_ci 23862e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD("", flags, 1.0, &processed, &all_used)); 23872e5b6d6dSopenharmony_ci CHECK(all_used); 23882e5b6d6dSopenharmony_ci 23892e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("", flags, Double::NaN(), 23902e5b6d6dSopenharmony_ci &processed, &all_used)); 23912e5b6d6dSopenharmony_ci CHECK(all_used); 23922e5b6d6dSopenharmony_ci 23932e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD(" ", flags, 0.0, &processed, &all_used)); 23942e5b6d6dSopenharmony_ci CHECK(all_used); 23952e5b6d6dSopenharmony_ci 23962e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD(" ", flags, 1.0, &processed, &all_used)); 23972e5b6d6dSopenharmony_ci CHECK(all_used); 23982e5b6d6dSopenharmony_ci 23992e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" ", flags, Double::NaN(), 24002e5b6d6dSopenharmony_ci &processed, &all_used)); 24012e5b6d6dSopenharmony_ci CHECK(all_used); 24022e5b6d6dSopenharmony_ci 24032e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_TRAILING_SPACES; 24042e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("", flags, 0.0, &processed, &all_used)); 24052e5b6d6dSopenharmony_ci CHECK(all_used); 24062e5b6d6dSopenharmony_ci 24072e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD("", flags, 1.0, &processed, &all_used)); 24082e5b6d6dSopenharmony_ci CHECK(all_used); 24092e5b6d6dSopenharmony_ci 24102e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("", flags, Double::NaN(), 24112e5b6d6dSopenharmony_ci &processed, &all_used)); 24122e5b6d6dSopenharmony_ci CHECK(all_used); 24132e5b6d6dSopenharmony_ci 24142e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD(" ", flags, 0.0, &processed, &all_used)); 24152e5b6d6dSopenharmony_ci CHECK(all_used); 24162e5b6d6dSopenharmony_ci 24172e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD(" ", flags, 1.0, &processed, &all_used)); 24182e5b6d6dSopenharmony_ci CHECK(all_used); 24192e5b6d6dSopenharmony_ci 24202e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" ", flags, Double::NaN(), 24212e5b6d6dSopenharmony_ci &processed, &all_used)); 24222e5b6d6dSopenharmony_ci CHECK(all_used); 24232e5b6d6dSopenharmony_ci 24242e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_TRAILING_JUNK; 24252e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("", flags, 0.0, &processed, &all_used)); 24262e5b6d6dSopenharmony_ci CHECK(all_used); 24272e5b6d6dSopenharmony_ci 24282e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD("", flags, 1.0, &processed, &all_used)); 24292e5b6d6dSopenharmony_ci CHECK(all_used); 24302e5b6d6dSopenharmony_ci 24312e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("", flags, Double::NaN(), 24322e5b6d6dSopenharmony_ci &processed, &all_used)); 24332e5b6d6dSopenharmony_ci CHECK(all_used); 24342e5b6d6dSopenharmony_ci 24352e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" ", flags, 0.0, &processed, &all_used)); 24362e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 24372e5b6d6dSopenharmony_ci 24382e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" ", flags, 1.0, &processed, &all_used)); 24392e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 24402e5b6d6dSopenharmony_ci 24412e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" ", flags, Double::NaN(), 24422e5b6d6dSopenharmony_ci &processed, &all_used)); 24432e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 24442e5b6d6dSopenharmony_ci 24452e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("x", flags, 0.0, &processed, &all_used)); 24462e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 24472e5b6d6dSopenharmony_ci 24482e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" x", flags, 0.0, &processed, &all_used)); 24492e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 24502e5b6d6dSopenharmony_ci} 24512e5b6d6dSopenharmony_ci 24522e5b6d6dSopenharmony_ci 24532e5b6d6dSopenharmony_ciTEST(StringToDoubleHexString) { 24542e5b6d6dSopenharmony_ci int flags; 24552e5b6d6dSopenharmony_ci int processed; 24562e5b6d6dSopenharmony_ci bool all_used; 24572e5b6d6dSopenharmony_ci 24582e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_HEX | 24592e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_LEADING_SPACES | 24602e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_SPACES | 24612e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN; 24622e5b6d6dSopenharmony_ci 24632e5b6d6dSopenharmony_ci CHECK_EQ(18.0, StrToD("0x12", flags, 0.0, &processed, &all_used)); 24642e5b6d6dSopenharmony_ci CHECK(all_used); 24652e5b6d6dSopenharmony_ci 24662e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("0x0", flags, 1.0, &processed, &all_used)); 24672e5b6d6dSopenharmony_ci CHECK(all_used); 24682e5b6d6dSopenharmony_ci 24692e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0x123456789), 24702e5b6d6dSopenharmony_ci StrToD("0x123456789", flags, Double::NaN(), &processed, &all_used)); 24712e5b6d6dSopenharmony_ci CHECK(all_used); 24722e5b6d6dSopenharmony_ci 24732e5b6d6dSopenharmony_ci CHECK_EQ(18.0, StrToD(" 0x12 ", flags, 0.0, &processed, &all_used)); 24742e5b6d6dSopenharmony_ci CHECK(all_used); 24752e5b6d6dSopenharmony_ci 24762e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD(" 0x0 ", flags, 1.0, &processed, &all_used)); 24772e5b6d6dSopenharmony_ci CHECK(all_used); 24782e5b6d6dSopenharmony_ci 24792e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0x123456789), 24802e5b6d6dSopenharmony_ci StrToD(" 0x123456789 ", flags, Double::NaN(), 24812e5b6d6dSopenharmony_ci &processed, &all_used)); 24822e5b6d6dSopenharmony_ci CHECK(all_used); 24832e5b6d6dSopenharmony_ci 24842e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0xabcdef), 24852e5b6d6dSopenharmony_ci StrToD("0xabcdef", flags, 0.0, &processed, &all_used)); 24862e5b6d6dSopenharmony_ci CHECK(all_used); 24872e5b6d6dSopenharmony_ci 24882e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0xabcdef), 24892e5b6d6dSopenharmony_ci StrToD("0xABCDEF", flags, 0.0, &processed, &all_used)); 24902e5b6d6dSopenharmony_ci CHECK(all_used); 24912e5b6d6dSopenharmony_ci 24922e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0xabcdef), 24932e5b6d6dSopenharmony_ci StrToD(" 0xabcdef ", flags, 0.0, &processed, &all_used)); 24942e5b6d6dSopenharmony_ci CHECK(all_used); 24952e5b6d6dSopenharmony_ci 24962e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0xabcdef), 24972e5b6d6dSopenharmony_ci StrToD(" 0xABCDEF ", flags, 0.0, &processed, &all_used)); 24982e5b6d6dSopenharmony_ci CHECK(all_used); 24992e5b6d6dSopenharmony_ci 25002e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" ", flags, Double::NaN(), 25012e5b6d6dSopenharmony_ci &processed, &all_used)); 25022e5b6d6dSopenharmony_ci CHECK(all_used); 25032e5b6d6dSopenharmony_ci 25042e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("0x", flags, 0.0, 25052e5b6d6dSopenharmony_ci &processed, &all_used)); 25062e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 25072e5b6d6dSopenharmony_ci 25082e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 0x ", flags, 0.0, 25092e5b6d6dSopenharmony_ci &processed, &all_used)); 25102e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 25112e5b6d6dSopenharmony_ci 25122e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 0x 3", flags, 0.0, 25132e5b6d6dSopenharmony_ci &processed, &all_used)); 25142e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 25152e5b6d6dSopenharmony_ci 25162e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("0x3g", flags, 0.0, 25172e5b6d6dSopenharmony_ci &processed, &all_used)); 25182e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 25192e5b6d6dSopenharmony_ci 25202e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("0x3.23", flags, 0.0, 25212e5b6d6dSopenharmony_ci &processed, &all_used)); 25222e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 25232e5b6d6dSopenharmony_ci 25242e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("x3", flags, 0.0, 25252e5b6d6dSopenharmony_ci &processed, &all_used)); 25262e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 25272e5b6d6dSopenharmony_ci 25282e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("0x3 foo", flags, 0.0, 25292e5b6d6dSopenharmony_ci &processed, &all_used)); 25302e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 25312e5b6d6dSopenharmony_ci 25322e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 0x3 foo", flags, 0.0, 25332e5b6d6dSopenharmony_ci &processed, &all_used)); 25342e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 25352e5b6d6dSopenharmony_ci 25362e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("+ 0x3 foo", flags, 0.0, 25372e5b6d6dSopenharmony_ci &processed, &all_used)); 25382e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 25392e5b6d6dSopenharmony_ci 25402e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("+", flags, 0.0, &processed, &all_used)); 25412e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 25422e5b6d6dSopenharmony_ci 25432e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("-", flags, 0.0, &processed, &all_used)); 25442e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 25452e5b6d6dSopenharmony_ci 25462e5b6d6dSopenharmony_ci CHECK_EQ(-5.0, StrToD("-0x5", flags, 0.0, &processed, &all_used)); 25472e5b6d6dSopenharmony_ci CHECK(all_used); 25482e5b6d6dSopenharmony_ci 25492e5b6d6dSopenharmony_ci CHECK_EQ(-5.0, StrToD(" - 0x5 ", flags, 0.0, &processed, &all_used)); 25502e5b6d6dSopenharmony_ci CHECK(all_used); 25512e5b6d6dSopenharmony_ci 25522e5b6d6dSopenharmony_ci CHECK_EQ(5.0, StrToD(" + 0x5 ", flags, 0.0, &processed, &all_used)); 25532e5b6d6dSopenharmony_ci CHECK(all_used); 25542e5b6d6dSopenharmony_ci 25552e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("- -0x5", flags, 0.0, &processed, &all_used)); 25562e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 25572e5b6d6dSopenharmony_ci 25582e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("- +0x5", flags, 0.0, &processed, &all_used)); 25592e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 25602e5b6d6dSopenharmony_ci 25612e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("+ +0x5", flags, 0.0, &processed, &all_used)); 25622e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 25632e5b6d6dSopenharmony_ci 25642e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_HEX; 25652e5b6d6dSopenharmony_ci 25662e5b6d6dSopenharmony_ci CHECK_EQ(18.0, StrToD("0x12", flags, 0.0, &processed, &all_used)); 25672e5b6d6dSopenharmony_ci CHECK(all_used); 25682e5b6d6dSopenharmony_ci 25692e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("0x0", flags, 1.0, &processed, &all_used)); 25702e5b6d6dSopenharmony_ci CHECK(all_used); 25712e5b6d6dSopenharmony_ci 25722e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0x123456789), 25732e5b6d6dSopenharmony_ci StrToD("0x123456789", flags, Double::NaN(), &processed, &all_used)); 25742e5b6d6dSopenharmony_ci CHECK(all_used); 25752e5b6d6dSopenharmony_ci 25762e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 0x12 ", flags, 0.0, &processed, &all_used)); 25772e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 25782e5b6d6dSopenharmony_ci 25792e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 0x0 ", flags, 1.0, &processed, &all_used)); 25802e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 25812e5b6d6dSopenharmony_ci 25822e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 0x123456789 ", flags, Double::NaN(), 25832e5b6d6dSopenharmony_ci &processed, &all_used)); 25842e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 25852e5b6d6dSopenharmony_ci 25862e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0xabcdef), 25872e5b6d6dSopenharmony_ci StrToD("0xabcdef", flags, 0.0, &processed, &all_used)); 25882e5b6d6dSopenharmony_ci CHECK(all_used); 25892e5b6d6dSopenharmony_ci 25902e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0xabcdef), 25912e5b6d6dSopenharmony_ci StrToD("0xABCDEF", flags, 0.0, &processed, &all_used)); 25922e5b6d6dSopenharmony_ci CHECK(all_used); 25932e5b6d6dSopenharmony_ci 25942e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 25952e5b6d6dSopenharmony_ci StrToD(" 0xabcdef ", flags, 0.0, &processed, &all_used)); 25962e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 25972e5b6d6dSopenharmony_ci 25982e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 25992e5b6d6dSopenharmony_ci StrToD(" 0xABCDEF ", flags, 0.0, &processed, &all_used)); 26002e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 26012e5b6d6dSopenharmony_ci 26022e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 26032e5b6d6dSopenharmony_ci StrToD(" ", flags, 0.0, &processed, &all_used)); 26042e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 26052e5b6d6dSopenharmony_ci 26062e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("0x", flags, 0.0, 26072e5b6d6dSopenharmony_ci &processed, &all_used)); 26082e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 26092e5b6d6dSopenharmony_ci 26102e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 0x ", flags, 0.0, 26112e5b6d6dSopenharmony_ci &processed, &all_used)); 26122e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 26132e5b6d6dSopenharmony_ci 26142e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 0x 3", flags, 0.0, 26152e5b6d6dSopenharmony_ci &processed, &all_used)); 26162e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 26172e5b6d6dSopenharmony_ci 26182e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("0x3g", flags, 0.0, 26192e5b6d6dSopenharmony_ci &processed, &all_used)); 26202e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 26212e5b6d6dSopenharmony_ci 26222e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("0x3.23", flags, 0.0, 26232e5b6d6dSopenharmony_ci &processed, &all_used)); 26242e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 26252e5b6d6dSopenharmony_ci 26262e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("x3", flags, 0.0, 26272e5b6d6dSopenharmony_ci &processed, &all_used)); 26282e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 26292e5b6d6dSopenharmony_ci 26302e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("+ 0x3 foo", flags, 0.0, 26312e5b6d6dSopenharmony_ci &processed, &all_used)); 26322e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 26332e5b6d6dSopenharmony_ci 26342e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("+", flags, 0.0, &processed, &all_used)); 26352e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 26362e5b6d6dSopenharmony_ci 26372e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("-", flags, 0.0, &processed, &all_used)); 26382e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 26392e5b6d6dSopenharmony_ci 26402e5b6d6dSopenharmony_ci CHECK_EQ(-5.0, StrToD("-0x5", flags, 0.0, &processed, &all_used)); 26412e5b6d6dSopenharmony_ci CHECK(all_used); 26422e5b6d6dSopenharmony_ci 26432e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" - 0x5 ", flags, 0.0, &processed, &all_used)); 26442e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 26452e5b6d6dSopenharmony_ci 26462e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" + 0x5 ", flags, 0.0, &processed, &all_used)); 26472e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 26482e5b6d6dSopenharmony_ci 26492e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("- -0x5", flags, 0.0, &processed, &all_used)); 26502e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 26512e5b6d6dSopenharmony_ci 26522e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("- +0x5", flags, 0.0, &processed, &all_used)); 26532e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 26542e5b6d6dSopenharmony_ci 26552e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("+ +0x5", flags, 0.0, &processed, &all_used)); 26562e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 26572e5b6d6dSopenharmony_ci 26582e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_TRAILING_JUNK | 26592e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_HEX; 26602e5b6d6dSopenharmony_ci 26612e5b6d6dSopenharmony_ci CHECK_EQ(18.0, StrToD("0x12", flags, 0.0, &processed, &all_used)); 26622e5b6d6dSopenharmony_ci CHECK(all_used); 26632e5b6d6dSopenharmony_ci 26642e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("0x0", flags, 1.0, &processed, &all_used)); 26652e5b6d6dSopenharmony_ci CHECK(all_used); 26662e5b6d6dSopenharmony_ci 26672e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0x123456789), 26682e5b6d6dSopenharmony_ci StrToD("0x123456789", flags, Double::NaN(), &processed, &all_used)); 26692e5b6d6dSopenharmony_ci CHECK(all_used); 26702e5b6d6dSopenharmony_ci 26712e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 0x12 ", flags, 0.0, &processed, &all_used)); 26722e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 26732e5b6d6dSopenharmony_ci 26742e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 0x0 ", flags, 1.0, &processed, &all_used)); 26752e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 26762e5b6d6dSopenharmony_ci 26772e5b6d6dSopenharmony_ci CHECK_EQ(18.0, StrToD("0x12 ", flags, 0.0, &processed, &all_used)); 26782e5b6d6dSopenharmony_ci CHECK_EQ(4, processed); 26792e5b6d6dSopenharmony_ci 26802e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("0x0 ", flags, 1.0, &processed, &all_used)); 26812e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 26822e5b6d6dSopenharmony_ci 26832e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 26842e5b6d6dSopenharmony_ci StrToD(" 0x123456789 ", flags, Double::NaN(), 26852e5b6d6dSopenharmony_ci &processed, &all_used)); 26862e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 26872e5b6d6dSopenharmony_ci 26882e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0xabcdef), 26892e5b6d6dSopenharmony_ci StrToD("0xabcdef", flags, 0.0, &processed, &all_used)); 26902e5b6d6dSopenharmony_ci CHECK(all_used); 26912e5b6d6dSopenharmony_ci 26922e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0xabcdef), 26932e5b6d6dSopenharmony_ci StrToD("0xABCDEF", flags, 0.0, &processed, &all_used)); 26942e5b6d6dSopenharmony_ci CHECK(all_used); 26952e5b6d6dSopenharmony_ci 26962e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 26972e5b6d6dSopenharmony_ci StrToD(" 0xabcdef ", flags, 0.0, &processed, &all_used)); 26982e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 26992e5b6d6dSopenharmony_ci 27002e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 27012e5b6d6dSopenharmony_ci StrToD(" 0xABCDEF ", flags, 0.0, &processed, &all_used)); 27022e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 27032e5b6d6dSopenharmony_ci 27042e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0xabcdef), 27052e5b6d6dSopenharmony_ci StrToD("0xabcdef ", flags, 0.0, &processed, &all_used)); 27062e5b6d6dSopenharmony_ci CHECK_EQ(8, processed); 27072e5b6d6dSopenharmony_ci 27082e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0xabcdef), 27092e5b6d6dSopenharmony_ci StrToD("0xABCDEF ", flags, 0.0, &processed, &all_used)); 27102e5b6d6dSopenharmony_ci CHECK_EQ(8, processed); 27112e5b6d6dSopenharmony_ci 27122e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 27132e5b6d6dSopenharmony_ci StrToD(" 0xabcdef", flags, 0.0, &processed, &all_used)); 27142e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 27152e5b6d6dSopenharmony_ci 27162e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 27172e5b6d6dSopenharmony_ci StrToD(" 0xABCDEF", flags, 0.0, &processed, &all_used)); 27182e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 27192e5b6d6dSopenharmony_ci 27202e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" ", flags, 0.0, &processed, &all_used)); 27212e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 27222e5b6d6dSopenharmony_ci 27232e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("0x", flags, 0.0, 27242e5b6d6dSopenharmony_ci &processed, &all_used)); 27252e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 27262e5b6d6dSopenharmony_ci 27272e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 0x ", flags, 0.0, 27282e5b6d6dSopenharmony_ci &processed, &all_used)); 27292e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 27302e5b6d6dSopenharmony_ci 27312e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 0x 3", flags, 0.0, 27322e5b6d6dSopenharmony_ci &processed, &all_used)); 27332e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 27342e5b6d6dSopenharmony_ci 27352e5b6d6dSopenharmony_ci CHECK_EQ(3.0, StrToD("0x3g", flags, 0.0, &processed, &all_used)); 27362e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 27372e5b6d6dSopenharmony_ci 27382e5b6d6dSopenharmony_ci CHECK_EQ(3.0, StrToD("0x3.234", flags, 0.0, &processed, &all_used)); 27392e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 27402e5b6d6dSopenharmony_ci 27412e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 0x3g", flags, 0.0, &processed, &all_used)); 27422e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 27432e5b6d6dSopenharmony_ci 27442e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 27452e5b6d6dSopenharmony_ci StrToD(" 0x3.234", flags, 0.0, &processed, &all_used)); 27462e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 27472e5b6d6dSopenharmony_ci 27482e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("x3", flags, 0.0, 27492e5b6d6dSopenharmony_ci &processed, &all_used)); 27502e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 27512e5b6d6dSopenharmony_ci 27522e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("+ 0x3 foo", flags, 0.0, 27532e5b6d6dSopenharmony_ci &processed, &all_used)); 27542e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 27552e5b6d6dSopenharmony_ci 27562e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("+", flags, 0.0, &processed, &all_used)); 27572e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 27582e5b6d6dSopenharmony_ci 27592e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("-", flags, 0.0, &processed, &all_used)); 27602e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 27612e5b6d6dSopenharmony_ci 27622e5b6d6dSopenharmony_ci CHECK_EQ(-5.0, StrToD("-0x5", flags, 0.0, &processed, &all_used)); 27632e5b6d6dSopenharmony_ci CHECK(all_used); 27642e5b6d6dSopenharmony_ci 27652e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" - 0x5 ", flags, 0.0, &processed, &all_used)); 27662e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 27672e5b6d6dSopenharmony_ci 27682e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" + 0x5 ", flags, 0.0, &processed, &all_used)); 27692e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 27702e5b6d6dSopenharmony_ci 27712e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("- -0x5", flags, 0.0, &processed, &all_used)); 27722e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 27732e5b6d6dSopenharmony_ci 27742e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("- +0x5", flags, 0.0, &processed, &all_used)); 27752e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 27762e5b6d6dSopenharmony_ci 27772e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("+ +0x5", flags, 0.0, &processed, &all_used)); 27782e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 27792e5b6d6dSopenharmony_ci 27802e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_TRAILING_JUNK | 27812e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_LEADING_SPACES | 27822e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_SPACES | 27832e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN | 27842e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_HEX; 27852e5b6d6dSopenharmony_ci 27862e5b6d6dSopenharmony_ci CHECK_EQ(18.0, StrToD("0x12", flags, 0.0, &processed, &all_used)); 27872e5b6d6dSopenharmony_ci CHECK(all_used); 27882e5b6d6dSopenharmony_ci 27892e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("0x0", flags, 1.0, &processed, &all_used)); 27902e5b6d6dSopenharmony_ci CHECK(all_used); 27912e5b6d6dSopenharmony_ci 27922e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0x123456789), 27932e5b6d6dSopenharmony_ci StrToD("0x123456789", flags, Double::NaN(), &processed, &all_used)); 27942e5b6d6dSopenharmony_ci CHECK(all_used); 27952e5b6d6dSopenharmony_ci 27962e5b6d6dSopenharmony_ci CHECK_EQ(18.0, StrToD(" 0x12 ", flags, 0.0, &processed, &all_used)); 27972e5b6d6dSopenharmony_ci CHECK(all_used); 27982e5b6d6dSopenharmony_ci 27992e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD(" 0x0 ", flags, 1.0, &processed, &all_used)); 28002e5b6d6dSopenharmony_ci CHECK(all_used); 28012e5b6d6dSopenharmony_ci 28022e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0x123456789), 28032e5b6d6dSopenharmony_ci StrToD(" 0x123456789 ", flags, Double::NaN(), 28042e5b6d6dSopenharmony_ci &processed, &all_used)); 28052e5b6d6dSopenharmony_ci CHECK(all_used); 28062e5b6d6dSopenharmony_ci 28072e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0xabcdef), 28082e5b6d6dSopenharmony_ci StrToD("0xabcdef", flags, 0.0, &processed, &all_used)); 28092e5b6d6dSopenharmony_ci CHECK(all_used); 28102e5b6d6dSopenharmony_ci 28112e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0xabcdef), 28122e5b6d6dSopenharmony_ci StrToD("0xABCDEF", flags, 0.0, &processed, &all_used)); 28132e5b6d6dSopenharmony_ci CHECK(all_used); 28142e5b6d6dSopenharmony_ci 28152e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0xabcdef), 28162e5b6d6dSopenharmony_ci StrToD(" 0xabcdef ", flags, 0.0, &processed, &all_used)); 28172e5b6d6dSopenharmony_ci CHECK(all_used); 28182e5b6d6dSopenharmony_ci 28192e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0xabcdef), 28202e5b6d6dSopenharmony_ci StrToD(" 0xABCDEF ", flags, 0.0, &processed, &all_used)); 28212e5b6d6dSopenharmony_ci CHECK(all_used); 28222e5b6d6dSopenharmony_ci 28232e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0xabc), 28242e5b6d6dSopenharmony_ci StrToD(" 0xabc def ", flags, 0.0, &processed, &all_used)); 28252e5b6d6dSopenharmony_ci CHECK_EQ(7, processed); 28262e5b6d6dSopenharmony_ci 28272e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0xabc), 28282e5b6d6dSopenharmony_ci StrToD(" 0xABC DEF ", flags, 0.0, &processed, &all_used)); 28292e5b6d6dSopenharmony_ci CHECK_EQ(7, processed); 28302e5b6d6dSopenharmony_ci 28312e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0x12), 28322e5b6d6dSopenharmony_ci StrToD(" 0x12 ", flags, 0.0, &processed, &all_used)); 28332e5b6d6dSopenharmony_ci CHECK(all_used); 28342e5b6d6dSopenharmony_ci 28352e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD(" 0x0 ", flags, 1.0, &processed, &all_used)); 28362e5b6d6dSopenharmony_ci CHECK(all_used); 28372e5b6d6dSopenharmony_ci 28382e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0x123456789), 28392e5b6d6dSopenharmony_ci StrToD(" 0x123456789 ", flags, Double::NaN(), 28402e5b6d6dSopenharmony_ci &processed, &all_used)); 28412e5b6d6dSopenharmony_ci CHECK(all_used); 28422e5b6d6dSopenharmony_ci 28432e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" ", flags, Double::NaN(), 28442e5b6d6dSopenharmony_ci &processed, &all_used)); 28452e5b6d6dSopenharmony_ci CHECK(all_used); 28462e5b6d6dSopenharmony_ci 28472e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("0x", flags, 0.0, 28482e5b6d6dSopenharmony_ci &processed, &all_used)); 28492e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 28502e5b6d6dSopenharmony_ci 28512e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 0x ", flags, 0.0, 28522e5b6d6dSopenharmony_ci &processed, &all_used)); 28532e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 28542e5b6d6dSopenharmony_ci 28552e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 0x 3", flags, 0.0, 28562e5b6d6dSopenharmony_ci &processed, &all_used)); 28572e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 28582e5b6d6dSopenharmony_ci 28592e5b6d6dSopenharmony_ci CHECK_EQ((double)0x3, StrToD("0x3g", flags, 0.0, &processed, &all_used)); 28602e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 28612e5b6d6dSopenharmony_ci 28622e5b6d6dSopenharmony_ci CHECK_EQ((double)0x3, StrToD("0x3.234", flags, 0.0, &processed, &all_used)); 28632e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 28642e5b6d6dSopenharmony_ci 28652e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("x3", flags, 0.0, 28662e5b6d6dSopenharmony_ci &processed, &all_used)); 28672e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 28682e5b6d6dSopenharmony_ci 28692e5b6d6dSopenharmony_ci CHECK_EQ(-5.634002666912405e+27, StrToD("-0x123456789012345678901234", 28702e5b6d6dSopenharmony_ci flags, 0.0, 28712e5b6d6dSopenharmony_ci &processed, &all_used)); 28722e5b6d6dSopenharmony_ci CHECK(all_used); 28732e5b6d6dSopenharmony_ci 28742e5b6d6dSopenharmony_ci CHECK_EQ(72057594037927940.0, StrToD("0x100000000000001", flags, 0.0, 28752e5b6d6dSopenharmony_ci &processed, &all_used)); 28762e5b6d6dSopenharmony_ci CHECK(all_used); 28772e5b6d6dSopenharmony_ci 28782e5b6d6dSopenharmony_ci CHECK_EQ(72057594037927940.0, StrToD("0x100000000000000", flags, 0.0, 28792e5b6d6dSopenharmony_ci &processed, &all_used)); 28802e5b6d6dSopenharmony_ci CHECK(all_used); 28812e5b6d6dSopenharmony_ci 28822e5b6d6dSopenharmony_ci CHECK_EQ(295147905179352830000.0, StrToD("0x100000000000000001", flags, 0.0, 28832e5b6d6dSopenharmony_ci &processed, &all_used)); 28842e5b6d6dSopenharmony_ci CHECK(all_used); 28852e5b6d6dSopenharmony_ci 28862e5b6d6dSopenharmony_ci CHECK_EQ(295147905179352830000.0, StrToD("0x100000000000000000", flags, 0.0, 28872e5b6d6dSopenharmony_ci &processed, &all_used)); 28882e5b6d6dSopenharmony_ci CHECK(all_used); 28892e5b6d6dSopenharmony_ci 28902e5b6d6dSopenharmony_ci CHECK_EQ(295147905179352900000.0, StrToD("0x100000000000008001", flags, 0.0, 28912e5b6d6dSopenharmony_ci &processed, &all_used)); 28922e5b6d6dSopenharmony_ci CHECK(all_used); 28932e5b6d6dSopenharmony_ci 28942e5b6d6dSopenharmony_ci CHECK_EQ(295147905179352830000.0, StrToD("0x100000000000008000", flags, 0.0, 28952e5b6d6dSopenharmony_ci &processed, &all_used)); 28962e5b6d6dSopenharmony_ci CHECK(all_used); 28972e5b6d6dSopenharmony_ci 28982e5b6d6dSopenharmony_ci CHECK_EQ(295147905179352960000.0, StrToD("0x100000000000018001", flags, 0.0, 28992e5b6d6dSopenharmony_ci &processed, &all_used)); 29002e5b6d6dSopenharmony_ci CHECK(all_used); 29012e5b6d6dSopenharmony_ci 29022e5b6d6dSopenharmony_ci CHECK_EQ(295147905179352960000.0, StrToD("0x100000000000018000", flags, 0.0, 29032e5b6d6dSopenharmony_ci &processed, &all_used)); 29042e5b6d6dSopenharmony_ci CHECK(all_used); 29052e5b6d6dSopenharmony_ci 29062e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_HEX_FLOATS; 29072e5b6d6dSopenharmony_ci 29082e5b6d6dSopenharmony_ci CHECK_EQ(3.0, StrToD("0x3p0", flags, 0.0, &processed, &all_used)); 29092e5b6d6dSopenharmony_ci CHECK(all_used); 29102e5b6d6dSopenharmony_ci 29112e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("0x.0p0", flags, 0.0, &processed, &all_used)); 29122e5b6d6dSopenharmony_ci CHECK(all_used); 29132e5b6d6dSopenharmony_ci 29142e5b6d6dSopenharmony_ci CHECK_EQ(3.0, StrToD("0x3.0p0", flags, 0.0, &processed, &all_used)); 29152e5b6d6dSopenharmony_ci CHECK(all_used); 29162e5b6d6dSopenharmony_ci 29172e5b6d6dSopenharmony_ci CHECK_EQ(3.0, StrToD("0x3.p0", flags, 0.0, &processed, &all_used)); 29182e5b6d6dSopenharmony_ci CHECK(all_used); 29192e5b6d6dSopenharmony_ci 29202e5b6d6dSopenharmony_ci CHECK_EQ(-5.634002666912405e+27, StrToD("-0x123456789012345678901234p0", 29212e5b6d6dSopenharmony_ci flags, 0.0, 29222e5b6d6dSopenharmony_ci &processed, &all_used)); 29232e5b6d6dSopenharmony_ci CHECK(all_used); 29242e5b6d6dSopenharmony_ci 29252e5b6d6dSopenharmony_ci CHECK_EQ(72057594037927940.0, StrToD("0x100000000000001p0", flags, 0.0, 29262e5b6d6dSopenharmony_ci &processed, &all_used)); 29272e5b6d6dSopenharmony_ci CHECK(all_used); 29282e5b6d6dSopenharmony_ci 29292e5b6d6dSopenharmony_ci CHECK_EQ(72057594037927940.0, StrToD("0x100000000000000p0", flags, 0.0, 29302e5b6d6dSopenharmony_ci &processed, &all_used)); 29312e5b6d6dSopenharmony_ci CHECK(all_used); 29322e5b6d6dSopenharmony_ci 29332e5b6d6dSopenharmony_ci CHECK_EQ(295147905179352830000.0, StrToD("0x100000000000000001p0", flags, 0.0, 29342e5b6d6dSopenharmony_ci &processed, &all_used)); 29352e5b6d6dSopenharmony_ci CHECK(all_used); 29362e5b6d6dSopenharmony_ci 29372e5b6d6dSopenharmony_ci CHECK_EQ(295147905179352830000.0, StrToD("0x100000000000000000p0", flags, 0.0, 29382e5b6d6dSopenharmony_ci &processed, &all_used)); 29392e5b6d6dSopenharmony_ci CHECK(all_used); 29402e5b6d6dSopenharmony_ci 29412e5b6d6dSopenharmony_ci CHECK_EQ(295147905179352900000.0, StrToD("0x100000000000008001p0", flags, 0.0, 29422e5b6d6dSopenharmony_ci &processed, &all_used)); 29432e5b6d6dSopenharmony_ci CHECK(all_used); 29442e5b6d6dSopenharmony_ci 29452e5b6d6dSopenharmony_ci CHECK_EQ(295147905179352830000.0, StrToD("0x100000000000008000p0", flags, 0.0, 29462e5b6d6dSopenharmony_ci &processed, &all_used)); 29472e5b6d6dSopenharmony_ci CHECK(all_used); 29482e5b6d6dSopenharmony_ci 29492e5b6d6dSopenharmony_ci CHECK_EQ(295147905179352960000.0, StrToD("0x100000000000018001p0", flags, 0.0, 29502e5b6d6dSopenharmony_ci &processed, &all_used)); 29512e5b6d6dSopenharmony_ci CHECK(all_used); 29522e5b6d6dSopenharmony_ci 29532e5b6d6dSopenharmony_ci CHECK_EQ(295147905179352960000.0, StrToD("0x100000000000018000p0", flags, 0.0, 29542e5b6d6dSopenharmony_ci &processed, &all_used)); 29552e5b6d6dSopenharmony_ci CHECK(all_used); 29562e5b6d6dSopenharmony_ci 29572e5b6d6dSopenharmony_ci CHECK_EQ(4.722366482869645e+21, StrToD("0x100000000000000001p4", flags, 0.0, 29582e5b6d6dSopenharmony_ci &processed, &all_used)); 29592e5b6d6dSopenharmony_ci CHECK(all_used); 29602e5b6d6dSopenharmony_ci 29612e5b6d6dSopenharmony_ci CHECK_EQ(4.722366482869645e+21, StrToD("0x100000000000000000p+4", flags, 0.0, 29622e5b6d6dSopenharmony_ci &processed, &all_used)); 29632e5b6d6dSopenharmony_ci CHECK(all_used); 29642e5b6d6dSopenharmony_ci 29652e5b6d6dSopenharmony_ci CHECK_EQ(4.722366482869646e+21, StrToD("0x100000000000008001p04", flags, 0.0, 29662e5b6d6dSopenharmony_ci &processed, &all_used)); 29672e5b6d6dSopenharmony_ci CHECK(all_used); 29682e5b6d6dSopenharmony_ci 29692e5b6d6dSopenharmony_ci CHECK_EQ(18446744073709552000.0, StrToD("0x100000000000008000p-4", flags, 0.0, 29702e5b6d6dSopenharmony_ci &processed, &all_used)); 29712e5b6d6dSopenharmony_ci CHECK(all_used); 29722e5b6d6dSopenharmony_ci 29732e5b6d6dSopenharmony_ci CHECK_EQ(18446744073709560000.0, StrToD("0x100000000000018001p-04", flags, 0.0, 29742e5b6d6dSopenharmony_ci &processed, &all_used)); 29752e5b6d6dSopenharmony_ci CHECK(all_used); 29762e5b6d6dSopenharmony_ci 29772e5b6d6dSopenharmony_ci CHECK_EQ(4.722366482869647e+21, StrToD("0x100000000000018000p4", flags, 0.0, 29782e5b6d6dSopenharmony_ci &processed, &all_used)); 29792e5b6d6dSopenharmony_ci CHECK(all_used); 29802e5b6d6dSopenharmony_ci 29812e5b6d6dSopenharmony_ci CHECK_EQ(Double::Infinity(), StrToD("0x1p2000", flags, 0.0, 29822e5b6d6dSopenharmony_ci &processed, &all_used)); 29832e5b6d6dSopenharmony_ci CHECK(all_used); 29842e5b6d6dSopenharmony_ci 29852e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("0x1p-2000", flags, 0.0, &processed, &all_used)); 29862e5b6d6dSopenharmony_ci CHECK(all_used); 29872e5b6d6dSopenharmony_ci 29882e5b6d6dSopenharmony_ci CHECK_EQ(-0.0, StrToD("-0x1p-2000", flags, 0.0, &processed, &all_used)); 29892e5b6d6dSopenharmony_ci CHECK(all_used); 29902e5b6d6dSopenharmony_ci 29912e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" ", flags, Double::NaN(), 29922e5b6d6dSopenharmony_ci &processed, &all_used)); 29932e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 29942e5b6d6dSopenharmony_ci 29952e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("0x", flags, 0.0, 29962e5b6d6dSopenharmony_ci &processed, &all_used)); 29972e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 29982e5b6d6dSopenharmony_ci 29992e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 0x ", flags, 0.0, 30002e5b6d6dSopenharmony_ci &processed, &all_used)); 30012e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 30022e5b6d6dSopenharmony_ci 30032e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 0x 3", flags, 0.0, 30042e5b6d6dSopenharmony_ci &processed, &all_used)); 30052e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 30062e5b6d6dSopenharmony_ci 30072e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("0x3g", flags, 0.0, 30082e5b6d6dSopenharmony_ci &processed, &all_used)); 30092e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 30102e5b6d6dSopenharmony_ci 30112e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("x3", flags, 0.0, 30122e5b6d6dSopenharmony_ci &processed, &all_used)); 30132e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 30142e5b6d6dSopenharmony_ci 30152e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("0x3 foo", flags, 0.0, 30162e5b6d6dSopenharmony_ci &processed, &all_used)); 30172e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 30182e5b6d6dSopenharmony_ci 30192e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 0x3 foo", flags, 0.0, 30202e5b6d6dSopenharmony_ci &processed, &all_used)); 30212e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 30222e5b6d6dSopenharmony_ci 30232e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("+ 0x3 foo", flags, 0.0, 30242e5b6d6dSopenharmony_ci &processed, &all_used)); 30252e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 30262e5b6d6dSopenharmony_ci 30272e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("+", flags, 0.0, &processed, &all_used)); 30282e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 30292e5b6d6dSopenharmony_ci 30302e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("-", flags, 0.0, &processed, &all_used)); 30312e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 30322e5b6d6dSopenharmony_ci 30332e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("- -0x5", flags, 0.0, &processed, &all_used)); 30342e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 30352e5b6d6dSopenharmony_ci 30362e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("- +0x5", flags, 0.0, &processed, &all_used)); 30372e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 30382e5b6d6dSopenharmony_ci 30392e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("+ +0x5", flags, 0.0, &processed, &all_used)); 30402e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 30412e5b6d6dSopenharmony_ci 30422e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("0xp1", flags, 0.0, &processed, &all_used)); 30432e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 30442e5b6d6dSopenharmony_ci 30452e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("0x.p1", flags, 0.0, &processed, &all_used)); 30462e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 30472e5b6d6dSopenharmony_ci 30482e5b6d6dSopenharmony_ci CHECK_EQ(Double::Infinity(), StrToD("0x1.p10000000000000000", flags, 0.0, 30492e5b6d6dSopenharmony_ci &processed, &all_used)); 30502e5b6d6dSopenharmony_ci CHECK(all_used); 30512e5b6d6dSopenharmony_ci 30522e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("0x1.p-10000000000000000", flags, 0.0, 30532e5b6d6dSopenharmony_ci &processed, &all_used)); 30542e5b6d6dSopenharmony_ci CHECK(all_used); 30552e5b6d6dSopenharmony_ci} 30562e5b6d6dSopenharmony_ci 30572e5b6d6dSopenharmony_ci 30582e5b6d6dSopenharmony_ciTEST(StringToDoubleOctalString) { 30592e5b6d6dSopenharmony_ci int flags; 30602e5b6d6dSopenharmony_ci int processed; 30612e5b6d6dSopenharmony_ci bool all_used; 30622e5b6d6dSopenharmony_ci 30632e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_OCTALS | 30642e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_LEADING_SPACES | 30652e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_SPACES | 30662e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN; 30672e5b6d6dSopenharmony_ci 30682e5b6d6dSopenharmony_ci CHECK_EQ(10.0, StrToD("012", flags, 0.0, &processed, &all_used)); 30692e5b6d6dSopenharmony_ci CHECK(all_used); 30702e5b6d6dSopenharmony_ci 30712e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("00", flags, 1.0, &processed, &all_used)); 30722e5b6d6dSopenharmony_ci CHECK(all_used); 30732e5b6d6dSopenharmony_ci 30742e5b6d6dSopenharmony_ci CHECK_EQ(10.0, StrToD("012", flags, 1.0, &processed, &all_used)); 30752e5b6d6dSopenharmony_ci CHECK(all_used); 30762e5b6d6dSopenharmony_ci 30772e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0, 30782e5b6d6dSopenharmony_ci StrToD("0123456789", flags, Double::NaN(), &processed, &all_used)); 30792e5b6d6dSopenharmony_ci CHECK(all_used); 30802e5b6d6dSopenharmony_ci 30812e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 30822e5b6d6dSopenharmony_ci StrToD("01234567", flags, Double::NaN(), &processed, &all_used)); 30832e5b6d6dSopenharmony_ci CHECK(all_used); 30842e5b6d6dSopenharmony_ci 30852e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 30862e5b6d6dSopenharmony_ci StrToD("+01234567", flags, Double::NaN(), &processed, &all_used)); 30872e5b6d6dSopenharmony_ci CHECK(all_used); 30882e5b6d6dSopenharmony_ci 30892e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0, 30902e5b6d6dSopenharmony_ci StrToD("-01234567", flags, Double::NaN(), &processed, &all_used)); 30912e5b6d6dSopenharmony_ci CHECK(all_used); 30922e5b6d6dSopenharmony_ci 30932e5b6d6dSopenharmony_ci CHECK_EQ(10.0, StrToD(" 012", flags, 0.0, &processed, &all_used)); 30942e5b6d6dSopenharmony_ci CHECK(all_used); 30952e5b6d6dSopenharmony_ci 30962e5b6d6dSopenharmony_ci CHECK_EQ(10.0, StrToD("\n012", flags, 0.0, &processed, &all_used)); 30972e5b6d6dSopenharmony_ci CHECK(all_used); 30982e5b6d6dSopenharmony_ci 30992e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD(" 00", flags, 1.0, &processed, &all_used)); 31002e5b6d6dSopenharmony_ci CHECK(all_used); 31012e5b6d6dSopenharmony_ci 31022e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("\t00", flags, 1.0, &processed, &all_used)); 31032e5b6d6dSopenharmony_ci CHECK(all_used); 31042e5b6d6dSopenharmony_ci 31052e5b6d6dSopenharmony_ci CHECK_EQ(10.0, StrToD(" 012", flags, 1.0, &processed, &all_used)); 31062e5b6d6dSopenharmony_ci CHECK(all_used); 31072e5b6d6dSopenharmony_ci 31082e5b6d6dSopenharmony_ci CHECK_EQ(10.0, StrToD("\n012", flags, 1.0, &processed, &all_used)); 31092e5b6d6dSopenharmony_ci CHECK(all_used); 31102e5b6d6dSopenharmony_ci 31112e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0, 31122e5b6d6dSopenharmony_ci StrToD(" 0123456789", flags, Double::NaN(), &processed, &all_used)); 31132e5b6d6dSopenharmony_ci CHECK(all_used); 31142e5b6d6dSopenharmony_ci 31152e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 31162e5b6d6dSopenharmony_ci StrToD(" 01234567", flags, Double::NaN(), &processed, &all_used)); 31172e5b6d6dSopenharmony_ci CHECK(all_used); 31182e5b6d6dSopenharmony_ci 31192e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 31202e5b6d6dSopenharmony_ci StrToD("\n01234567", flags, Double::NaN(), &processed, &all_used)); 31212e5b6d6dSopenharmony_ci CHECK(all_used); 31222e5b6d6dSopenharmony_ci 31232e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 31242e5b6d6dSopenharmony_ci StrToD(" + 01234567", flags, Double::NaN(), &processed, &all_used)); 31252e5b6d6dSopenharmony_ci CHECK(all_used); 31262e5b6d6dSopenharmony_ci 31272e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0, 31282e5b6d6dSopenharmony_ci StrToD(" - 01234567", flags, Double::NaN(), &processed, &all_used)); 31292e5b6d6dSopenharmony_ci CHECK(all_used); 31302e5b6d6dSopenharmony_ci 31312e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0, 31322e5b6d6dSopenharmony_ci StrToD("\n-\t01234567", flags, Double::NaN(), &processed, &all_used)); 31332e5b6d6dSopenharmony_ci CHECK(all_used); 31342e5b6d6dSopenharmony_ci 31352e5b6d6dSopenharmony_ci CHECK_EQ(10.0, StrToD(" 012 ", flags, 0.0, &processed, &all_used)); 31362e5b6d6dSopenharmony_ci CHECK(all_used); 31372e5b6d6dSopenharmony_ci 31382e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD(" 00 ", flags, 1.0, &processed, &all_used)); 31392e5b6d6dSopenharmony_ci CHECK(all_used); 31402e5b6d6dSopenharmony_ci 31412e5b6d6dSopenharmony_ci CHECK_EQ(10.0, StrToD(" 012 ", flags, 1.0, &processed, &all_used)); 31422e5b6d6dSopenharmony_ci CHECK(all_used); 31432e5b6d6dSopenharmony_ci 31442e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0, 31452e5b6d6dSopenharmony_ci StrToD(" 0123456789 ", flags, Double::NaN(), &processed, &all_used)); 31462e5b6d6dSopenharmony_ci CHECK(all_used); 31472e5b6d6dSopenharmony_ci 31482e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 31492e5b6d6dSopenharmony_ci StrToD(" 01234567 ", flags, Double::NaN(), &processed, &all_used)); 31502e5b6d6dSopenharmony_ci CHECK(all_used); 31512e5b6d6dSopenharmony_ci 31522e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 31532e5b6d6dSopenharmony_ci StrToD(" + 01234567 ", flags, Double::NaN(), &processed, &all_used)); 31542e5b6d6dSopenharmony_ci CHECK(all_used); 31552e5b6d6dSopenharmony_ci 31562e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0, 31572e5b6d6dSopenharmony_ci StrToD(" - 01234567 ", flags, Double::NaN(), &processed, &all_used)); 31582e5b6d6dSopenharmony_ci CHECK(all_used); 31592e5b6d6dSopenharmony_ci 31602e5b6d6dSopenharmony_ci CHECK_EQ(10.0, StrToD("012 ", flags, 0.0, &processed, &all_used)); 31612e5b6d6dSopenharmony_ci CHECK(all_used); 31622e5b6d6dSopenharmony_ci 31632e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("00 ", flags, 1.0, &processed, &all_used)); 31642e5b6d6dSopenharmony_ci CHECK(all_used); 31652e5b6d6dSopenharmony_ci 31662e5b6d6dSopenharmony_ci CHECK_EQ(10.0, StrToD("012 ", flags, 1.0, &processed, &all_used)); 31672e5b6d6dSopenharmony_ci CHECK(all_used); 31682e5b6d6dSopenharmony_ci 31692e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0, 31702e5b6d6dSopenharmony_ci StrToD("0123456789 ", flags, Double::NaN(), &processed, &all_used)); 31712e5b6d6dSopenharmony_ci CHECK(all_used); 31722e5b6d6dSopenharmony_ci 31732e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 31742e5b6d6dSopenharmony_ci StrToD("01234567 ", flags, Double::NaN(), &processed, &all_used)); 31752e5b6d6dSopenharmony_ci CHECK(all_used); 31762e5b6d6dSopenharmony_ci 31772e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 31782e5b6d6dSopenharmony_ci StrToD("+01234567", flags, Double::NaN(), &processed, &all_used)); 31792e5b6d6dSopenharmony_ci CHECK(all_used); 31802e5b6d6dSopenharmony_ci 31812e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0, 31822e5b6d6dSopenharmony_ci StrToD("-01234567", flags, Double::NaN(), &processed, &all_used)); 31832e5b6d6dSopenharmony_ci CHECK(all_used); 31842e5b6d6dSopenharmony_ci 31852e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 31862e5b6d6dSopenharmony_ci StrToD("01234567e0", flags, Double::NaN(), &processed, &all_used)); 31872e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 31882e5b6d6dSopenharmony_ci 31892e5b6d6dSopenharmony_ci 31902e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_OCTALS; 31912e5b6d6dSopenharmony_ci CHECK_EQ(10.0, StrToD("012", flags, 0.0, &processed, &all_used)); 31922e5b6d6dSopenharmony_ci CHECK(all_used); 31932e5b6d6dSopenharmony_ci 31942e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("00", flags, 1.0, &processed, &all_used)); 31952e5b6d6dSopenharmony_ci CHECK(all_used); 31962e5b6d6dSopenharmony_ci 31972e5b6d6dSopenharmony_ci CHECK_EQ(10.0, StrToD("012", flags, 1.0, &processed, &all_used)); 31982e5b6d6dSopenharmony_ci CHECK(all_used); 31992e5b6d6dSopenharmony_ci 32002e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0, 32012e5b6d6dSopenharmony_ci StrToD("0123456789", flags, Double::NaN(), &processed, &all_used)); 32022e5b6d6dSopenharmony_ci CHECK(all_used); 32032e5b6d6dSopenharmony_ci 32042e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 32052e5b6d6dSopenharmony_ci StrToD("01234567", flags, Double::NaN(), &processed, &all_used)); 32062e5b6d6dSopenharmony_ci CHECK(all_used); 32072e5b6d6dSopenharmony_ci 32082e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 32092e5b6d6dSopenharmony_ci StrToD("+01234567", flags, Double::NaN(), &processed, &all_used)); 32102e5b6d6dSopenharmony_ci CHECK(all_used); 32112e5b6d6dSopenharmony_ci 32122e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0, 32132e5b6d6dSopenharmony_ci StrToD("-01234567", flags, Double::NaN(), &processed, &all_used)); 32142e5b6d6dSopenharmony_ci CHECK(all_used); 32152e5b6d6dSopenharmony_ci 32162e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 012", flags, 0.0, &processed, &all_used)); 32172e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 32182e5b6d6dSopenharmony_ci 32192e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 00", flags, 1.0, &processed, &all_used)); 32202e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 32212e5b6d6dSopenharmony_ci 32222e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 012", flags, 1.0, &processed, &all_used)); 32232e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 32242e5b6d6dSopenharmony_ci 32252e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 32262e5b6d6dSopenharmony_ci StrToD(" 0123456789", flags, Double::NaN(), &processed, &all_used)); 32272e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 32282e5b6d6dSopenharmony_ci 32292e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 32302e5b6d6dSopenharmony_ci StrToD(" 01234567", flags, Double::NaN(), &processed, &all_used)); 32312e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 32322e5b6d6dSopenharmony_ci 32332e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 32342e5b6d6dSopenharmony_ci StrToD(" + 01234567", flags, Double::NaN(), &processed, &all_used)); 32352e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 32362e5b6d6dSopenharmony_ci 32372e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 32382e5b6d6dSopenharmony_ci StrToD(" - 01234567", flags, Double::NaN(), &processed, &all_used)); 32392e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 32402e5b6d6dSopenharmony_ci 32412e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 012 ", flags, 0.0, &processed, &all_used)); 32422e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 32432e5b6d6dSopenharmony_ci 32442e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 00 ", flags, 1.0, &processed, &all_used)); 32452e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 32462e5b6d6dSopenharmony_ci 32472e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 012 ", flags, 1.0, &processed, &all_used)); 32482e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 32492e5b6d6dSopenharmony_ci 32502e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 32512e5b6d6dSopenharmony_ci StrToD(" 0123456789 ", flags, Double::NaN(), &processed, &all_used)); 32522e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 32532e5b6d6dSopenharmony_ci 32542e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 32552e5b6d6dSopenharmony_ci StrToD(" 01234567 ", flags, Double::NaN(), &processed, &all_used)); 32562e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 32572e5b6d6dSopenharmony_ci 32582e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 32592e5b6d6dSopenharmony_ci StrToD(" + 01234567 ", flags, Double::NaN(), &processed, &all_used)); 32602e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 32612e5b6d6dSopenharmony_ci 32622e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 32632e5b6d6dSopenharmony_ci StrToD(" - 01234567 ", flags, Double::NaN(), &processed, &all_used)); 32642e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 32652e5b6d6dSopenharmony_ci 32662e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("012 ", flags, 0.0, &processed, &all_used)); 32672e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 32682e5b6d6dSopenharmony_ci 32692e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("00 ", flags, 1.0, &processed, &all_used)); 32702e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 32712e5b6d6dSopenharmony_ci 32722e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("012 ", flags, 1.0, &processed, &all_used)); 32732e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 32742e5b6d6dSopenharmony_ci 32752e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 32762e5b6d6dSopenharmony_ci StrToD("0123456789 ", flags, Double::NaN(), &processed, &all_used)); 32772e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 32782e5b6d6dSopenharmony_ci 32792e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 32802e5b6d6dSopenharmony_ci StrToD("01234567 ", flags, Double::NaN(), &processed, &all_used)); 32812e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 32822e5b6d6dSopenharmony_ci 32832e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 32842e5b6d6dSopenharmony_ci StrToD("+01234567", flags, Double::NaN(), &processed, &all_used)); 32852e5b6d6dSopenharmony_ci CHECK(all_used); 32862e5b6d6dSopenharmony_ci 32872e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0, 32882e5b6d6dSopenharmony_ci StrToD("-01234567", flags, Double::NaN(), &processed, &all_used)); 32892e5b6d6dSopenharmony_ci CHECK(all_used); 32902e5b6d6dSopenharmony_ci 32912e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 32922e5b6d6dSopenharmony_ci StrToD("01234567e0", flags, Double::NaN(), &processed, &all_used)); 32932e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 32942e5b6d6dSopenharmony_ci 32952e5b6d6dSopenharmony_ci 32962e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_OCTALS | 32972e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_JUNK; 32982e5b6d6dSopenharmony_ci CHECK_EQ(10.0, StrToD("012", flags, 0.0, &processed, &all_used)); 32992e5b6d6dSopenharmony_ci CHECK(all_used); 33002e5b6d6dSopenharmony_ci 33012e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("00", flags, 1.0, &processed, &all_used)); 33022e5b6d6dSopenharmony_ci CHECK(all_used); 33032e5b6d6dSopenharmony_ci 33042e5b6d6dSopenharmony_ci CHECK_EQ(10.0, StrToD("012", flags, 1.0, &processed, &all_used)); 33052e5b6d6dSopenharmony_ci CHECK(all_used); 33062e5b6d6dSopenharmony_ci 33072e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0, 33082e5b6d6dSopenharmony_ci StrToD("0123456789", flags, Double::NaN(), &processed, &all_used)); 33092e5b6d6dSopenharmony_ci CHECK(all_used); 33102e5b6d6dSopenharmony_ci 33112e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 33122e5b6d6dSopenharmony_ci StrToD("01234567", flags, Double::NaN(), &processed, &all_used)); 33132e5b6d6dSopenharmony_ci CHECK(all_used); 33142e5b6d6dSopenharmony_ci 33152e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 33162e5b6d6dSopenharmony_ci StrToD("+01234567", flags, Double::NaN(), &processed, &all_used)); 33172e5b6d6dSopenharmony_ci CHECK(all_used); 33182e5b6d6dSopenharmony_ci 33192e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0, 33202e5b6d6dSopenharmony_ci StrToD("-01234567", flags, Double::NaN(), &processed, &all_used)); 33212e5b6d6dSopenharmony_ci CHECK(all_used); 33222e5b6d6dSopenharmony_ci 33232e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 012", flags, 0.0, &processed, &all_used)); 33242e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 33252e5b6d6dSopenharmony_ci 33262e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 00", flags, 1.0, &processed, &all_used)); 33272e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 33282e5b6d6dSopenharmony_ci 33292e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 012", flags, 1.0, &processed, &all_used)); 33302e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 33312e5b6d6dSopenharmony_ci 33322e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 33332e5b6d6dSopenharmony_ci StrToD(" 0123456789", flags, Double::NaN(), &processed, &all_used)); 33342e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 33352e5b6d6dSopenharmony_ci 33362e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 33372e5b6d6dSopenharmony_ci StrToD(" 01234567", flags, Double::NaN(), &processed, &all_used)); 33382e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 33392e5b6d6dSopenharmony_ci 33402e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 33412e5b6d6dSopenharmony_ci StrToD(" + 01234567", flags, Double::NaN(), &processed, &all_used)); 33422e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 33432e5b6d6dSopenharmony_ci 33442e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 33452e5b6d6dSopenharmony_ci StrToD(" - 01234567", flags, Double::NaN(), &processed, &all_used)); 33462e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 33472e5b6d6dSopenharmony_ci 33482e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 012 ", flags, 0.0, &processed, &all_used)); 33492e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 33502e5b6d6dSopenharmony_ci 33512e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 00 ", flags, 1.0, &processed, &all_used)); 33522e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 33532e5b6d6dSopenharmony_ci 33542e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 012 ", flags, 1.0, &processed, &all_used)); 33552e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 33562e5b6d6dSopenharmony_ci 33572e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 33582e5b6d6dSopenharmony_ci StrToD(" 0123456789 ", flags, Double::NaN(), &processed, &all_used)); 33592e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 33602e5b6d6dSopenharmony_ci 33612e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 33622e5b6d6dSopenharmony_ci StrToD(" 01234567 ", flags, Double::NaN(), &processed, &all_used)); 33632e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 33642e5b6d6dSopenharmony_ci 33652e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 33662e5b6d6dSopenharmony_ci StrToD(" + 01234567 ", flags, Double::NaN(), &processed, &all_used)); 33672e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 33682e5b6d6dSopenharmony_ci 33692e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 33702e5b6d6dSopenharmony_ci StrToD(" - 01234567 ", flags, Double::NaN(), &processed, &all_used)); 33712e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 33722e5b6d6dSopenharmony_ci 33732e5b6d6dSopenharmony_ci CHECK_EQ(10.0, StrToD("012 ", flags, 0.0, &processed, &all_used)); 33742e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 33752e5b6d6dSopenharmony_ci 33762e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("00 ", flags, 1.0, &processed, &all_used)); 33772e5b6d6dSopenharmony_ci CHECK_EQ(2, processed); 33782e5b6d6dSopenharmony_ci 33792e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0, 33802e5b6d6dSopenharmony_ci StrToD("0123456789 ", flags, Double::NaN(), &processed, &all_used)); 33812e5b6d6dSopenharmony_ci CHECK_EQ(10, processed); 33822e5b6d6dSopenharmony_ci 33832e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 33842e5b6d6dSopenharmony_ci StrToD("01234567 ", flags, Double::NaN(), &processed, &all_used)); 33852e5b6d6dSopenharmony_ci CHECK_EQ(8, processed); 33862e5b6d6dSopenharmony_ci 33872e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 33882e5b6d6dSopenharmony_ci StrToD("+01234567", flags, Double::NaN(), &processed, &all_used)); 33892e5b6d6dSopenharmony_ci CHECK(all_used); 33902e5b6d6dSopenharmony_ci 33912e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0, 33922e5b6d6dSopenharmony_ci StrToD("-01234567", flags, Double::NaN(), &processed, &all_used)); 33932e5b6d6dSopenharmony_ci CHECK(all_used); 33942e5b6d6dSopenharmony_ci 33952e5b6d6dSopenharmony_ci CHECK_EQ(10.0, StrToD("012foo ", flags, 0.0, &processed, &all_used)); 33962e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 33972e5b6d6dSopenharmony_ci 33982e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("00foo ", flags, 1.0, &processed, &all_used)); 33992e5b6d6dSopenharmony_ci CHECK_EQ(2, processed); 34002e5b6d6dSopenharmony_ci 34012e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0, 34022e5b6d6dSopenharmony_ci StrToD("0123456789foo ", flags, Double::NaN(), 34032e5b6d6dSopenharmony_ci &processed, &all_used)); 34042e5b6d6dSopenharmony_ci CHECK_EQ(10, processed); 34052e5b6d6dSopenharmony_ci 34062e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 34072e5b6d6dSopenharmony_ci StrToD("01234567foo ", flags, Double::NaN(), &processed, &all_used)); 34082e5b6d6dSopenharmony_ci CHECK_EQ(8, processed); 34092e5b6d6dSopenharmony_ci 34102e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 34112e5b6d6dSopenharmony_ci StrToD("+01234567foo", flags, Double::NaN(), &processed, &all_used)); 34122e5b6d6dSopenharmony_ci CHECK_EQ(9, processed); 34132e5b6d6dSopenharmony_ci 34142e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0, 34152e5b6d6dSopenharmony_ci StrToD("-01234567foo", flags, Double::NaN(), &processed, &all_used)); 34162e5b6d6dSopenharmony_ci CHECK_EQ(9, processed); 34172e5b6d6dSopenharmony_ci 34182e5b6d6dSopenharmony_ci CHECK_EQ(10.0, StrToD("012 foo ", flags, 0.0, &processed, &all_used)); 34192e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 34202e5b6d6dSopenharmony_ci 34212e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("00 foo ", flags, 1.0, &processed, &all_used)); 34222e5b6d6dSopenharmony_ci CHECK_EQ(2, processed); 34232e5b6d6dSopenharmony_ci 34242e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0, 34252e5b6d6dSopenharmony_ci StrToD("0123456789 foo ", flags, Double::NaN(), 34262e5b6d6dSopenharmony_ci &processed, &all_used)); 34272e5b6d6dSopenharmony_ci CHECK_EQ(10, processed); 34282e5b6d6dSopenharmony_ci 34292e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 34302e5b6d6dSopenharmony_ci StrToD("01234567 foo ", flags, Double::NaN(), 34312e5b6d6dSopenharmony_ci &processed, &all_used)); 34322e5b6d6dSopenharmony_ci CHECK_EQ(8, processed); 34332e5b6d6dSopenharmony_ci 34342e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 34352e5b6d6dSopenharmony_ci StrToD("+01234567 foo", flags, Double::NaN(), 34362e5b6d6dSopenharmony_ci &processed, &all_used)); 34372e5b6d6dSopenharmony_ci CHECK_EQ(9, processed); 34382e5b6d6dSopenharmony_ci 34392e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0, 34402e5b6d6dSopenharmony_ci StrToD("-01234567 foo", flags, Double::NaN(), &processed, 34412e5b6d6dSopenharmony_ci &all_used)); 34422e5b6d6dSopenharmony_ci CHECK_EQ(9, processed); 34432e5b6d6dSopenharmony_ci 34442e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 34452e5b6d6dSopenharmony_ci StrToD("01234567e0", flags, Double::NaN(), &processed, &all_used)); 34462e5b6d6dSopenharmony_ci CHECK_EQ(8, processed); 34472e5b6d6dSopenharmony_ci 34482e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 34492e5b6d6dSopenharmony_ci StrToD("01234567e", flags, Double::NaN(), &processed, &all_used)); 34502e5b6d6dSopenharmony_ci CHECK_EQ(8, processed); 34512e5b6d6dSopenharmony_ci 34522e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_OCTALS | 34532e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_SPACES | 34542e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_JUNK; 34552e5b6d6dSopenharmony_ci CHECK_EQ(10.0, StrToD("012", flags, 0.0, &processed, &all_used)); 34562e5b6d6dSopenharmony_ci CHECK(all_used); 34572e5b6d6dSopenharmony_ci 34582e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("00", flags, 1.0, &processed, &all_used)); 34592e5b6d6dSopenharmony_ci CHECK(all_used); 34602e5b6d6dSopenharmony_ci 34612e5b6d6dSopenharmony_ci CHECK_EQ(10.0, StrToD("012", flags, 1.0, &processed, &all_used)); 34622e5b6d6dSopenharmony_ci CHECK(all_used); 34632e5b6d6dSopenharmony_ci 34642e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0, 34652e5b6d6dSopenharmony_ci StrToD("0123456789", flags, Double::NaN(), &processed, &all_used)); 34662e5b6d6dSopenharmony_ci CHECK(all_used); 34672e5b6d6dSopenharmony_ci 34682e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 34692e5b6d6dSopenharmony_ci StrToD("01234567", flags, Double::NaN(), &processed, &all_used)); 34702e5b6d6dSopenharmony_ci CHECK(all_used); 34712e5b6d6dSopenharmony_ci 34722e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 34732e5b6d6dSopenharmony_ci StrToD("+01234567", flags, Double::NaN(), &processed, &all_used)); 34742e5b6d6dSopenharmony_ci CHECK(all_used); 34752e5b6d6dSopenharmony_ci 34762e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0, 34772e5b6d6dSopenharmony_ci StrToD("-01234567", flags, Double::NaN(), &processed, &all_used)); 34782e5b6d6dSopenharmony_ci CHECK(all_used); 34792e5b6d6dSopenharmony_ci 34802e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 012", flags, 0.0, &processed, &all_used)); 34812e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 34822e5b6d6dSopenharmony_ci 34832e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 00", flags, 1.0, &processed, &all_used)); 34842e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 34852e5b6d6dSopenharmony_ci 34862e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 012", flags, 1.0, &processed, &all_used)); 34872e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 34882e5b6d6dSopenharmony_ci 34892e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 34902e5b6d6dSopenharmony_ci StrToD(" 0123456789", flags, Double::NaN(), &processed, &all_used)); 34912e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 34922e5b6d6dSopenharmony_ci 34932e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 34942e5b6d6dSopenharmony_ci StrToD(" 01234567", flags, Double::NaN(), &processed, &all_used)); 34952e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 34962e5b6d6dSopenharmony_ci 34972e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 34982e5b6d6dSopenharmony_ci StrToD(" + 01234567", flags, Double::NaN(), &processed, &all_used)); 34992e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 35002e5b6d6dSopenharmony_ci 35012e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 35022e5b6d6dSopenharmony_ci StrToD(" - 01234567", flags, Double::NaN(), &processed, &all_used)); 35032e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 35042e5b6d6dSopenharmony_ci 35052e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 012 ", flags, 0.0, &processed, &all_used)); 35062e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 35072e5b6d6dSopenharmony_ci 35082e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 00 ", flags, 1.0, &processed, &all_used)); 35092e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 35102e5b6d6dSopenharmony_ci 35112e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 012 ", flags, 1.0, &processed, &all_used)); 35122e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 35132e5b6d6dSopenharmony_ci 35142e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 35152e5b6d6dSopenharmony_ci StrToD(" 0123456789 ", flags, Double::NaN(), &processed, &all_used)); 35162e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 35172e5b6d6dSopenharmony_ci 35182e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 35192e5b6d6dSopenharmony_ci StrToD(" 01234567 ", flags, Double::NaN(), &processed, &all_used)); 35202e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 35212e5b6d6dSopenharmony_ci 35222e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 35232e5b6d6dSopenharmony_ci StrToD(" + 01234567 ", flags, Double::NaN(), &processed, &all_used)); 35242e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 35252e5b6d6dSopenharmony_ci 35262e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 35272e5b6d6dSopenharmony_ci StrToD(" - 01234567 ", flags, Double::NaN(), &processed, &all_used)); 35282e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 35292e5b6d6dSopenharmony_ci 35302e5b6d6dSopenharmony_ci CHECK_EQ(10.0, StrToD("012 ", flags, 0.0, &processed, &all_used)); 35312e5b6d6dSopenharmony_ci CHECK(all_used); 35322e5b6d6dSopenharmony_ci 35332e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("00 ", flags, 1.0, &processed, &all_used)); 35342e5b6d6dSopenharmony_ci CHECK(all_used); 35352e5b6d6dSopenharmony_ci 35362e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0, 35372e5b6d6dSopenharmony_ci StrToD("0123456789 ", flags, Double::NaN(), &processed, &all_used)); 35382e5b6d6dSopenharmony_ci CHECK(all_used); 35392e5b6d6dSopenharmony_ci 35402e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 35412e5b6d6dSopenharmony_ci StrToD("01234567 ", flags, Double::NaN(), &processed, &all_used)); 35422e5b6d6dSopenharmony_ci CHECK(all_used); 35432e5b6d6dSopenharmony_ci 35442e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 35452e5b6d6dSopenharmony_ci StrToD("+01234567", flags, Double::NaN(), &processed, &all_used)); 35462e5b6d6dSopenharmony_ci CHECK(all_used); 35472e5b6d6dSopenharmony_ci 35482e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0, 35492e5b6d6dSopenharmony_ci StrToD("-01234567", flags, Double::NaN(), &processed, &all_used)); 35502e5b6d6dSopenharmony_ci CHECK(all_used); 35512e5b6d6dSopenharmony_ci 35522e5b6d6dSopenharmony_ci CHECK_EQ(10.0, StrToD("012foo ", flags, 0.0, &processed, &all_used)); 35532e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 35542e5b6d6dSopenharmony_ci 35552e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("00foo ", flags, 1.0, &processed, &all_used)); 35562e5b6d6dSopenharmony_ci CHECK_EQ(2, processed); 35572e5b6d6dSopenharmony_ci 35582e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0, 35592e5b6d6dSopenharmony_ci StrToD("0123456789foo ", flags, Double::NaN(), 35602e5b6d6dSopenharmony_ci &processed, &all_used)); 35612e5b6d6dSopenharmony_ci CHECK_EQ(10, processed); 35622e5b6d6dSopenharmony_ci 35632e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 35642e5b6d6dSopenharmony_ci StrToD("01234567foo ", flags, Double::NaN(), &processed, &all_used)); 35652e5b6d6dSopenharmony_ci CHECK_EQ(8, processed); 35662e5b6d6dSopenharmony_ci 35672e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 35682e5b6d6dSopenharmony_ci StrToD("+01234567foo", flags, Double::NaN(), &processed, &all_used)); 35692e5b6d6dSopenharmony_ci CHECK_EQ(9, processed); 35702e5b6d6dSopenharmony_ci 35712e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0, 35722e5b6d6dSopenharmony_ci StrToD("-01234567foo", flags, Double::NaN(), &processed, &all_used)); 35732e5b6d6dSopenharmony_ci CHECK_EQ(9, processed); 35742e5b6d6dSopenharmony_ci 35752e5b6d6dSopenharmony_ci CHECK_EQ(10.0, StrToD("012 foo ", flags, 0.0, &processed, &all_used)); 35762e5b6d6dSopenharmony_ci CHECK_EQ(4, processed); 35772e5b6d6dSopenharmony_ci 35782e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("00 foo ", flags, 1.0, &processed, &all_used)); 35792e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 35802e5b6d6dSopenharmony_ci 35812e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0, 35822e5b6d6dSopenharmony_ci StrToD("0123456789 foo ", flags, Double::NaN(), 35832e5b6d6dSopenharmony_ci &processed, &all_used)); 35842e5b6d6dSopenharmony_ci CHECK_EQ(11, processed); 35852e5b6d6dSopenharmony_ci 35862e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 35872e5b6d6dSopenharmony_ci StrToD("01234567 foo ", flags, Double::NaN(), 35882e5b6d6dSopenharmony_ci &processed, &all_used)); 35892e5b6d6dSopenharmony_ci CHECK_EQ(9, processed); 35902e5b6d6dSopenharmony_ci 35912e5b6d6dSopenharmony_ci CHECK_EQ(342391.0, 35922e5b6d6dSopenharmony_ci StrToD("+01234567 foo", flags, Double::NaN(), 35932e5b6d6dSopenharmony_ci &processed, &all_used)); 35942e5b6d6dSopenharmony_ci CHECK_EQ(10, processed); 35952e5b6d6dSopenharmony_ci 35962e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0, 35972e5b6d6dSopenharmony_ci StrToD("-01234567 foo", flags, Double::NaN(), 35982e5b6d6dSopenharmony_ci &processed, &all_used)); 35992e5b6d6dSopenharmony_ci CHECK_EQ(10, processed); 36002e5b6d6dSopenharmony_ci} 36012e5b6d6dSopenharmony_ci 36022e5b6d6dSopenharmony_ci 36032e5b6d6dSopenharmony_ciTEST(StringToDoubleSeparator) { 36042e5b6d6dSopenharmony_ci int flags; 36052e5b6d6dSopenharmony_ci int processed; 36062e5b6d6dSopenharmony_ci bool all_used; 36072e5b6d6dSopenharmony_ci uc16 separator; 36082e5b6d6dSopenharmony_ci 36092e5b6d6dSopenharmony_ci separator = '\''; 36102e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::NO_FLAGS; 36112e5b6d6dSopenharmony_ci 36122e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD("000'001.0'0", flags, 0.0, 36132e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 36142e5b6d6dSopenharmony_ci CHECK(all_used); 36152e5b6d6dSopenharmony_ci 36162e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD("0'0'0'0'0'1.0'0", flags, 0.0, 36172e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 36182e5b6d6dSopenharmony_ci CHECK(all_used); 36192e5b6d6dSopenharmony_ci 36202e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("'1.0", flags, 0.0, 36212e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 36222e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 36232e5b6d6dSopenharmony_ci 36242e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1'.0", flags, 0.0, 36252e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 36262e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 36272e5b6d6dSopenharmony_ci 36282e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1.'0", flags, 0.0, 36292e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 36302e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 36312e5b6d6dSopenharmony_ci 36322e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("0''1.0", flags, 0.0, 36332e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 36342e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 36352e5b6d6dSopenharmony_ci 36362e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1.0e1'0", flags, 0.0, 36372e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 36382e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 36392e5b6d6dSopenharmony_ci 36402e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1.0e1'", flags, 0.0, 36412e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 36422e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 36432e5b6d6dSopenharmony_ci 36442e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1.0e'1", flags, 0.0, 36452e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 36462e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 36472e5b6d6dSopenharmony_ci 36482e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1.0'e1", flags, 0.0, 36492e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 36502e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 36512e5b6d6dSopenharmony_ci 36522e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("+'1.0e1", flags, 0.0, 36532e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 36542e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 36552e5b6d6dSopenharmony_ci 36562e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("-'1.0e1", flags, 0.0, 36572e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 36582e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 36592e5b6d6dSopenharmony_ci 36602e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1.0e+'1", flags, 0.0, 36612e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 36622e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 36632e5b6d6dSopenharmony_ci 36642e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1.0e-'1", flags, 0.0, 36652e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 36662e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 36672e5b6d6dSopenharmony_ci 36682e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1.0e'+1", flags, 0.0, 36692e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 36702e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 36712e5b6d6dSopenharmony_ci 36722e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1.0e'-1", flags, 0.0, 36732e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 36742e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 36752e5b6d6dSopenharmony_ci 36762e5b6d6dSopenharmony_ci separator = ' '; 36772e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::NO_FLAGS; 36782e5b6d6dSopenharmony_ci 36792e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD("000 001.0 0", flags, 0.0, 36802e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 36812e5b6d6dSopenharmony_ci CHECK(all_used); 36822e5b6d6dSopenharmony_ci 36832e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD("0 0 0 0 0 1.0 0", flags, 0.0, 36842e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 36852e5b6d6dSopenharmony_ci CHECK(all_used); 36862e5b6d6dSopenharmony_ci 36872e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 1.0", flags, 0.0, 36882e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 36892e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 36902e5b6d6dSopenharmony_ci 36912e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1 .0", flags, 0.0, 36922e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 36932e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 36942e5b6d6dSopenharmony_ci 36952e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1. 0", flags, 0.0, 36962e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 36972e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 36982e5b6d6dSopenharmony_ci 36992e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("0 1.0", flags, 0.0, 37002e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 37012e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 37022e5b6d6dSopenharmony_ci 37032e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1.0e1 0", flags, 0.0, 37042e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 37052e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 37062e5b6d6dSopenharmony_ci 37072e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1.0e1 ", flags, 0.0, 37082e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 37092e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 37102e5b6d6dSopenharmony_ci 37112e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1.0e 1", flags, 0.0, 37122e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 37132e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 37142e5b6d6dSopenharmony_ci 37152e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1.0 e1", flags, 0.0, 37162e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 37172e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 37182e5b6d6dSopenharmony_ci 37192e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("+ 1.0e1", flags, 0.0, 37202e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 37212e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 37222e5b6d6dSopenharmony_ci 37232e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("- 1.0e1", flags, 0.0, 37242e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 37252e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 37262e5b6d6dSopenharmony_ci 37272e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1.0e+ 1", flags, 0.0, 37282e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 37292e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 37302e5b6d6dSopenharmony_ci 37312e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1.0e- 1", flags, 0.0, 37322e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 37332e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 37342e5b6d6dSopenharmony_ci 37352e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1.0e +1", flags, 0.0, 37362e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 37372e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 37382e5b6d6dSopenharmony_ci 37392e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1.0e -1", flags, 0.0, 37402e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 37412e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 37422e5b6d6dSopenharmony_ci 37432e5b6d6dSopenharmony_ci separator = ' '; 37442e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_LEADING_SPACES | 37452e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_SPACES; 37462e5b6d6dSopenharmony_ci 37472e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD("000 001.0 0", flags, 0.0, 37482e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 37492e5b6d6dSopenharmony_ci CHECK(all_used); 37502e5b6d6dSopenharmony_ci 37512e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD("0 0 0 0 0 1.0 0", flags, 0.0, 37522e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 37532e5b6d6dSopenharmony_ci CHECK(all_used); 37542e5b6d6dSopenharmony_ci 37552e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD(" 000 001.0 0 ", flags, 0.0, 37562e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 37572e5b6d6dSopenharmony_ci CHECK(all_used); 37582e5b6d6dSopenharmony_ci 37592e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD(" 0 0 0 0 0 1.0 0 ", flags, 0.0, 37602e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 37612e5b6d6dSopenharmony_ci CHECK(all_used); 37622e5b6d6dSopenharmony_ci 37632e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD(" 1.0", flags, 0.0, 37642e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 37652e5b6d6dSopenharmony_ci CHECK(all_used); 37662e5b6d6dSopenharmony_ci 37672e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1 .0", flags, 0.0, 37682e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 37692e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 37702e5b6d6dSopenharmony_ci 37712e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1. 0", flags, 0.0, 37722e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 37732e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 37742e5b6d6dSopenharmony_ci 37752e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("0 1.0", flags, 0.0, 37762e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 37772e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 37782e5b6d6dSopenharmony_ci 37792e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1.0e1 0", flags, 0.0, 37802e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 37812e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 37822e5b6d6dSopenharmony_ci 37832e5b6d6dSopenharmony_ci CHECK_EQ(10.0, StrToD("1.0e1 ", flags, 0.0, 37842e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 37852e5b6d6dSopenharmony_ci CHECK(all_used); 37862e5b6d6dSopenharmony_ci 37872e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1.0e 1", flags, 0.0, 37882e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 37892e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 37902e5b6d6dSopenharmony_ci 37912e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1.0 e1", flags, 0.0, 37922e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 37932e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 37942e5b6d6dSopenharmony_ci 37952e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("+ 1.0e1", flags, 0.0, 37962e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 37972e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 37982e5b6d6dSopenharmony_ci 37992e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("- 1.0e1", flags, 0.0, 38002e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 38012e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 38022e5b6d6dSopenharmony_ci 38032e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1.0e+ 1", flags, 0.0, 38042e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 38052e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 38062e5b6d6dSopenharmony_ci 38072e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1.0e- 1", flags, 0.0, 38082e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 38092e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 38102e5b6d6dSopenharmony_ci 38112e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1.0e +1", flags, 0.0, 38122e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 38132e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 38142e5b6d6dSopenharmony_ci 38152e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("1.0e -1", flags, 0.0, 38162e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 38172e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 38182e5b6d6dSopenharmony_ci 38192e5b6d6dSopenharmony_ci separator = ' '; 38202e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_HEX | 38212e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_HEX_FLOATS | 38222e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_LEADING_SPACES | 38232e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_SPACES; 38242e5b6d6dSopenharmony_ci 38252e5b6d6dSopenharmony_ci CHECK_EQ(18.0, StrToD("0x1 2", flags, 0.0, &processed, &all_used, separator)); 38262e5b6d6dSopenharmony_ci CHECK(all_used); 38272e5b6d6dSopenharmony_ci 38282e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("0x0 0", flags, 1.0, &processed, &all_used, separator)); 38292e5b6d6dSopenharmony_ci CHECK(all_used); 38302e5b6d6dSopenharmony_ci 38312e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0x123456789), 38322e5b6d6dSopenharmony_ci StrToD("0x1 2 3 4 5 6 7 8 9", flags, Double::NaN(), 38332e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 38342e5b6d6dSopenharmony_ci CHECK(all_used); 38352e5b6d6dSopenharmony_ci 38362e5b6d6dSopenharmony_ci CHECK_EQ(18.0, StrToD(" 0x1 2 ", flags, 0.0, 38372e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 38382e5b6d6dSopenharmony_ci CHECK(all_used); 38392e5b6d6dSopenharmony_ci 38402e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD(" 0x0 ", flags, 1.0, 38412e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 38422e5b6d6dSopenharmony_ci CHECK(all_used); 38432e5b6d6dSopenharmony_ci 38442e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0x123456789), 38452e5b6d6dSopenharmony_ci StrToD(" 0x1 2 3 4 5 6 7 8 9 ", flags, Double::NaN(), 38462e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 38472e5b6d6dSopenharmony_ci CHECK(all_used); 38482e5b6d6dSopenharmony_ci 38492e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0xabcdef), 38502e5b6d6dSopenharmony_ci StrToD("0xa b c d e f", flags, 0.0, 38512e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 38522e5b6d6dSopenharmony_ci CHECK(all_used); 38532e5b6d6dSopenharmony_ci 38542e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("0x 1 2", flags, 0.0, 38552e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 38562e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 38572e5b6d6dSopenharmony_ci 38582e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("0 x0", flags, 1.0, 38592e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 38602e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 38612e5b6d6dSopenharmony_ci 38622e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 38632e5b6d6dSopenharmony_ci StrToD("0x1 2 3 4 5 6 7 8 9", flags, Double::NaN(), 38642e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 38652e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 38662e5b6d6dSopenharmony_ci 38672e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 0 x1 2 ", flags, 0.0, 38682e5b6d6dSopenharmony_ci &processed, &all_used, separator)); 38692e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 38702e5b6d6dSopenharmony_ci 38712e5b6d6dSopenharmony_ci CHECK_EQ(3.0, 38722e5b6d6dSopenharmony_ci StrToD("0x0 3p0", flags, 0.0, &processed, &all_used, separator)); 38732e5b6d6dSopenharmony_ci CHECK(all_used); 38742e5b6d6dSopenharmony_ci 38752e5b6d6dSopenharmony_ci CHECK_EQ(0.0, 38762e5b6d6dSopenharmony_ci StrToD("0x.0 0p0", flags, 0.0, &processed, &all_used, separator)); 38772e5b6d6dSopenharmony_ci CHECK(all_used); 38782e5b6d6dSopenharmony_ci 38792e5b6d6dSopenharmony_ci CHECK_EQ(3.0, 38802e5b6d6dSopenharmony_ci StrToD("0x3.0 0p0", flags, 0.0, &processed, &all_used, separator)); 38812e5b6d6dSopenharmony_ci CHECK(all_used); 38822e5b6d6dSopenharmony_ci 38832e5b6d6dSopenharmony_ci CHECK_EQ(3.0, 38842e5b6d6dSopenharmony_ci StrToD("0x0 3.p0", flags, 0.0, &processed, &all_used, separator)); 38852e5b6d6dSopenharmony_ci CHECK(all_used); 38862e5b6d6dSopenharmony_ci 38872e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 38882e5b6d6dSopenharmony_ci StrToD("0x 3p0", flags, 0.0, &processed, &all_used)); 38892e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 38902e5b6d6dSopenharmony_ci 38912e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 38922e5b6d6dSopenharmony_ci StrToD("0x.0 p0", flags, 0.0, &processed, &all_used)); 38932e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 38942e5b6d6dSopenharmony_ci 38952e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 38962e5b6d6dSopenharmony_ci StrToD("0x3.0p0 0", flags, 0.0, &processed, &all_used)); 38972e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 38982e5b6d6dSopenharmony_ci 38992e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 39002e5b6d6dSopenharmony_ci StrToD("0x0 3.p 0", flags, 0.0, &processed, &all_used)); 39012e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 39022e5b6d6dSopenharmony_ci 39032e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 39042e5b6d6dSopenharmony_ci StrToD("0x3p+ 0", flags, 0.0, &processed, &all_used)); 39052e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 39062e5b6d6dSopenharmony_ci 39072e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 39082e5b6d6dSopenharmony_ci StrToD("0x.0p- 0", flags, 0.0, &processed, &all_used)); 39092e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 39102e5b6d6dSopenharmony_ci 39112e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 39122e5b6d6dSopenharmony_ci StrToD("0x3.0p +0", flags, 0.0, &processed, &all_used)); 39132e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 39142e5b6d6dSopenharmony_ci 39152e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 39162e5b6d6dSopenharmony_ci StrToD("0x0 3.p -0", flags, 0.0, &processed, &all_used)); 39172e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 39182e5b6d6dSopenharmony_ci 39192e5b6d6dSopenharmony_ci separator = 0x202F; 39202e5b6d6dSopenharmony_ci char char_separator = '@'; 39212e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_HEX | 39222e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_HEX_FLOATS | 39232e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_LEADING_SPACES | 39242e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_SPACES; 39252e5b6d6dSopenharmony_ci 39262e5b6d6dSopenharmony_ci CHECK_EQ(18.0, 39272e5b6d6dSopenharmony_ci StrToD16("0x1@2", flags, 0.0, &processed, &all_used, 39282e5b6d6dSopenharmony_ci char_separator, separator)); 39292e5b6d6dSopenharmony_ci CHECK(all_used); 39302e5b6d6dSopenharmony_ci 39312e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD16("0x0@0", flags, 1.0, &processed, &all_used, 39322e5b6d6dSopenharmony_ci char_separator, separator)); 39332e5b6d6dSopenharmony_ci CHECK(all_used); 39342e5b6d6dSopenharmony_ci 39352e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0x123456789), 39362e5b6d6dSopenharmony_ci StrToD16("0x1@2@3@4@5@6@7@8@9", flags, Double::NaN(), 39372e5b6d6dSopenharmony_ci &processed, &all_used, char_separator, separator)); 39382e5b6d6dSopenharmony_ci CHECK(all_used); 39392e5b6d6dSopenharmony_ci 39402e5b6d6dSopenharmony_ci CHECK_EQ(18.0, StrToD16(" 0x1@2 ", flags, 0.0, 39412e5b6d6dSopenharmony_ci &processed, &all_used, char_separator, separator)); 39422e5b6d6dSopenharmony_ci CHECK(all_used); 39432e5b6d6dSopenharmony_ci 39442e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(0xabcdef), 39452e5b6d6dSopenharmony_ci StrToD16("0xa@b@c@d@e@f", flags, 0.0, 39462e5b6d6dSopenharmony_ci &processed, &all_used, char_separator, separator)); 39472e5b6d6dSopenharmony_ci CHECK(all_used); 39482e5b6d6dSopenharmony_ci 39492e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 39502e5b6d6dSopenharmony_ci StrToD16("0x@1@2", flags, 0.0, 39512e5b6d6dSopenharmony_ci &processed, &all_used, char_separator, separator)); 39522e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 39532e5b6d6dSopenharmony_ci 39542e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 39552e5b6d6dSopenharmony_ci StrToD16("0@x0", flags, 1.0, 39562e5b6d6dSopenharmony_ci &processed, &all_used, char_separator, separator)); 39572e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 39582e5b6d6dSopenharmony_ci 39592e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 39602e5b6d6dSopenharmony_ci StrToD16("0x1@2@@3@4@5@6@7@8@9", flags, Double::NaN(), 39612e5b6d6dSopenharmony_ci &processed, &all_used, char_separator, separator)); 39622e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 39632e5b6d6dSopenharmony_ci 39642e5b6d6dSopenharmony_ci CHECK_EQ(3.0, 39652e5b6d6dSopenharmony_ci StrToD16("0x0@3p0", flags, 0.0, &processed, &all_used, 39662e5b6d6dSopenharmony_ci char_separator, separator)); 39672e5b6d6dSopenharmony_ci CHECK(all_used); 39682e5b6d6dSopenharmony_ci 39692e5b6d6dSopenharmony_ci CHECK_EQ(0.0, 39702e5b6d6dSopenharmony_ci StrToD16("0x.0@0p0", flags, 0.0, &processed, &all_used, 39712e5b6d6dSopenharmony_ci char_separator, separator)); 39722e5b6d6dSopenharmony_ci CHECK(all_used); 39732e5b6d6dSopenharmony_ci 39742e5b6d6dSopenharmony_ci CHECK_EQ(3.0, 39752e5b6d6dSopenharmony_ci StrToD16("0x3.0@0p0", flags, 0.0, &processed, &all_used, 39762e5b6d6dSopenharmony_ci char_separator, separator)); 39772e5b6d6dSopenharmony_ci CHECK(all_used); 39782e5b6d6dSopenharmony_ci 39792e5b6d6dSopenharmony_ci CHECK_EQ(3.0, 39802e5b6d6dSopenharmony_ci StrToD16("0x0@3.p0", flags, 0.0, &processed, &all_used, 39812e5b6d6dSopenharmony_ci char_separator, separator)); 39822e5b6d6dSopenharmony_ci CHECK(all_used); 39832e5b6d6dSopenharmony_ci} 39842e5b6d6dSopenharmony_ci 39852e5b6d6dSopenharmony_ciTEST(StringToDoubleSpecialValues) { 39862e5b6d6dSopenharmony_ci int processed; 39872e5b6d6dSopenharmony_ci int flags = StringToDoubleConverter::NO_FLAGS; 39882e5b6d6dSopenharmony_ci 39892e5b6d6dSopenharmony_ci { 39902e5b6d6dSopenharmony_ci // Use 1.0 as junk_string_value. 39912e5b6d6dSopenharmony_ci StringToDoubleConverter converter(flags, 0.0, 1.0, "infinity", "NaN"); 39922e5b6d6dSopenharmony_ci 39932e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), converter.StringToDouble("+NaN", 4, &processed)); 39942e5b6d6dSopenharmony_ci CHECK_EQ(4, processed); 39952e5b6d6dSopenharmony_ci 39962e5b6d6dSopenharmony_ci CHECK_EQ(-Double::Infinity(), 39972e5b6d6dSopenharmony_ci converter.StringToDouble("-infinity", 9, &processed)); 39982e5b6d6dSopenharmony_ci CHECK_EQ(9, processed); 39992e5b6d6dSopenharmony_ci 40002e5b6d6dSopenharmony_ci CHECK_EQ(1.0, converter.StringToDouble("Infinity", 8, &processed)); 40012e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 40022e5b6d6dSopenharmony_ci 40032e5b6d6dSopenharmony_ci CHECK_EQ(1.0, converter.StringToDouble("++NaN", 5, &processed)); 40042e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 40052e5b6d6dSopenharmony_ci } 40062e5b6d6dSopenharmony_ci 40072e5b6d6dSopenharmony_ci { 40082e5b6d6dSopenharmony_ci // Use 1.0 as junk_string_value. 40092e5b6d6dSopenharmony_ci StringToDoubleConverter converter(flags, 0.0, 1.0, "+infinity", "1NaN"); 40102e5b6d6dSopenharmony_ci 40112e5b6d6dSopenharmony_ci // The '+' is consumed before trying to match the infinity string. 40122e5b6d6dSopenharmony_ci CHECK_EQ(1.0, converter.StringToDouble("+infinity", 9, &processed)); 40132e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 40142e5b6d6dSopenharmony_ci 40152e5b6d6dSopenharmony_ci // The match for "1NaN" triggers, and doesn't let the 1234.0 complete. 40162e5b6d6dSopenharmony_ci CHECK_EQ(1.0, converter.StringToDouble("1234.0", 6, &processed)); 40172e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 40182e5b6d6dSopenharmony_ci } 40192e5b6d6dSopenharmony_ci} 40202e5b6d6dSopenharmony_ci 40212e5b6d6dSopenharmony_ci 40222e5b6d6dSopenharmony_ciTEST(StringToDoubleCommentExamples) { 40232e5b6d6dSopenharmony_ci // Make sure the examples in the comments are correct. 40242e5b6d6dSopenharmony_ci int flags; 40252e5b6d6dSopenharmony_ci int processed; 40262e5b6d6dSopenharmony_ci bool all_used; 40272e5b6d6dSopenharmony_ci 40282e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_HEX; 40292e5b6d6dSopenharmony_ci 40302e5b6d6dSopenharmony_ci CHECK_EQ(4660.0, StrToD("0x1234", flags, 0.0, &processed, &all_used)); 40312e5b6d6dSopenharmony_ci CHECK(all_used); 40322e5b6d6dSopenharmony_ci 40332e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 40342e5b6d6dSopenharmony_ci StrToD("0x1234.56", flags, 0.0, &processed, &all_used)); 40352e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 40362e5b6d6dSopenharmony_ci 40372e5b6d6dSopenharmony_ci flags |= StringToDoubleConverter::ALLOW_TRAILING_JUNK; 40382e5b6d6dSopenharmony_ci CHECK_EQ(4660.0, 40392e5b6d6dSopenharmony_ci StrToD("0x1234.56", flags, 0.0, &processed, &all_used)); 40402e5b6d6dSopenharmony_ci CHECK_EQ(6, processed); 40412e5b6d6dSopenharmony_ci 40422e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_OCTALS; 40432e5b6d6dSopenharmony_ci CHECK_EQ(668.0, StrToD("01234", flags, 0.0, &processed, &all_used)); 40442e5b6d6dSopenharmony_ci CHECK(all_used); 40452e5b6d6dSopenharmony_ci 40462e5b6d6dSopenharmony_ci CHECK_EQ(12349.0, StrToD("012349", flags, 0.0, &processed, &all_used)); 40472e5b6d6dSopenharmony_ci CHECK(all_used); 40482e5b6d6dSopenharmony_ci 40492e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 40502e5b6d6dSopenharmony_ci StrToD("01234.56", flags, 0.0, &processed, &all_used)); 40512e5b6d6dSopenharmony_ci CHECK_EQ(processed, 0); 40522e5b6d6dSopenharmony_ci 40532e5b6d6dSopenharmony_ci flags |= StringToDoubleConverter::ALLOW_TRAILING_JUNK; 40542e5b6d6dSopenharmony_ci CHECK_EQ(668.0, 40552e5b6d6dSopenharmony_ci StrToD("01234.56", flags, 0.0, &processed, &all_used)); 40562e5b6d6dSopenharmony_ci CHECK_EQ(processed, 5); 40572e5b6d6dSopenharmony_ci 40582e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN; 40592e5b6d6dSopenharmony_ci CHECK_EQ(-123.2, StrToD("- 123.2", flags, 0.0, &processed, &all_used)); 40602e5b6d6dSopenharmony_ci CHECK(all_used); 40612e5b6d6dSopenharmony_ci 40622e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN; 40632e5b6d6dSopenharmony_ci CHECK_EQ(123.2, StrToD("+ 123.2", flags, 0.0, &processed, &all_used)); 40642e5b6d6dSopenharmony_ci CHECK(all_used); 40652e5b6d6dSopenharmony_ci 40662e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_HEX | 40672e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_JUNK; 40682e5b6d6dSopenharmony_ci 40692e5b6d6dSopenharmony_ci CHECK_EQ(4660.0, StrToD("0x1234", flags, 0.0, &processed, &all_used)); 40702e5b6d6dSopenharmony_ci CHECK(all_used); 40712e5b6d6dSopenharmony_ci 40722e5b6d6dSopenharmony_ci CHECK_EQ(4660.0, StrToD("0x1234K", flags, 0.0, &processed, &all_used)); 40732e5b6d6dSopenharmony_ci CHECK_EQ(processed, 6); 40742e5b6d6dSopenharmony_ci 40752e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("", flags, 0.0, &processed, &all_used)); 40762e5b6d6dSopenharmony_ci CHECK(all_used); 40772e5b6d6dSopenharmony_ci 40782e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" ", flags, 0.0, &processed, &all_used)); 40792e5b6d6dSopenharmony_ci CHECK_EQ(processed, 0); 40802e5b6d6dSopenharmony_ci 40812e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD(" 1", flags, 0.0, &processed, &all_used)); 40822e5b6d6dSopenharmony_ci CHECK_EQ(processed, 0); 40832e5b6d6dSopenharmony_ci 40842e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("0x", flags, 0.0, &processed, &all_used)); 40852e5b6d6dSopenharmony_ci CHECK_EQ(processed, 0); 40862e5b6d6dSopenharmony_ci 40872e5b6d6dSopenharmony_ci CHECK_EQ(-123.45, StrToD("-123.45", flags, 0.0, &processed, &all_used)); 40882e5b6d6dSopenharmony_ci CHECK(all_used); 40892e5b6d6dSopenharmony_ci 40902e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 40912e5b6d6dSopenharmony_ci StrToD("--123.45", flags, 0.0, &processed, &all_used)); 40922e5b6d6dSopenharmony_ci CHECK_EQ(processed, 0); 40932e5b6d6dSopenharmony_ci 40942e5b6d6dSopenharmony_ci CHECK_EQ(123e45, StrToD("123e45", flags, 0.0, &processed, &all_used)); 40952e5b6d6dSopenharmony_ci CHECK(all_used); 40962e5b6d6dSopenharmony_ci 40972e5b6d6dSopenharmony_ci CHECK_EQ(123e45, StrToD("123E45", flags, 0.0, &processed, &all_used)); 40982e5b6d6dSopenharmony_ci CHECK(all_used); 40992e5b6d6dSopenharmony_ci 41002e5b6d6dSopenharmony_ci CHECK_EQ(123e45, StrToD("123e+45", flags, 0.0, &processed, &all_used)); 41012e5b6d6dSopenharmony_ci CHECK(all_used); 41022e5b6d6dSopenharmony_ci 41032e5b6d6dSopenharmony_ci CHECK_EQ(123e-45, StrToD("123e-45", flags, 0.0, &processed, &all_used)); 41042e5b6d6dSopenharmony_ci CHECK(all_used); 41052e5b6d6dSopenharmony_ci 41062e5b6d6dSopenharmony_ci CHECK_EQ(123.0, StrToD("123e", flags, 0.0, &processed, &all_used)); 41072e5b6d6dSopenharmony_ci CHECK_EQ(processed, 3); 41082e5b6d6dSopenharmony_ci 41092e5b6d6dSopenharmony_ci CHECK_EQ(123.0, StrToD("123e-", flags, 0.0, &processed, &all_used)); 41102e5b6d6dSopenharmony_ci CHECK_EQ(processed, 3); 41112e5b6d6dSopenharmony_ci 41122e5b6d6dSopenharmony_ci { 41132e5b6d6dSopenharmony_ci StringToDoubleConverter converter(flags, 0.0, 1.0, "infinity", "NaN"); 41142e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), converter.StringToDouble("+NaN", 4, &processed)); 41152e5b6d6dSopenharmony_ci CHECK_EQ(4, processed); 41162e5b6d6dSopenharmony_ci 41172e5b6d6dSopenharmony_ci CHECK_EQ(-Double::Infinity(), 41182e5b6d6dSopenharmony_ci converter.StringToDouble("-infinity", 9, &processed)); 41192e5b6d6dSopenharmony_ci CHECK_EQ(9, processed); 41202e5b6d6dSopenharmony_ci 41212e5b6d6dSopenharmony_ci CHECK_EQ(1.0, converter.StringToDouble("Infinity", 9, &processed)); 41222e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 41232e5b6d6dSopenharmony_ci } 41242e5b6d6dSopenharmony_ci 41252e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_OCTALS | 41262e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_LEADING_SPACES; 41272e5b6d6dSopenharmony_ci 41282e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("0x1234", flags, 0.0, &processed, &all_used)); 41292e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 41302e5b6d6dSopenharmony_ci 41312e5b6d6dSopenharmony_ci CHECK_EQ(668.0, StrToD("01234", flags, 0.0, &processed, &all_used)); 41322e5b6d6dSopenharmony_ci CHECK(all_used); 41332e5b6d6dSopenharmony_ci 41342e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD("", flags, 0.0, &processed, &all_used)); 41352e5b6d6dSopenharmony_ci CHECK(all_used); 41362e5b6d6dSopenharmony_ci 41372e5b6d6dSopenharmony_ci CHECK_EQ(0.0, StrToD(" ", flags, 0.0, &processed, &all_used)); 41382e5b6d6dSopenharmony_ci CHECK(all_used); 41392e5b6d6dSopenharmony_ci 41402e5b6d6dSopenharmony_ci CHECK_EQ(1.0, StrToD(" 1", flags, 0.0, &processed, &all_used)); 41412e5b6d6dSopenharmony_ci CHECK(all_used); 41422e5b6d6dSopenharmony_ci 41432e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("0x", flags, 0.0, &processed, &all_used)); 41442e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 41452e5b6d6dSopenharmony_ci 41462e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("0123e45", flags, 0.0, &processed, &all_used)); 41472e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 41482e5b6d6dSopenharmony_ci 41492e5b6d6dSopenharmony_ci CHECK_EQ(1239e45, StrToD("01239e45", flags, 0.0, &processed, &all_used)); 41502e5b6d6dSopenharmony_ci CHECK(all_used); 41512e5b6d6dSopenharmony_ci 41522e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 41532e5b6d6dSopenharmony_ci StrToD("-infinity", flags, 0.0, &processed, &all_used)); 41542e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 41552e5b6d6dSopenharmony_ci 41562e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToD("NaN", flags, 0.0, &processed, &all_used)); 41572e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 41582e5b6d6dSopenharmony_ci 41592e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::NO_FLAGS; 41602e5b6d6dSopenharmony_ci char separator = ' '; 41612e5b6d6dSopenharmony_ci CHECK_EQ(1234.0, 41622e5b6d6dSopenharmony_ci StrToD("1 2 3 4", flags, 0.0, &processed, &all_used, separator)); 41632e5b6d6dSopenharmony_ci CHECK(all_used); 41642e5b6d6dSopenharmony_ci 41652e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 41662e5b6d6dSopenharmony_ci StrToD("1 2", flags, 0.0, &processed, &all_used, separator)); 41672e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 41682e5b6d6dSopenharmony_ci 41692e5b6d6dSopenharmony_ci CHECK_EQ(1000000.0, 41702e5b6d6dSopenharmony_ci StrToD("1 000 000.0", flags, 0.0, &processed, &all_used, separator)); 41712e5b6d6dSopenharmony_ci CHECK(all_used); 41722e5b6d6dSopenharmony_ci 41732e5b6d6dSopenharmony_ci CHECK_EQ(1.0, 41742e5b6d6dSopenharmony_ci StrToD("1.000 000", flags, 0.0, &processed, &all_used, separator)); 41752e5b6d6dSopenharmony_ci CHECK(all_used); 41762e5b6d6dSopenharmony_ci 41772e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), 41782e5b6d6dSopenharmony_ci StrToD("1.0e1 000", flags, 0.0, &processed, &all_used, separator)); 41792e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 41802e5b6d6dSopenharmony_ci} 41812e5b6d6dSopenharmony_ci 41822e5b6d6dSopenharmony_ci 41832e5b6d6dSopenharmony_cistatic float StrToF16(const uc16* str16, int length, int flags, 41842e5b6d6dSopenharmony_ci double empty_string_value, 41852e5b6d6dSopenharmony_ci int* processed_characters_count, 41862e5b6d6dSopenharmony_ci bool* processed_all) { 41872e5b6d6dSopenharmony_ci StringToDoubleConverter converter(flags, empty_string_value, Double::NaN(), 41882e5b6d6dSopenharmony_ci NULL, NULL); 41892e5b6d6dSopenharmony_ci float result = 41902e5b6d6dSopenharmony_ci converter.StringToFloat(str16, length, processed_characters_count); 41912e5b6d6dSopenharmony_ci *processed_all = (length == *processed_characters_count); 41922e5b6d6dSopenharmony_ci return result; 41932e5b6d6dSopenharmony_ci} 41942e5b6d6dSopenharmony_ci 41952e5b6d6dSopenharmony_ci 41962e5b6d6dSopenharmony_cistatic float StrToF(const char* str, int flags, double empty_string_value, 41972e5b6d6dSopenharmony_ci int* processed_characters_count, bool* processed_all) { 41982e5b6d6dSopenharmony_ci StringToDoubleConverter converter(flags, empty_string_value, Single::NaN(), 41992e5b6d6dSopenharmony_ci NULL, NULL); 42002e5b6d6dSopenharmony_ci int len = static_cast<int>(strlen(str)); 42012e5b6d6dSopenharmony_ci float result = converter.StringToFloat(str, len, 42022e5b6d6dSopenharmony_ci processed_characters_count); 42032e5b6d6dSopenharmony_ci *processed_all = 42042e5b6d6dSopenharmony_ci ((strlen(str) == static_cast<unsigned>(*processed_characters_count))); 42052e5b6d6dSopenharmony_ci 42062e5b6d6dSopenharmony_ci uc16 buffer16[256]; 42072e5b6d6dSopenharmony_ci DOUBLE_CONVERSION_ASSERT(strlen(str) < DOUBLE_CONVERSION_ARRAY_SIZE(buffer16)); 42082e5b6d6dSopenharmony_ci for (int i = 0; i < len; i++) { 42092e5b6d6dSopenharmony_ci buffer16[i] = str[i]; 42102e5b6d6dSopenharmony_ci } 42112e5b6d6dSopenharmony_ci int processed_characters_count16; 42122e5b6d6dSopenharmony_ci bool processed_all16; 42132e5b6d6dSopenharmony_ci float result16 = StrToF16(buffer16, len, flags, empty_string_value, 42142e5b6d6dSopenharmony_ci &processed_characters_count16, 42152e5b6d6dSopenharmony_ci &processed_all16); 42162e5b6d6dSopenharmony_ci CHECK_EQ(result, result16); 42172e5b6d6dSopenharmony_ci CHECK_EQ(*processed_characters_count, processed_characters_count16); 42182e5b6d6dSopenharmony_ci return result; 42192e5b6d6dSopenharmony_ci} 42202e5b6d6dSopenharmony_ci 42212e5b6d6dSopenharmony_ci 42222e5b6d6dSopenharmony_ciTEST(StringToFloatVarious) { 42232e5b6d6dSopenharmony_ci int flags; 42242e5b6d6dSopenharmony_ci int processed; 42252e5b6d6dSopenharmony_ci bool all_used; 42262e5b6d6dSopenharmony_ci 42272e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_LEADING_SPACES | 42282e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN | 42292e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_SPACES; 42302e5b6d6dSopenharmony_ci 42312e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("", flags, 0.0f, &processed, &all_used)); 42322e5b6d6dSopenharmony_ci CHECK(all_used); 42332e5b6d6dSopenharmony_ci 42342e5b6d6dSopenharmony_ci CHECK_EQ(1.0f, StrToF("", flags, 1.0f, &processed, &all_used)); 42352e5b6d6dSopenharmony_ci CHECK(all_used); 42362e5b6d6dSopenharmony_ci 42372e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF(" ", flags, 0.0f, &processed, &all_used)); 42382e5b6d6dSopenharmony_ci CHECK(all_used); 42392e5b6d6dSopenharmony_ci 42402e5b6d6dSopenharmony_ci CHECK_EQ(1.0f, StrToF(" ", flags, 1.0f, &processed, &all_used)); 42412e5b6d6dSopenharmony_ci CHECK(all_used); 42422e5b6d6dSopenharmony_ci 42432e5b6d6dSopenharmony_ci CHECK_EQ(42.0f, StrToF("42", flags, 0.0f, &processed, &all_used)); 42442e5b6d6dSopenharmony_ci CHECK(all_used); 42452e5b6d6dSopenharmony_ci 42462e5b6d6dSopenharmony_ci CHECK_EQ(42.0f, StrToF(" + 42 ", flags, 0.0f, &processed, &all_used)); 42472e5b6d6dSopenharmony_ci CHECK(all_used); 42482e5b6d6dSopenharmony_ci 42492e5b6d6dSopenharmony_ci CHECK_EQ(-42.0f, StrToF(" - 42 ", flags, 0.0f, &processed, &all_used)); 42502e5b6d6dSopenharmony_ci CHECK(all_used); 42512e5b6d6dSopenharmony_ci 42522e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToF("x", flags, 1.0f, &processed, &all_used)); 42532e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 42542e5b6d6dSopenharmony_ci 42552e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToF(" x", flags, 1.0f, &processed, &all_used)); 42562e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 42572e5b6d6dSopenharmony_ci 42582e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToF("42x", flags, 0.0f, &processed, &all_used)); 42592e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 42602e5b6d6dSopenharmony_ci 42612e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToF("42 x", flags, 0.0f, &processed, &all_used)); 42622e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 42632e5b6d6dSopenharmony_ci 42642e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToF(" + 42 x", flags, 0.0f, &processed, &all_used)); 42652e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 42662e5b6d6dSopenharmony_ci 42672e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToF(" - 42 x", flags, 0.0f, &processed, &all_used)); 42682e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 42692e5b6d6dSopenharmony_ci 42702e5b6d6dSopenharmony_ci 42712e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_LEADING_SPACES | 42722e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN | 42732e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_SPACES | 42742e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_JUNK; 42752e5b6d6dSopenharmony_ci 42762e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("", flags, 0.0f, &processed, &all_used)); 42772e5b6d6dSopenharmony_ci CHECK(all_used); 42782e5b6d6dSopenharmony_ci 42792e5b6d6dSopenharmony_ci CHECK_EQ(1.0f, StrToF("", flags, 1.0f, &processed, &all_used)); 42802e5b6d6dSopenharmony_ci CHECK(all_used); 42812e5b6d6dSopenharmony_ci 42822e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF(" ", flags, 0.0f, &processed, &all_used)); 42832e5b6d6dSopenharmony_ci CHECK(all_used); 42842e5b6d6dSopenharmony_ci 42852e5b6d6dSopenharmony_ci CHECK_EQ(1.0f, StrToF(" ", flags, 1.0f, &processed, &all_used)); 42862e5b6d6dSopenharmony_ci CHECK(all_used); 42872e5b6d6dSopenharmony_ci 42882e5b6d6dSopenharmony_ci CHECK_EQ(42.0f, StrToF("42", flags, 0.0f, &processed, &all_used)); 42892e5b6d6dSopenharmony_ci CHECK(all_used); 42902e5b6d6dSopenharmony_ci 42912e5b6d6dSopenharmony_ci CHECK_EQ(42.0f, StrToF(" + 42 ", flags, 0.0f, &processed, &all_used)); 42922e5b6d6dSopenharmony_ci CHECK(all_used); 42932e5b6d6dSopenharmony_ci 42942e5b6d6dSopenharmony_ci CHECK_EQ(-42.0f, StrToF(" - 42 ", flags, 0.0f, &processed, &all_used)); 42952e5b6d6dSopenharmony_ci CHECK(all_used); 42962e5b6d6dSopenharmony_ci 42972e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToF("x", flags, 1.0f, &processed, &all_used)); 42982e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 42992e5b6d6dSopenharmony_ci 43002e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToF(" x", flags, 1.0f, &processed, &all_used)); 43012e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 43022e5b6d6dSopenharmony_ci 43032e5b6d6dSopenharmony_ci CHECK_EQ(42.0f, StrToF("42x", flags, 0.0f, &processed, &all_used)); 43042e5b6d6dSopenharmony_ci CHECK_EQ(2, processed); 43052e5b6d6dSopenharmony_ci 43062e5b6d6dSopenharmony_ci CHECK_EQ(42.0f, StrToF("42 x", flags, 0.0f, &processed, &all_used)); 43072e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 43082e5b6d6dSopenharmony_ci 43092e5b6d6dSopenharmony_ci CHECK_EQ(42.0f, StrToF(" + 42 x", flags, 0.0f, &processed, &all_used)); 43102e5b6d6dSopenharmony_ci CHECK_EQ(6, processed); 43112e5b6d6dSopenharmony_ci 43122e5b6d6dSopenharmony_ci CHECK_EQ(-42.0f, StrToF(" - 42 x", flags, 0.0f, &processed, &all_used)); 43132e5b6d6dSopenharmony_ci CHECK_EQ(6, processed); 43142e5b6d6dSopenharmony_ci 43152e5b6d6dSopenharmony_ci 43162e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_LEADING_SPACES | 43172e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN | 43182e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_JUNK; 43192e5b6d6dSopenharmony_ci 43202e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("", flags, 0.0f, &processed, &all_used)); 43212e5b6d6dSopenharmony_ci CHECK(all_used); 43222e5b6d6dSopenharmony_ci 43232e5b6d6dSopenharmony_ci CHECK_EQ(1.0f, StrToF("", flags, 1.0f, &processed, &all_used)); 43242e5b6d6dSopenharmony_ci CHECK(all_used); 43252e5b6d6dSopenharmony_ci 43262e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF(" ", flags, 0.0f, &processed, &all_used)); 43272e5b6d6dSopenharmony_ci CHECK(all_used); 43282e5b6d6dSopenharmony_ci 43292e5b6d6dSopenharmony_ci CHECK_EQ(1.0f, StrToF(" ", flags, 1.0f, &processed, &all_used)); 43302e5b6d6dSopenharmony_ci CHECK(all_used); 43312e5b6d6dSopenharmony_ci 43322e5b6d6dSopenharmony_ci CHECK_EQ(42.0f, StrToF("42", flags, 0.0f, &processed, &all_used)); 43332e5b6d6dSopenharmony_ci CHECK(all_used); 43342e5b6d6dSopenharmony_ci 43352e5b6d6dSopenharmony_ci CHECK_EQ(42.0f, StrToF(" + 42 ", flags, 0.0f, &processed, &all_used)); 43362e5b6d6dSopenharmony_ci CHECK_EQ(5, processed); 43372e5b6d6dSopenharmony_ci 43382e5b6d6dSopenharmony_ci CHECK_EQ(-42.0f, StrToF(" - 42 ", flags, 0.0f, &processed, &all_used)); 43392e5b6d6dSopenharmony_ci CHECK_EQ(5, processed); 43402e5b6d6dSopenharmony_ci 43412e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToF("x", flags, 1.0f, &processed, &all_used)); 43422e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 43432e5b6d6dSopenharmony_ci 43442e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToF(" x", flags, 1.0f, &processed, &all_used)); 43452e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 43462e5b6d6dSopenharmony_ci 43472e5b6d6dSopenharmony_ci CHECK_EQ(42.0f, StrToF("42x", flags, 0.0f, &processed, &all_used)); 43482e5b6d6dSopenharmony_ci CHECK_EQ(2, processed); 43492e5b6d6dSopenharmony_ci 43502e5b6d6dSopenharmony_ci CHECK_EQ(42.0f, StrToF("42 x", flags, 0.0f, &processed, &all_used)); 43512e5b6d6dSopenharmony_ci CHECK_EQ(2, processed); 43522e5b6d6dSopenharmony_ci 43532e5b6d6dSopenharmony_ci CHECK_EQ(42.0f, StrToF(" + 42 x", flags, 0.0f, &processed, &all_used)); 43542e5b6d6dSopenharmony_ci CHECK_EQ(5, processed); 43552e5b6d6dSopenharmony_ci 43562e5b6d6dSopenharmony_ci CHECK_EQ(-42.0f, StrToF(" - 42 x", flags, 0.0f, &processed, &all_used)); 43572e5b6d6dSopenharmony_ci CHECK_EQ(5, processed); 43582e5b6d6dSopenharmony_ci 43592e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_LEADING_SPACES | 43602e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_JUNK; 43612e5b6d6dSopenharmony_ci 43622e5b6d6dSopenharmony_ci CHECK_EQ(42.0f, StrToF(" +42 ", flags, 0.0f, &processed, &all_used)); 43632e5b6d6dSopenharmony_ci CHECK_EQ(4, processed); 43642e5b6d6dSopenharmony_ci 43652e5b6d6dSopenharmony_ci CHECK_EQ(-42.0f, StrToF(" -42 ", flags, 0.0f, &processed, &all_used)); 43662e5b6d6dSopenharmony_ci CHECK_EQ(4, processed); 43672e5b6d6dSopenharmony_ci 43682e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToF(" + 42 ", flags, 0.0f, &processed, &all_used)); 43692e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 43702e5b6d6dSopenharmony_ci 43712e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToF(" - 42 ", flags, 0.0f, &processed, &all_used)); 43722e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 43732e5b6d6dSopenharmony_ci 43742e5b6d6dSopenharmony_ci 43752e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::NO_FLAGS; 43762e5b6d6dSopenharmony_ci 43772e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("", flags, 0.0f, &processed, &all_used)); 43782e5b6d6dSopenharmony_ci CHECK(all_used); 43792e5b6d6dSopenharmony_ci 43802e5b6d6dSopenharmony_ci CHECK_EQ(1.0f, StrToF("", flags, 1.0f, &processed, &all_used)); 43812e5b6d6dSopenharmony_ci CHECK(all_used); 43822e5b6d6dSopenharmony_ci 43832e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToF(" ", flags, 0.0f, &processed, &all_used)); 43842e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 43852e5b6d6dSopenharmony_ci 43862e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToF(" ", flags, 1.0f, &processed, &all_used)); 43872e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 43882e5b6d6dSopenharmony_ci 43892e5b6d6dSopenharmony_ci CHECK_EQ(42.0f, StrToF("42", flags, 0.0f, &processed, &all_used)); 43902e5b6d6dSopenharmony_ci CHECK(all_used); 43912e5b6d6dSopenharmony_ci 43922e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToF(" + 42 ", flags, 0.0f, &processed, &all_used)); 43932e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 43942e5b6d6dSopenharmony_ci 43952e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToF(" - 42 ", flags, 0.0f, &processed, &all_used)); 43962e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 43972e5b6d6dSopenharmony_ci 43982e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToF("x", flags, 1.0f, &processed, &all_used)); 43992e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 44002e5b6d6dSopenharmony_ci 44012e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToF(" x", flags, 1.0f, &processed, &all_used)); 44022e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 44032e5b6d6dSopenharmony_ci 44042e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToF("42x", flags, 0.0f, &processed, &all_used)); 44052e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 44062e5b6d6dSopenharmony_ci 44072e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToF("42 x", flags, 0.0f, &processed, &all_used)); 44082e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 44092e5b6d6dSopenharmony_ci 44102e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToF(" + 42 x", flags, 0.0f, &processed, &all_used)); 44112e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 44122e5b6d6dSopenharmony_ci 44132e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToF(" - 42 x", flags, 0.0f, &processed, &all_used)); 44142e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 44152e5b6d6dSopenharmony_ci 44162e5b6d6dSopenharmony_ci 44172e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_LEADING_SPACES; 44182e5b6d6dSopenharmony_ci 44192e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF(" ", flags, 0.0f, &processed, &all_used)); 44202e5b6d6dSopenharmony_ci CHECK(all_used); 44212e5b6d6dSopenharmony_ci 44222e5b6d6dSopenharmony_ci CHECK_EQ(1.0f, StrToF(" ", flags, 1.0f, &processed, &all_used)); 44232e5b6d6dSopenharmony_ci CHECK(all_used); 44242e5b6d6dSopenharmony_ci 44252e5b6d6dSopenharmony_ci CHECK_EQ(42.0f, StrToF(" 42", flags, 0.0f, &processed, &all_used)); 44262e5b6d6dSopenharmony_ci CHECK(all_used); 44272e5b6d6dSopenharmony_ci 44282e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToF("42 ", flags, 0.0f, &processed, &all_used)); 44292e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 44302e5b6d6dSopenharmony_ci 44312e5b6d6dSopenharmony_ci 44322e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_TRAILING_SPACES; 44332e5b6d6dSopenharmony_ci 44342e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF(" ", flags, 0.0f, &processed, &all_used)); 44352e5b6d6dSopenharmony_ci CHECK(all_used); 44362e5b6d6dSopenharmony_ci 44372e5b6d6dSopenharmony_ci CHECK_EQ(1.0f, StrToF(" ", flags, 1.0f, &processed, &all_used)); 44382e5b6d6dSopenharmony_ci CHECK(all_used); 44392e5b6d6dSopenharmony_ci 44402e5b6d6dSopenharmony_ci CHECK_EQ(42.0f, StrToF("42 ", flags, 0.0f, &processed, &all_used)); 44412e5b6d6dSopenharmony_ci CHECK(all_used); 44422e5b6d6dSopenharmony_ci 44432e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), StrToF(" 42", flags, 0.0f, &processed, &all_used)); 44442e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 44452e5b6d6dSopenharmony_ci} 44462e5b6d6dSopenharmony_ci 44472e5b6d6dSopenharmony_ciTEST(StringToFloatEmptyString) { 44482e5b6d6dSopenharmony_ci int flags; 44492e5b6d6dSopenharmony_ci int processed; 44502e5b6d6dSopenharmony_ci bool all_used; 44512e5b6d6dSopenharmony_ci 44522e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::NO_FLAGS; 44532e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("", flags, 0.0f, &processed, &all_used)); 44542e5b6d6dSopenharmony_ci CHECK(all_used); 44552e5b6d6dSopenharmony_ci 44562e5b6d6dSopenharmony_ci CHECK_EQ(1.0f, StrToF("", flags, 1.0f, &processed, &all_used)); 44572e5b6d6dSopenharmony_ci CHECK(all_used); 44582e5b6d6dSopenharmony_ci 44592e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("", flags, Single::NaN(), 44602e5b6d6dSopenharmony_ci &processed, &all_used)); 44612e5b6d6dSopenharmony_ci CHECK(all_used); 44622e5b6d6dSopenharmony_ci 44632e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" ", flags, 0.0f, &processed, &all_used)); 44642e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 44652e5b6d6dSopenharmony_ci 44662e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" ", flags, 1.0f, &processed, &all_used)); 44672e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 44682e5b6d6dSopenharmony_ci 44692e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" ", flags, Single::NaN(), 44702e5b6d6dSopenharmony_ci &processed, &all_used)); 44712e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 44722e5b6d6dSopenharmony_ci 44732e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN; 44742e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("", flags, 0.0f, &processed, &all_used)); 44752e5b6d6dSopenharmony_ci CHECK(all_used); 44762e5b6d6dSopenharmony_ci 44772e5b6d6dSopenharmony_ci CHECK_EQ(1.0f, StrToF("", flags, 1.0f, &processed, &all_used)); 44782e5b6d6dSopenharmony_ci CHECK(all_used); 44792e5b6d6dSopenharmony_ci 44802e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("", flags, Single::NaN(), 44812e5b6d6dSopenharmony_ci &processed, &all_used)); 44822e5b6d6dSopenharmony_ci CHECK(all_used); 44832e5b6d6dSopenharmony_ci 44842e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" ", flags, 0.0f, &processed, &all_used)); 44852e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 44862e5b6d6dSopenharmony_ci 44872e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" ", flags, 1.0f, &processed, &all_used)); 44882e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 44892e5b6d6dSopenharmony_ci 44902e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" ", flags, Single::NaN(), 44912e5b6d6dSopenharmony_ci &processed, &all_used)); 44922e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 44932e5b6d6dSopenharmony_ci 44942e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_LEADING_SPACES; 44952e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("", flags, 0.0f, &processed, &all_used)); 44962e5b6d6dSopenharmony_ci CHECK(all_used); 44972e5b6d6dSopenharmony_ci 44982e5b6d6dSopenharmony_ci CHECK_EQ(1.0f, StrToF("", flags, 1.0f, &processed, &all_used)); 44992e5b6d6dSopenharmony_ci CHECK(all_used); 45002e5b6d6dSopenharmony_ci 45012e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("", flags, Single::NaN(), 45022e5b6d6dSopenharmony_ci &processed, &all_used)); 45032e5b6d6dSopenharmony_ci CHECK(all_used); 45042e5b6d6dSopenharmony_ci 45052e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF(" ", flags, 0.0f, &processed, &all_used)); 45062e5b6d6dSopenharmony_ci CHECK(all_used); 45072e5b6d6dSopenharmony_ci 45082e5b6d6dSopenharmony_ci CHECK_EQ(1.0f, StrToF(" ", flags, 1.0f, &processed, &all_used)); 45092e5b6d6dSopenharmony_ci CHECK(all_used); 45102e5b6d6dSopenharmony_ci 45112e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" ", flags, Single::NaN(), 45122e5b6d6dSopenharmony_ci &processed, &all_used)); 45132e5b6d6dSopenharmony_ci CHECK(all_used); 45142e5b6d6dSopenharmony_ci 45152e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_TRAILING_SPACES; 45162e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("", flags, 0.0f, &processed, &all_used)); 45172e5b6d6dSopenharmony_ci CHECK(all_used); 45182e5b6d6dSopenharmony_ci 45192e5b6d6dSopenharmony_ci CHECK_EQ(1.0f, StrToF("", flags, 1.0f, &processed, &all_used)); 45202e5b6d6dSopenharmony_ci CHECK(all_used); 45212e5b6d6dSopenharmony_ci 45222e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("", flags, Single::NaN(), 45232e5b6d6dSopenharmony_ci &processed, &all_used)); 45242e5b6d6dSopenharmony_ci CHECK(all_used); 45252e5b6d6dSopenharmony_ci 45262e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF(" ", flags, 0.0f, &processed, &all_used)); 45272e5b6d6dSopenharmony_ci CHECK(all_used); 45282e5b6d6dSopenharmony_ci 45292e5b6d6dSopenharmony_ci CHECK_EQ(1.0f, StrToF(" ", flags, 1.0f, &processed, &all_used)); 45302e5b6d6dSopenharmony_ci CHECK(all_used); 45312e5b6d6dSopenharmony_ci 45322e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" ", flags, Single::NaN(), 45332e5b6d6dSopenharmony_ci &processed, &all_used)); 45342e5b6d6dSopenharmony_ci CHECK(all_used); 45352e5b6d6dSopenharmony_ci 45362e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_TRAILING_JUNK; 45372e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("", flags, 0.0f, &processed, &all_used)); 45382e5b6d6dSopenharmony_ci CHECK(all_used); 45392e5b6d6dSopenharmony_ci 45402e5b6d6dSopenharmony_ci CHECK_EQ(1.0f, StrToF("", flags, 1.0f, &processed, &all_used)); 45412e5b6d6dSopenharmony_ci CHECK(all_used); 45422e5b6d6dSopenharmony_ci 45432e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("", flags, Single::NaN(), 45442e5b6d6dSopenharmony_ci &processed, &all_used)); 45452e5b6d6dSopenharmony_ci CHECK(all_used); 45462e5b6d6dSopenharmony_ci 45472e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" ", flags, 0.0f, &processed, &all_used)); 45482e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 45492e5b6d6dSopenharmony_ci 45502e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" ", flags, 1.0f, &processed, &all_used)); 45512e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 45522e5b6d6dSopenharmony_ci 45532e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" ", flags, Single::NaN(), 45542e5b6d6dSopenharmony_ci &processed, &all_used)); 45552e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 45562e5b6d6dSopenharmony_ci 45572e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("x", flags, 0.0f, &processed, &all_used)); 45582e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 45592e5b6d6dSopenharmony_ci 45602e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" x", flags, 0.0f, &processed, &all_used)); 45612e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 45622e5b6d6dSopenharmony_ci} 45632e5b6d6dSopenharmony_ci 45642e5b6d6dSopenharmony_ciTEST(StringToFloatHexString) { 45652e5b6d6dSopenharmony_ci int flags; 45662e5b6d6dSopenharmony_ci int processed; 45672e5b6d6dSopenharmony_ci bool all_used; 45682e5b6d6dSopenharmony_ci double d; 45692e5b6d6dSopenharmony_ci float f; 45702e5b6d6dSopenharmony_ci 45712e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_HEX | 45722e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_LEADING_SPACES | 45732e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_SPACES | 45742e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN; 45752e5b6d6dSopenharmony_ci 45762e5b6d6dSopenharmony_ci // Check that no double rounding occurs: 45772e5b6d6dSopenharmony_ci const char* double_rounding_example1 = "0x100000100000008"; 45782e5b6d6dSopenharmony_ci d = StrToD(double_rounding_example1, flags, 0.0, &processed, &all_used); 45792e5b6d6dSopenharmony_ci f = StrToF(double_rounding_example1, flags, 0.0f, &processed, &all_used); 45802e5b6d6dSopenharmony_ci CHECK(f != static_cast<float>(d)); 45812e5b6d6dSopenharmony_ci CHECK_EQ(72057602627862528.0f, StrToF(double_rounding_example1, 45822e5b6d6dSopenharmony_ci flags, 0.0f, &processed, &all_used)); 45832e5b6d6dSopenharmony_ci CHECK(all_used); 45842e5b6d6dSopenharmony_ci 45852e5b6d6dSopenharmony_ci const char* double_rounding_example2 = "0x1000002FFFFFFF8"; 45862e5b6d6dSopenharmony_ci d = StrToD(double_rounding_example2, flags, 0.0, &processed, &all_used); 45872e5b6d6dSopenharmony_ci f = StrToF(double_rounding_example2, flags, 0.0f, &processed, &all_used); 45882e5b6d6dSopenharmony_ci CHECK(f != static_cast<float>(d)); 45892e5b6d6dSopenharmony_ci CHECK_EQ(72057602627862528.0f, StrToF(double_rounding_example2, 45902e5b6d6dSopenharmony_ci flags, 0.0f, &processed, &all_used)); 45912e5b6d6dSopenharmony_ci CHECK(all_used); 45922e5b6d6dSopenharmony_ci 45932e5b6d6dSopenharmony_ci CHECK_EQ(18.0f, StrToF("0x12", flags, 0.0f, &processed, &all_used)); 45942e5b6d6dSopenharmony_ci CHECK(all_used); 45952e5b6d6dSopenharmony_ci 45962e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("0x0", flags, 1.0f, &processed, &all_used)); 45972e5b6d6dSopenharmony_ci CHECK(all_used); 45982e5b6d6dSopenharmony_ci 45992e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(0x123456789), 46002e5b6d6dSopenharmony_ci StrToF("0x123456789", flags, Single::NaN(), &processed, &all_used)); 46012e5b6d6dSopenharmony_ci CHECK(all_used); 46022e5b6d6dSopenharmony_ci 46032e5b6d6dSopenharmony_ci CHECK_EQ(18.0f, StrToF(" 0x12 ", flags, 0.0f, &processed, &all_used)); 46042e5b6d6dSopenharmony_ci CHECK(all_used); 46052e5b6d6dSopenharmony_ci 46062e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF(" 0x0 ", flags, 1.0f, &processed, &all_used)); 46072e5b6d6dSopenharmony_ci CHECK(all_used); 46082e5b6d6dSopenharmony_ci 46092e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(0x123456789), 46102e5b6d6dSopenharmony_ci StrToF(" 0x123456789 ", flags, Single::NaN(), 46112e5b6d6dSopenharmony_ci &processed, &all_used)); 46122e5b6d6dSopenharmony_ci CHECK(all_used); 46132e5b6d6dSopenharmony_ci 46142e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(0xabcdef), 46152e5b6d6dSopenharmony_ci StrToF("0xabcdef", flags, 0.0f, &processed, &all_used)); 46162e5b6d6dSopenharmony_ci CHECK(all_used); 46172e5b6d6dSopenharmony_ci 46182e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(0xabcdef), 46192e5b6d6dSopenharmony_ci StrToF("0xABCDEF", flags, 0.0f, &processed, &all_used)); 46202e5b6d6dSopenharmony_ci CHECK(all_used); 46212e5b6d6dSopenharmony_ci 46222e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(0xabcdef), 46232e5b6d6dSopenharmony_ci StrToF(" 0xabcdef ", flags, 0.0f, &processed, &all_used)); 46242e5b6d6dSopenharmony_ci CHECK(all_used); 46252e5b6d6dSopenharmony_ci 46262e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(0xabcdef), 46272e5b6d6dSopenharmony_ci StrToF(" 0xABCDEF ", flags, 0.0f, &processed, &all_used)); 46282e5b6d6dSopenharmony_ci CHECK(all_used); 46292e5b6d6dSopenharmony_ci 46302e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" ", flags, Single::NaN(), 46312e5b6d6dSopenharmony_ci &processed, &all_used)); 46322e5b6d6dSopenharmony_ci CHECK(all_used); 46332e5b6d6dSopenharmony_ci 46342e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("0x", flags, 0.0f, 46352e5b6d6dSopenharmony_ci &processed, &all_used)); 46362e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 46372e5b6d6dSopenharmony_ci 46382e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 0x ", flags, 0.0f, 46392e5b6d6dSopenharmony_ci &processed, &all_used)); 46402e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 46412e5b6d6dSopenharmony_ci 46422e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 0x 3", flags, 0.0f, 46432e5b6d6dSopenharmony_ci &processed, &all_used)); 46442e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 46452e5b6d6dSopenharmony_ci 46462e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("0x3g", flags, 0.0f, 46472e5b6d6dSopenharmony_ci &processed, &all_used)); 46482e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 46492e5b6d6dSopenharmony_ci 46502e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("0x3.23", flags, 0.0f, 46512e5b6d6dSopenharmony_ci &processed, &all_used)); 46522e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 46532e5b6d6dSopenharmony_ci 46542e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("x3", flags, 0.0f, 46552e5b6d6dSopenharmony_ci &processed, &all_used)); 46562e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 46572e5b6d6dSopenharmony_ci 46582e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("0x3 foo", flags, 0.0f, 46592e5b6d6dSopenharmony_ci &processed, &all_used)); 46602e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 46612e5b6d6dSopenharmony_ci 46622e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 0x3 foo", flags, 0.0f, 46632e5b6d6dSopenharmony_ci &processed, &all_used)); 46642e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 46652e5b6d6dSopenharmony_ci 46662e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("+ 0x3 foo", flags, 0.0f, 46672e5b6d6dSopenharmony_ci &processed, &all_used)); 46682e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 46692e5b6d6dSopenharmony_ci 46702e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("+", flags, 0.0f, &processed, &all_used)); 46712e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 46722e5b6d6dSopenharmony_ci 46732e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("-", flags, 0.0f, &processed, &all_used)); 46742e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 46752e5b6d6dSopenharmony_ci 46762e5b6d6dSopenharmony_ci CHECK_EQ(-5.0f, StrToF("-0x5", flags, 0.0f, &processed, &all_used)); 46772e5b6d6dSopenharmony_ci CHECK(all_used); 46782e5b6d6dSopenharmony_ci 46792e5b6d6dSopenharmony_ci CHECK_EQ(-5.0f, StrToF(" - 0x5 ", flags, 0.0f, &processed, &all_used)); 46802e5b6d6dSopenharmony_ci CHECK(all_used); 46812e5b6d6dSopenharmony_ci 46822e5b6d6dSopenharmony_ci CHECK_EQ(5.0f, StrToF(" + 0x5 ", flags, 0.0f, &processed, &all_used)); 46832e5b6d6dSopenharmony_ci CHECK(all_used); 46842e5b6d6dSopenharmony_ci 46852e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("- -0x5", flags, 0.0f, 46862e5b6d6dSopenharmony_ci &processed, &all_used)); 46872e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 46882e5b6d6dSopenharmony_ci 46892e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("- +0x5", flags, 0.0f, 46902e5b6d6dSopenharmony_ci &processed, &all_used)); 46912e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 46922e5b6d6dSopenharmony_ci 46932e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("+ +0x5", flags, 0.0f, 46942e5b6d6dSopenharmony_ci &processed, &all_used)); 46952e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 46962e5b6d6dSopenharmony_ci 46972e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("0x3p0", flags, 0.0f, &processed, &all_used)); 46982e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 46992e5b6d6dSopenharmony_ci 47002e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("0x.0p0", flags, 0.0f, &processed, &all_used)); 47012e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 47022e5b6d6dSopenharmony_ci 47032e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("0x3.0p0", flags, 0.0f, 47042e5b6d6dSopenharmony_ci &processed, &all_used)); 47052e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 47062e5b6d6dSopenharmony_ci 47072e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("0x3.p0", flags, 0.0f, 47082e5b6d6dSopenharmony_ci &processed, &all_used)); 47092e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 47102e5b6d6dSopenharmony_ci 47112e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_HEX; 47122e5b6d6dSopenharmony_ci 47132e5b6d6dSopenharmony_ci CHECK_EQ(18.0f, StrToF("0x12", flags, 0.0f, &processed, &all_used)); 47142e5b6d6dSopenharmony_ci CHECK(all_used); 47152e5b6d6dSopenharmony_ci 47162e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("0x0", flags, 1.0f, &processed, &all_used)); 47172e5b6d6dSopenharmony_ci CHECK(all_used); 47182e5b6d6dSopenharmony_ci 47192e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(0x123456789), 47202e5b6d6dSopenharmony_ci StrToF("0x123456789", flags, Single::NaN(), &processed, &all_used)); 47212e5b6d6dSopenharmony_ci CHECK(all_used); 47222e5b6d6dSopenharmony_ci 47232e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 0x12 ", flags, 0.0f, &processed, &all_used)); 47242e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 47252e5b6d6dSopenharmony_ci 47262e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 0x0 ", flags, 1.0f, &processed, &all_used)); 47272e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 47282e5b6d6dSopenharmony_ci 47292e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 0x123456789 ", flags, Single::NaN(), 47302e5b6d6dSopenharmony_ci &processed, &all_used)); 47312e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 47322e5b6d6dSopenharmony_ci 47332e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(0xabcdef), 47342e5b6d6dSopenharmony_ci StrToF("0xabcdef", flags, 0.0f, &processed, &all_used)); 47352e5b6d6dSopenharmony_ci CHECK(all_used); 47362e5b6d6dSopenharmony_ci 47372e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(0xabcdef), 47382e5b6d6dSopenharmony_ci StrToF("0xABCDEF", flags, 0.0f, &processed, &all_used)); 47392e5b6d6dSopenharmony_ci CHECK(all_used); 47402e5b6d6dSopenharmony_ci 47412e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 47422e5b6d6dSopenharmony_ci StrToF(" 0xabcdef ", flags, 0.0f, &processed, &all_used)); 47432e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 47442e5b6d6dSopenharmony_ci 47452e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 47462e5b6d6dSopenharmony_ci StrToF(" 0xABCDEF ", flags, 0.0f, &processed, &all_used)); 47472e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 47482e5b6d6dSopenharmony_ci 47492e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 47502e5b6d6dSopenharmony_ci StrToF(" ", flags, 0.0f, &processed, &all_used)); 47512e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 47522e5b6d6dSopenharmony_ci 47532e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("0x", flags, 0.0f, 47542e5b6d6dSopenharmony_ci &processed, &all_used)); 47552e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 47562e5b6d6dSopenharmony_ci 47572e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 0x ", flags, 0.0f, 47582e5b6d6dSopenharmony_ci &processed, &all_used)); 47592e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 47602e5b6d6dSopenharmony_ci 47612e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 0x 3", flags, 0.0f, 47622e5b6d6dSopenharmony_ci &processed, &all_used)); 47632e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 47642e5b6d6dSopenharmony_ci 47652e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("0x3g", flags, 0.0f, 47662e5b6d6dSopenharmony_ci &processed, &all_used)); 47672e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 47682e5b6d6dSopenharmony_ci 47692e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("0x3.23", flags, 0.0f, 47702e5b6d6dSopenharmony_ci &processed, &all_used)); 47712e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 47722e5b6d6dSopenharmony_ci 47732e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("x3", flags, 0.0f, 47742e5b6d6dSopenharmony_ci &processed, &all_used)); 47752e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 47762e5b6d6dSopenharmony_ci 47772e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("+ 0x3 foo", flags, 0.0f, 47782e5b6d6dSopenharmony_ci &processed, &all_used)); 47792e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 47802e5b6d6dSopenharmony_ci 47812e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("+", flags, 0.0f, &processed, &all_used)); 47822e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 47832e5b6d6dSopenharmony_ci 47842e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("-", flags, 0.0f, &processed, &all_used)); 47852e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 47862e5b6d6dSopenharmony_ci 47872e5b6d6dSopenharmony_ci CHECK_EQ(-5.0f, StrToF("-0x5", flags, 0.0f, &processed, &all_used)); 47882e5b6d6dSopenharmony_ci CHECK(all_used); 47892e5b6d6dSopenharmony_ci 47902e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" - 0x5 ", flags, 0.0f, &processed, &all_used)); 47912e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 47922e5b6d6dSopenharmony_ci 47932e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" + 0x5 ", flags, 0.0f, &processed, &all_used)); 47942e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 47952e5b6d6dSopenharmony_ci 47962e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("- -0x5", flags, 0.0f, &processed, &all_used)); 47972e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 47982e5b6d6dSopenharmony_ci 47992e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("- +0x5", flags, 0.0f, &processed, &all_used)); 48002e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 48012e5b6d6dSopenharmony_ci 48022e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("+ +0x5", flags, 0.0f, &processed, &all_used)); 48032e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 48042e5b6d6dSopenharmony_ci 48052e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("0x3p0", flags, 0.0f, &processed, &all_used)); 48062e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 48072e5b6d6dSopenharmony_ci 48082e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("0x.0p0", flags, 0.0f, &processed, &all_used)); 48092e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 48102e5b6d6dSopenharmony_ci 48112e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("0x3.0p0", flags, 0.0f, 48122e5b6d6dSopenharmony_ci &processed, &all_used)); 48132e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 48142e5b6d6dSopenharmony_ci 48152e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("0x3.p0", flags, 0.0f, 48162e5b6d6dSopenharmony_ci &processed, &all_used)); 48172e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 48182e5b6d6dSopenharmony_ci 48192e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_TRAILING_JUNK | 48202e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_HEX; 48212e5b6d6dSopenharmony_ci 48222e5b6d6dSopenharmony_ci CHECK_EQ(18.0f, StrToF("0x12", flags, 0.0f, &processed, &all_used)); 48232e5b6d6dSopenharmony_ci CHECK(all_used); 48242e5b6d6dSopenharmony_ci 48252e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("0x0", flags, 1.0f, &processed, &all_used)); 48262e5b6d6dSopenharmony_ci CHECK(all_used); 48272e5b6d6dSopenharmony_ci 48282e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(0x123456789), 48292e5b6d6dSopenharmony_ci StrToF("0x123456789", flags, Single::NaN(), &processed, &all_used)); 48302e5b6d6dSopenharmony_ci CHECK(all_used); 48312e5b6d6dSopenharmony_ci 48322e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 0x12 ", flags, 0.0f, &processed, &all_used)); 48332e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 48342e5b6d6dSopenharmony_ci 48352e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 0x0 ", flags, 1.0f, &processed, &all_used)); 48362e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 48372e5b6d6dSopenharmony_ci 48382e5b6d6dSopenharmony_ci CHECK_EQ(18.0f, StrToF("0x12 ", flags, 0.0f, &processed, &all_used)); 48392e5b6d6dSopenharmony_ci CHECK_EQ(4, processed); 48402e5b6d6dSopenharmony_ci 48412e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("0x0 ", flags, 1.0f, &processed, &all_used)); 48422e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 48432e5b6d6dSopenharmony_ci 48442e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 48452e5b6d6dSopenharmony_ci StrToF(" 0x123456789 ", flags, Single::NaN(), 48462e5b6d6dSopenharmony_ci &processed, &all_used)); 48472e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 48482e5b6d6dSopenharmony_ci 48492e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(0xabcdef), 48502e5b6d6dSopenharmony_ci StrToF("0xabcdef", flags, 0.0f, &processed, &all_used)); 48512e5b6d6dSopenharmony_ci CHECK(all_used); 48522e5b6d6dSopenharmony_ci 48532e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(0xabcdef), 48542e5b6d6dSopenharmony_ci StrToF("0xABCDEF", flags, 0.0f, &processed, &all_used)); 48552e5b6d6dSopenharmony_ci CHECK(all_used); 48562e5b6d6dSopenharmony_ci 48572e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 48582e5b6d6dSopenharmony_ci StrToF(" 0xabcdef ", flags, 0.0f, &processed, &all_used)); 48592e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 48602e5b6d6dSopenharmony_ci 48612e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 48622e5b6d6dSopenharmony_ci StrToF(" 0xABCDEF ", flags, 0.0f, &processed, &all_used)); 48632e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 48642e5b6d6dSopenharmony_ci 48652e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(0xabcdef), 48662e5b6d6dSopenharmony_ci StrToF("0xabcdef ", flags, 0.0f, &processed, &all_used)); 48672e5b6d6dSopenharmony_ci CHECK_EQ(8, processed); 48682e5b6d6dSopenharmony_ci 48692e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(0xabcdef), 48702e5b6d6dSopenharmony_ci StrToF("0xABCDEF ", flags, 0.0f, &processed, &all_used)); 48712e5b6d6dSopenharmony_ci CHECK_EQ(8, processed); 48722e5b6d6dSopenharmony_ci 48732e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 48742e5b6d6dSopenharmony_ci StrToF(" 0xabcdef", flags, 0.0f, &processed, &all_used)); 48752e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 48762e5b6d6dSopenharmony_ci 48772e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 48782e5b6d6dSopenharmony_ci StrToF(" 0xABCDEF", flags, 0.0f, &processed, &all_used)); 48792e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 48802e5b6d6dSopenharmony_ci 48812e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" ", flags, 0.0f, &processed, &all_used)); 48822e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 48832e5b6d6dSopenharmony_ci 48842e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("0x", flags, 0.0f, 48852e5b6d6dSopenharmony_ci &processed, &all_used)); 48862e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 48872e5b6d6dSopenharmony_ci 48882e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 0x ", flags, 0.0f, 48892e5b6d6dSopenharmony_ci &processed, &all_used)); 48902e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 48912e5b6d6dSopenharmony_ci 48922e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 0x 3", flags, 0.0f, 48932e5b6d6dSopenharmony_ci &processed, &all_used)); 48942e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 48952e5b6d6dSopenharmony_ci 48962e5b6d6dSopenharmony_ci CHECK_EQ(3.0f, StrToF("0x3g", flags, 0.0f, &processed, &all_used)); 48972e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 48982e5b6d6dSopenharmony_ci 48992e5b6d6dSopenharmony_ci CHECK_EQ(3.0f, StrToF("0x3.234", flags, 0.0f, &processed, &all_used)); 49002e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 49012e5b6d6dSopenharmony_ci 49022e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 0x3g", flags, 0.0f, &processed, &all_used)); 49032e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 49042e5b6d6dSopenharmony_ci 49052e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 49062e5b6d6dSopenharmony_ci StrToF(" 0x3.234", flags, 0.0f, &processed, &all_used)); 49072e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 49082e5b6d6dSopenharmony_ci 49092e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("x3", flags, 0.0f, 49102e5b6d6dSopenharmony_ci &processed, &all_used)); 49112e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 49122e5b6d6dSopenharmony_ci 49132e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("+ 0x3 foo", flags, 0.0f, 49142e5b6d6dSopenharmony_ci &processed, &all_used)); 49152e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 49162e5b6d6dSopenharmony_ci 49172e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("+", flags, 0.0f, &processed, &all_used)); 49182e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 49192e5b6d6dSopenharmony_ci 49202e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("-", flags, 0.0f, &processed, &all_used)); 49212e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 49222e5b6d6dSopenharmony_ci 49232e5b6d6dSopenharmony_ci CHECK_EQ(-5.0f, StrToF("-0x5", flags, 0.0f, &processed, &all_used)); 49242e5b6d6dSopenharmony_ci CHECK(all_used); 49252e5b6d6dSopenharmony_ci 49262e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" - 0x5 ", flags, 0.0f, &processed, &all_used)); 49272e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 49282e5b6d6dSopenharmony_ci 49292e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" + 0x5 ", flags, 0.0f, &processed, &all_used)); 49302e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 49312e5b6d6dSopenharmony_ci 49322e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("- -0x5", flags, 0.0f, &processed, &all_used)); 49332e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 49342e5b6d6dSopenharmony_ci 49352e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("- +0x5", flags, 0.0f, &processed, &all_used)); 49362e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 49372e5b6d6dSopenharmony_ci 49382e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("+ +0x5", flags, 0.0f, &processed, &all_used)); 49392e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 49402e5b6d6dSopenharmony_ci 49412e5b6d6dSopenharmony_ci CHECK_EQ(3.0f, StrToF("0x3p0", flags, 0.0f, &processed, &all_used)); 49422e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 49432e5b6d6dSopenharmony_ci 49442e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("0x.0p0", flags, 0.0f, &processed, &all_used)); 49452e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 49462e5b6d6dSopenharmony_ci 49472e5b6d6dSopenharmony_ci CHECK_EQ(3.0f, StrToF("0x3.0p0", flags, 0.0f, &processed, &all_used)); 49482e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 49492e5b6d6dSopenharmony_ci 49502e5b6d6dSopenharmony_ci CHECK_EQ(3.0f, StrToF("0x3.p0", flags, 0.0f, &processed, &all_used)); 49512e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 49522e5b6d6dSopenharmony_ci 49532e5b6d6dSopenharmony_ci 49542e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_TRAILING_JUNK | 49552e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_LEADING_SPACES | 49562e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_SPACES | 49572e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN | 49582e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_HEX; 49592e5b6d6dSopenharmony_ci 49602e5b6d6dSopenharmony_ci CHECK_EQ(18.0f, StrToF("0x12", flags, 0.0f, &processed, &all_used)); 49612e5b6d6dSopenharmony_ci CHECK(all_used); 49622e5b6d6dSopenharmony_ci 49632e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("0x0", flags, 1.0f, &processed, &all_used)); 49642e5b6d6dSopenharmony_ci CHECK(all_used); 49652e5b6d6dSopenharmony_ci 49662e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(0x123456789), 49672e5b6d6dSopenharmony_ci StrToF("0x123456789", flags, Single::NaN(), &processed, &all_used)); 49682e5b6d6dSopenharmony_ci CHECK(all_used); 49692e5b6d6dSopenharmony_ci 49702e5b6d6dSopenharmony_ci CHECK_EQ(18.0f, StrToF(" 0x12 ", flags, 0.0f, &processed, &all_used)); 49712e5b6d6dSopenharmony_ci CHECK(all_used); 49722e5b6d6dSopenharmony_ci 49732e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF(" 0x0 ", flags, 1.0f, &processed, &all_used)); 49742e5b6d6dSopenharmony_ci CHECK(all_used); 49752e5b6d6dSopenharmony_ci 49762e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(0x123456789), 49772e5b6d6dSopenharmony_ci StrToF(" 0x123456789 ", flags, Single::NaN(), 49782e5b6d6dSopenharmony_ci &processed, &all_used)); 49792e5b6d6dSopenharmony_ci CHECK(all_used); 49802e5b6d6dSopenharmony_ci 49812e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(0xabcdef), 49822e5b6d6dSopenharmony_ci StrToF("0xabcdef", flags, 0.0f, &processed, &all_used)); 49832e5b6d6dSopenharmony_ci CHECK(all_used); 49842e5b6d6dSopenharmony_ci 49852e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(0xabcdef), 49862e5b6d6dSopenharmony_ci StrToF("0xABCDEF", flags, 0.0f, &processed, &all_used)); 49872e5b6d6dSopenharmony_ci CHECK(all_used); 49882e5b6d6dSopenharmony_ci 49892e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(0xabcdef), 49902e5b6d6dSopenharmony_ci StrToF(" 0xabcdef ", flags, 0.0f, &processed, &all_used)); 49912e5b6d6dSopenharmony_ci CHECK(all_used); 49922e5b6d6dSopenharmony_ci 49932e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(0xabcdef), 49942e5b6d6dSopenharmony_ci StrToF(" 0xABCDEF ", flags, 0.0f, &processed, &all_used)); 49952e5b6d6dSopenharmony_ci CHECK(all_used); 49962e5b6d6dSopenharmony_ci 49972e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(0xabc), 49982e5b6d6dSopenharmony_ci StrToF(" 0xabc def ", flags, 0.0f, &processed, &all_used)); 49992e5b6d6dSopenharmony_ci CHECK_EQ(7, processed); 50002e5b6d6dSopenharmony_ci 50012e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(0xabc), 50022e5b6d6dSopenharmony_ci StrToF(" 0xABC DEF ", flags, 0.0f, &processed, &all_used)); 50032e5b6d6dSopenharmony_ci CHECK_EQ(7, processed); 50042e5b6d6dSopenharmony_ci 50052e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(0x12), 50062e5b6d6dSopenharmony_ci StrToF(" 0x12 ", flags, 0.0f, &processed, &all_used)); 50072e5b6d6dSopenharmony_ci CHECK(all_used); 50082e5b6d6dSopenharmony_ci 50092e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF(" 0x0 ", flags, 1.0f, &processed, &all_used)); 50102e5b6d6dSopenharmony_ci CHECK(all_used); 50112e5b6d6dSopenharmony_ci 50122e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(0x123456789), 50132e5b6d6dSopenharmony_ci StrToF(" 0x123456789 ", flags, Single::NaN(), 50142e5b6d6dSopenharmony_ci &processed, &all_used)); 50152e5b6d6dSopenharmony_ci CHECK(all_used); 50162e5b6d6dSopenharmony_ci 50172e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" ", flags, Single::NaN(), 50182e5b6d6dSopenharmony_ci &processed, &all_used)); 50192e5b6d6dSopenharmony_ci CHECK(all_used); 50202e5b6d6dSopenharmony_ci 50212e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("0x", flags, 0.0f, 50222e5b6d6dSopenharmony_ci &processed, &all_used)); 50232e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 50242e5b6d6dSopenharmony_ci 50252e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 0x ", flags, 0.0f, 50262e5b6d6dSopenharmony_ci &processed, &all_used)); 50272e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 50282e5b6d6dSopenharmony_ci 50292e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 0x 3", flags, 0.0f, 50302e5b6d6dSopenharmony_ci &processed, &all_used)); 50312e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 50322e5b6d6dSopenharmony_ci 50332e5b6d6dSopenharmony_ci CHECK_EQ((float)0x3, StrToF("0x3g", flags, 0.0f, &processed, &all_used)); 50342e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 50352e5b6d6dSopenharmony_ci 50362e5b6d6dSopenharmony_ci CHECK_EQ((float)0x3, StrToF("0x3.234", flags, 0.0f, &processed, &all_used)); 50372e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 50382e5b6d6dSopenharmony_ci 50392e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("x3", flags, 0.0f, 50402e5b6d6dSopenharmony_ci &processed, &all_used)); 50412e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 50422e5b6d6dSopenharmony_ci 50432e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_HEX_FLOATS; 50442e5b6d6dSopenharmony_ci 50452e5b6d6dSopenharmony_ci CHECK_EQ(3.0f, StrToF("0x3p0", flags, 0.0, &processed, &all_used)); 50462e5b6d6dSopenharmony_ci CHECK(all_used); 50472e5b6d6dSopenharmony_ci 50482e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("0x.0p0", flags, 0.0, &processed, &all_used)); 50492e5b6d6dSopenharmony_ci CHECK(all_used); 50502e5b6d6dSopenharmony_ci 50512e5b6d6dSopenharmony_ci CHECK_EQ(3.0f, StrToF("0x3.0p0", flags, 0.0, &processed, &all_used)); 50522e5b6d6dSopenharmony_ci CHECK(all_used); 50532e5b6d6dSopenharmony_ci 50542e5b6d6dSopenharmony_ci CHECK_EQ(3.0f, StrToF("0x3.p0", flags, 0.0, &processed, &all_used)); 50552e5b6d6dSopenharmony_ci CHECK(all_used); 50562e5b6d6dSopenharmony_ci 50572e5b6d6dSopenharmony_ci CHECK_EQ(-5634002804104940178441764864.0f, StrToF("-0x123456789012345678901234p0", 50582e5b6d6dSopenharmony_ci flags, 0.0, 50592e5b6d6dSopenharmony_ci &processed, &all_used)); 50602e5b6d6dSopenharmony_ci CHECK(all_used); 50612e5b6d6dSopenharmony_ci 50622e5b6d6dSopenharmony_ci CHECK_EQ(134217728.0f, StrToF("0x8000001p0", flags, 0.0, 50632e5b6d6dSopenharmony_ci &processed, &all_used)); 50642e5b6d6dSopenharmony_ci CHECK(all_used); 50652e5b6d6dSopenharmony_ci 50662e5b6d6dSopenharmony_ci CHECK_EQ(134217728.0f, StrToF("0x8000000p0", flags, 0.0, 50672e5b6d6dSopenharmony_ci &processed, &all_used)); 50682e5b6d6dSopenharmony_ci CHECK(all_used); 50692e5b6d6dSopenharmony_ci 50702e5b6d6dSopenharmony_ci CHECK_EQ(549755813888.0f, StrToF("0x8000000001p0", flags, 0.0, 50712e5b6d6dSopenharmony_ci &processed, &all_used)); 50722e5b6d6dSopenharmony_ci CHECK(all_used); 50732e5b6d6dSopenharmony_ci 50742e5b6d6dSopenharmony_ci CHECK_EQ(549755813888.0f, StrToF("0x8000000000p0", flags, 0.0, 50752e5b6d6dSopenharmony_ci &processed, &all_used)); 50762e5b6d6dSopenharmony_ci CHECK(all_used); 50772e5b6d6dSopenharmony_ci 50782e5b6d6dSopenharmony_ci CHECK_EQ(549755879424.0f, StrToF("0x8000008001p0", flags, 0.0, 50792e5b6d6dSopenharmony_ci &processed, &all_used)); 50802e5b6d6dSopenharmony_ci CHECK(all_used); 50812e5b6d6dSopenharmony_ci 50822e5b6d6dSopenharmony_ci CHECK_EQ(549755813888.0f, StrToF("0x8000008000p0", flags, 0.0, 50832e5b6d6dSopenharmony_ci &processed, &all_used)); 50842e5b6d6dSopenharmony_ci CHECK(all_used); 50852e5b6d6dSopenharmony_ci 50862e5b6d6dSopenharmony_ci CHECK_EQ(549755944960.0f, StrToF("0x8000018001p0", flags, 0.0, 50872e5b6d6dSopenharmony_ci &processed, &all_used)); 50882e5b6d6dSopenharmony_ci CHECK(all_used); 50892e5b6d6dSopenharmony_ci 50902e5b6d6dSopenharmony_ci CHECK_EQ(549755944960.0f, StrToF("0x8000018000p0", flags, 0.0, 50912e5b6d6dSopenharmony_ci &processed, &all_used)); 50922e5b6d6dSopenharmony_ci CHECK(all_used); 50932e5b6d6dSopenharmony_ci 50942e5b6d6dSopenharmony_ci CHECK_EQ(8796093022208.0f, StrToF("0x8000000001p4", flags, 0.0, 50952e5b6d6dSopenharmony_ci &processed, &all_used)); 50962e5b6d6dSopenharmony_ci CHECK(all_used); 50972e5b6d6dSopenharmony_ci 50982e5b6d6dSopenharmony_ci CHECK_EQ(8796093022208.0f, StrToF("0x8000000000p+4", flags, 0.0, 50992e5b6d6dSopenharmony_ci &processed, &all_used)); 51002e5b6d6dSopenharmony_ci CHECK(all_used); 51012e5b6d6dSopenharmony_ci 51022e5b6d6dSopenharmony_ci CHECK_EQ(8796094070784.0f, StrToF("0x8000008001p04", flags, 0.0, 51032e5b6d6dSopenharmony_ci &processed, &all_used)); 51042e5b6d6dSopenharmony_ci CHECK(all_used); 51052e5b6d6dSopenharmony_ci 51062e5b6d6dSopenharmony_ci CHECK_EQ(34359738368.0f, StrToF("0x8000008000p-4", flags, 0.0, 51072e5b6d6dSopenharmony_ci &processed, &all_used)); 51082e5b6d6dSopenharmony_ci CHECK(all_used); 51092e5b6d6dSopenharmony_ci 51102e5b6d6dSopenharmony_ci CHECK_EQ(34359746560.0f, StrToF("0x8000018001p-04", flags, 0.0, 51112e5b6d6dSopenharmony_ci &processed, &all_used)); 51122e5b6d6dSopenharmony_ci CHECK(all_used); 51132e5b6d6dSopenharmony_ci 51142e5b6d6dSopenharmony_ci CHECK_EQ(8796095119360.0f, StrToF("0x8000018000p4", flags, 0.0, 51152e5b6d6dSopenharmony_ci &processed, &all_used)); 51162e5b6d6dSopenharmony_ci CHECK(all_used); 51172e5b6d6dSopenharmony_ci 51182e5b6d6dSopenharmony_ci CHECK_EQ(Single::Infinity(), StrToF("0x1p2000", flags, 0.0, 51192e5b6d6dSopenharmony_ci &processed, &all_used)); 51202e5b6d6dSopenharmony_ci CHECK(all_used); 51212e5b6d6dSopenharmony_ci 51222e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("0x1p-2000", flags, 0.0, &processed, &all_used)); 51232e5b6d6dSopenharmony_ci CHECK(all_used); 51242e5b6d6dSopenharmony_ci 51252e5b6d6dSopenharmony_ci CHECK_EQ(-0.0f, StrToF("-0x1p-2000", flags, 0.0, &processed, &all_used)); 51262e5b6d6dSopenharmony_ci CHECK(all_used); 51272e5b6d6dSopenharmony_ci 51282e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" ", flags, Single::NaN(), 51292e5b6d6dSopenharmony_ci &processed, &all_used)); 51302e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 51312e5b6d6dSopenharmony_ci 51322e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("0x", flags, 0.0, 51332e5b6d6dSopenharmony_ci &processed, &all_used)); 51342e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 51352e5b6d6dSopenharmony_ci 51362e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 0x ", flags, 0.0, 51372e5b6d6dSopenharmony_ci &processed, &all_used)); 51382e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 51392e5b6d6dSopenharmony_ci 51402e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 0x 3", flags, 0.0, 51412e5b6d6dSopenharmony_ci &processed, &all_used)); 51422e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 51432e5b6d6dSopenharmony_ci 51442e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("0x3g", flags, 0.0, 51452e5b6d6dSopenharmony_ci &processed, &all_used)); 51462e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 51472e5b6d6dSopenharmony_ci 51482e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("x3", flags, 0.0, 51492e5b6d6dSopenharmony_ci &processed, &all_used)); 51502e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 51512e5b6d6dSopenharmony_ci 51522e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("0x3 foo", flags, 0.0, 51532e5b6d6dSopenharmony_ci &processed, &all_used)); 51542e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 51552e5b6d6dSopenharmony_ci 51562e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 0x3 foo", flags, 0.0, 51572e5b6d6dSopenharmony_ci &processed, &all_used)); 51582e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 51592e5b6d6dSopenharmony_ci 51602e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("+ 0x3 foo", flags, 0.0, 51612e5b6d6dSopenharmony_ci &processed, &all_used)); 51622e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 51632e5b6d6dSopenharmony_ci 51642e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("+", flags, 0.0, &processed, &all_used)); 51652e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 51662e5b6d6dSopenharmony_ci 51672e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("-", flags, 0.0, &processed, &all_used)); 51682e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 51692e5b6d6dSopenharmony_ci 51702e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("- -0x5", flags, 0.0, &processed, &all_used)); 51712e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 51722e5b6d6dSopenharmony_ci 51732e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("- +0x5", flags, 0.0, &processed, &all_used)); 51742e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 51752e5b6d6dSopenharmony_ci 51762e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("+ +0x5", flags, 0.0, &processed, &all_used)); 51772e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 51782e5b6d6dSopenharmony_ci 51792e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("0xp1", flags, 0.0, &processed, &all_used)); 51802e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 51812e5b6d6dSopenharmony_ci 51822e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("0x.p1", flags, 0.0, &processed, &all_used)); 51832e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 51842e5b6d6dSopenharmony_ci 51852e5b6d6dSopenharmony_ci CHECK_EQ(Single::Infinity(), StrToF("0x1.p10000000000000000", flags, 0.0, 51862e5b6d6dSopenharmony_ci &processed, &all_used)); 51872e5b6d6dSopenharmony_ci CHECK(all_used); 51882e5b6d6dSopenharmony_ci 51892e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("0x1.p-10000000000000000", flags, 0.0, 51902e5b6d6dSopenharmony_ci &processed, &all_used)); 51912e5b6d6dSopenharmony_ci CHECK(all_used); 51922e5b6d6dSopenharmony_ci} 51932e5b6d6dSopenharmony_ci 51942e5b6d6dSopenharmony_ci 51952e5b6d6dSopenharmony_ciTEST(StringToFloatOctalString) { 51962e5b6d6dSopenharmony_ci int flags; 51972e5b6d6dSopenharmony_ci int processed; 51982e5b6d6dSopenharmony_ci bool all_used; 51992e5b6d6dSopenharmony_ci double d; 52002e5b6d6dSopenharmony_ci float f; 52012e5b6d6dSopenharmony_ci 52022e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_OCTALS | 52032e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_LEADING_SPACES | 52042e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_SPACES | 52052e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN; 52062e5b6d6dSopenharmony_ci 52072e5b6d6dSopenharmony_ci // Check that no double rounding occurs: 52082e5b6d6dSopenharmony_ci const char* double_rounding_example1 = "04000000040000000010"; 52092e5b6d6dSopenharmony_ci d = StrToD(double_rounding_example1, flags, 0.0, &processed, &all_used); 52102e5b6d6dSopenharmony_ci f = StrToF(double_rounding_example1, flags, 0.0f, &processed, &all_used); 52112e5b6d6dSopenharmony_ci CHECK(f != static_cast<float>(d)); 52122e5b6d6dSopenharmony_ci CHECK_EQ(72057602627862528.0f, StrToF(double_rounding_example1, 52132e5b6d6dSopenharmony_ci flags, 0.0f, &processed, &all_used)); 52142e5b6d6dSopenharmony_ci CHECK(all_used); 52152e5b6d6dSopenharmony_ci 52162e5b6d6dSopenharmony_ci const char* double_rounding_example2 = "04000000137777777770"; 52172e5b6d6dSopenharmony_ci d = StrToD(double_rounding_example2, flags, 0.0, &processed, &all_used); 52182e5b6d6dSopenharmony_ci f = StrToF(double_rounding_example2, flags, 0.0f, &processed, &all_used); 52192e5b6d6dSopenharmony_ci CHECK(f != static_cast<float>(d)); 52202e5b6d6dSopenharmony_ci CHECK_EQ(72057602627862528.0f, StrToF(double_rounding_example2, 52212e5b6d6dSopenharmony_ci flags, 0.0f, &processed, &all_used)); 52222e5b6d6dSopenharmony_ci CHECK(all_used); 52232e5b6d6dSopenharmony_ci 52242e5b6d6dSopenharmony_ci CHECK_EQ(10.0f, StrToF("012", flags, 0.0f, &processed, &all_used)); 52252e5b6d6dSopenharmony_ci CHECK(all_used); 52262e5b6d6dSopenharmony_ci 52272e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("00", flags, 1.0f, &processed, &all_used)); 52282e5b6d6dSopenharmony_ci CHECK(all_used); 52292e5b6d6dSopenharmony_ci 52302e5b6d6dSopenharmony_ci CHECK_EQ(10.0f, StrToF("012", flags, 1.0f, &processed, &all_used)); 52312e5b6d6dSopenharmony_ci CHECK(all_used); 52322e5b6d6dSopenharmony_ci 52332e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0f, 52342e5b6d6dSopenharmony_ci StrToF("0123456789", flags, Single::NaN(), &processed, &all_used)); 52352e5b6d6dSopenharmony_ci CHECK(all_used); 52362e5b6d6dSopenharmony_ci 52372e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 52382e5b6d6dSopenharmony_ci StrToF("01234567", flags, Single::NaN(), &processed, &all_used)); 52392e5b6d6dSopenharmony_ci CHECK(all_used); 52402e5b6d6dSopenharmony_ci 52412e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 52422e5b6d6dSopenharmony_ci StrToF("+01234567", flags, Single::NaN(), &processed, &all_used)); 52432e5b6d6dSopenharmony_ci CHECK(all_used); 52442e5b6d6dSopenharmony_ci 52452e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0f, 52462e5b6d6dSopenharmony_ci StrToF("-01234567", flags, Single::NaN(), &processed, &all_used)); 52472e5b6d6dSopenharmony_ci CHECK(all_used); 52482e5b6d6dSopenharmony_ci 52492e5b6d6dSopenharmony_ci CHECK_EQ(10.0f, StrToF(" 012", flags, 0.0f, &processed, &all_used)); 52502e5b6d6dSopenharmony_ci CHECK(all_used); 52512e5b6d6dSopenharmony_ci 52522e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF(" 00", flags, 1.0f, &processed, &all_used)); 52532e5b6d6dSopenharmony_ci CHECK(all_used); 52542e5b6d6dSopenharmony_ci 52552e5b6d6dSopenharmony_ci CHECK_EQ(10.0f, StrToF(" 012", flags, 1.0f, &processed, &all_used)); 52562e5b6d6dSopenharmony_ci CHECK(all_used); 52572e5b6d6dSopenharmony_ci 52582e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0f, 52592e5b6d6dSopenharmony_ci StrToF(" 0123456789", flags, Single::NaN(), &processed, &all_used)); 52602e5b6d6dSopenharmony_ci CHECK(all_used); 52612e5b6d6dSopenharmony_ci 52622e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 52632e5b6d6dSopenharmony_ci StrToF(" 01234567", flags, Single::NaN(), &processed, &all_used)); 52642e5b6d6dSopenharmony_ci CHECK(all_used); 52652e5b6d6dSopenharmony_ci 52662e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 52672e5b6d6dSopenharmony_ci StrToF(" + 01234567", flags, Single::NaN(), &processed, &all_used)); 52682e5b6d6dSopenharmony_ci CHECK(all_used); 52692e5b6d6dSopenharmony_ci 52702e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0f, 52712e5b6d6dSopenharmony_ci StrToF(" - 01234567", flags, Single::NaN(), &processed, &all_used)); 52722e5b6d6dSopenharmony_ci CHECK(all_used); 52732e5b6d6dSopenharmony_ci 52742e5b6d6dSopenharmony_ci CHECK_EQ(10.0f, StrToF(" 012 ", flags, 0.0f, &processed, &all_used)); 52752e5b6d6dSopenharmony_ci CHECK(all_used); 52762e5b6d6dSopenharmony_ci 52772e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF(" 00 ", flags, 1.0f, &processed, &all_used)); 52782e5b6d6dSopenharmony_ci CHECK(all_used); 52792e5b6d6dSopenharmony_ci 52802e5b6d6dSopenharmony_ci CHECK_EQ(10.0f, StrToF(" 012 ", flags, 1.0f, &processed, &all_used)); 52812e5b6d6dSopenharmony_ci CHECK(all_used); 52822e5b6d6dSopenharmony_ci 52832e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0f, 52842e5b6d6dSopenharmony_ci StrToF(" 0123456789 ", flags, Single::NaN(), &processed, &all_used)); 52852e5b6d6dSopenharmony_ci CHECK(all_used); 52862e5b6d6dSopenharmony_ci 52872e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 52882e5b6d6dSopenharmony_ci StrToF(" 01234567 ", flags, Single::NaN(), &processed, &all_used)); 52892e5b6d6dSopenharmony_ci CHECK(all_used); 52902e5b6d6dSopenharmony_ci 52912e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 52922e5b6d6dSopenharmony_ci StrToF(" + 01234567 ", flags, Single::NaN(), &processed, &all_used)); 52932e5b6d6dSopenharmony_ci CHECK(all_used); 52942e5b6d6dSopenharmony_ci 52952e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0f, 52962e5b6d6dSopenharmony_ci StrToF(" - 01234567 ", flags, Single::NaN(), &processed, &all_used)); 52972e5b6d6dSopenharmony_ci CHECK(all_used); 52982e5b6d6dSopenharmony_ci 52992e5b6d6dSopenharmony_ci CHECK_EQ(10.0f, StrToF("012 ", flags, 0.0f, &processed, &all_used)); 53002e5b6d6dSopenharmony_ci CHECK(all_used); 53012e5b6d6dSopenharmony_ci 53022e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("00 ", flags, 1.0f, &processed, &all_used)); 53032e5b6d6dSopenharmony_ci CHECK(all_used); 53042e5b6d6dSopenharmony_ci 53052e5b6d6dSopenharmony_ci CHECK_EQ(10.0f, StrToF("012 ", flags, 1.0f, &processed, &all_used)); 53062e5b6d6dSopenharmony_ci CHECK(all_used); 53072e5b6d6dSopenharmony_ci 53082e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0f, 53092e5b6d6dSopenharmony_ci StrToF("0123456789 ", flags, Single::NaN(), &processed, &all_used)); 53102e5b6d6dSopenharmony_ci CHECK(all_used); 53112e5b6d6dSopenharmony_ci 53122e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 53132e5b6d6dSopenharmony_ci StrToF("01234567 ", flags, Single::NaN(), &processed, &all_used)); 53142e5b6d6dSopenharmony_ci CHECK(all_used); 53152e5b6d6dSopenharmony_ci 53162e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 53172e5b6d6dSopenharmony_ci StrToF("+01234567", flags, Single::NaN(), &processed, &all_used)); 53182e5b6d6dSopenharmony_ci CHECK(all_used); 53192e5b6d6dSopenharmony_ci 53202e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0f, 53212e5b6d6dSopenharmony_ci StrToF("-01234567", flags, Single::NaN(), &processed, &all_used)); 53222e5b6d6dSopenharmony_ci CHECK(all_used); 53232e5b6d6dSopenharmony_ci 53242e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 53252e5b6d6dSopenharmony_ci StrToF("01234567e0", flags, Single::NaN(), &processed, &all_used)); 53262e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 53272e5b6d6dSopenharmony_ci 53282e5b6d6dSopenharmony_ci 53292e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_OCTALS; 53302e5b6d6dSopenharmony_ci CHECK_EQ(10.0f, StrToF("012", flags, 0.0f, &processed, &all_used)); 53312e5b6d6dSopenharmony_ci CHECK(all_used); 53322e5b6d6dSopenharmony_ci 53332e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("00", flags, 1.0f, &processed, &all_used)); 53342e5b6d6dSopenharmony_ci CHECK(all_used); 53352e5b6d6dSopenharmony_ci 53362e5b6d6dSopenharmony_ci CHECK_EQ(10.0f, StrToF("012", flags, 1.0f, &processed, &all_used)); 53372e5b6d6dSopenharmony_ci CHECK(all_used); 53382e5b6d6dSopenharmony_ci 53392e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0f, 53402e5b6d6dSopenharmony_ci StrToF("0123456789", flags, Single::NaN(), &processed, &all_used)); 53412e5b6d6dSopenharmony_ci CHECK(all_used); 53422e5b6d6dSopenharmony_ci 53432e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 53442e5b6d6dSopenharmony_ci StrToF("01234567", flags, Single::NaN(), &processed, &all_used)); 53452e5b6d6dSopenharmony_ci CHECK(all_used); 53462e5b6d6dSopenharmony_ci 53472e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 53482e5b6d6dSopenharmony_ci StrToF("+01234567", flags, Single::NaN(), &processed, &all_used)); 53492e5b6d6dSopenharmony_ci CHECK(all_used); 53502e5b6d6dSopenharmony_ci 53512e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0f, 53522e5b6d6dSopenharmony_ci StrToF("-01234567", flags, Single::NaN(), &processed, &all_used)); 53532e5b6d6dSopenharmony_ci CHECK(all_used); 53542e5b6d6dSopenharmony_ci 53552e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 012", flags, 0.0f, &processed, &all_used)); 53562e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 53572e5b6d6dSopenharmony_ci 53582e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 00", flags, 1.0f, &processed, &all_used)); 53592e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 53602e5b6d6dSopenharmony_ci 53612e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 012", flags, 1.0f, &processed, &all_used)); 53622e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 53632e5b6d6dSopenharmony_ci 53642e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 53652e5b6d6dSopenharmony_ci StrToF(" 0123456789", flags, Single::NaN(), &processed, &all_used)); 53662e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 53672e5b6d6dSopenharmony_ci 53682e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 53692e5b6d6dSopenharmony_ci StrToF(" 01234567", flags, Single::NaN(), &processed, &all_used)); 53702e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 53712e5b6d6dSopenharmony_ci 53722e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 53732e5b6d6dSopenharmony_ci StrToF(" + 01234567", flags, Single::NaN(), &processed, &all_used)); 53742e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 53752e5b6d6dSopenharmony_ci 53762e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 53772e5b6d6dSopenharmony_ci StrToF(" - 01234567", flags, Single::NaN(), &processed, &all_used)); 53782e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 53792e5b6d6dSopenharmony_ci 53802e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 012 ", flags, 0.0f, &processed, &all_used)); 53812e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 53822e5b6d6dSopenharmony_ci 53832e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 00 ", flags, 1.0f, &processed, &all_used)); 53842e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 53852e5b6d6dSopenharmony_ci 53862e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 012 ", flags, 1.0f, &processed, &all_used)); 53872e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 53882e5b6d6dSopenharmony_ci 53892e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 53902e5b6d6dSopenharmony_ci StrToF(" 0123456789 ", flags, Single::NaN(), &processed, &all_used)); 53912e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 53922e5b6d6dSopenharmony_ci 53932e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 53942e5b6d6dSopenharmony_ci StrToF(" 01234567 ", flags, Single::NaN(), &processed, &all_used)); 53952e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 53962e5b6d6dSopenharmony_ci 53972e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 53982e5b6d6dSopenharmony_ci StrToF(" + 01234567 ", flags, Single::NaN(), &processed, &all_used)); 53992e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 54002e5b6d6dSopenharmony_ci 54012e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 54022e5b6d6dSopenharmony_ci StrToF(" - 01234567 ", flags, Single::NaN(), &processed, &all_used)); 54032e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 54042e5b6d6dSopenharmony_ci 54052e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("012 ", flags, 0.0f, &processed, &all_used)); 54062e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 54072e5b6d6dSopenharmony_ci 54082e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("00 ", flags, 1.0f, &processed, &all_used)); 54092e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 54102e5b6d6dSopenharmony_ci 54112e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF("012 ", flags, 1.0f, &processed, &all_used)); 54122e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 54132e5b6d6dSopenharmony_ci 54142e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 54152e5b6d6dSopenharmony_ci StrToF("0123456789 ", flags, Single::NaN(), &processed, &all_used)); 54162e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 54172e5b6d6dSopenharmony_ci 54182e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 54192e5b6d6dSopenharmony_ci StrToF("01234567 ", flags, Single::NaN(), &processed, &all_used)); 54202e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 54212e5b6d6dSopenharmony_ci 54222e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 54232e5b6d6dSopenharmony_ci StrToF("+01234567", flags, Single::NaN(), &processed, &all_used)); 54242e5b6d6dSopenharmony_ci CHECK(all_used); 54252e5b6d6dSopenharmony_ci 54262e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0f, 54272e5b6d6dSopenharmony_ci StrToF("-01234567", flags, Single::NaN(), &processed, &all_used)); 54282e5b6d6dSopenharmony_ci CHECK(all_used); 54292e5b6d6dSopenharmony_ci 54302e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 54312e5b6d6dSopenharmony_ci StrToF("01234567e0", flags, Single::NaN(), &processed, &all_used)); 54322e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 54332e5b6d6dSopenharmony_ci 54342e5b6d6dSopenharmony_ci 54352e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_OCTALS | 54362e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_JUNK; 54372e5b6d6dSopenharmony_ci CHECK_EQ(10.0f, StrToF("012", flags, 0.0f, &processed, &all_used)); 54382e5b6d6dSopenharmony_ci CHECK(all_used); 54392e5b6d6dSopenharmony_ci 54402e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("00", flags, 1.0f, &processed, &all_used)); 54412e5b6d6dSopenharmony_ci CHECK(all_used); 54422e5b6d6dSopenharmony_ci 54432e5b6d6dSopenharmony_ci CHECK_EQ(10.0f, StrToF("012", flags, 1.0f, &processed, &all_used)); 54442e5b6d6dSopenharmony_ci CHECK(all_used); 54452e5b6d6dSopenharmony_ci 54462e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0f, 54472e5b6d6dSopenharmony_ci StrToF("0123456789", flags, Single::NaN(), &processed, &all_used)); 54482e5b6d6dSopenharmony_ci CHECK(all_used); 54492e5b6d6dSopenharmony_ci 54502e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 54512e5b6d6dSopenharmony_ci StrToF("01234567", flags, Single::NaN(), &processed, &all_used)); 54522e5b6d6dSopenharmony_ci CHECK(all_used); 54532e5b6d6dSopenharmony_ci 54542e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 54552e5b6d6dSopenharmony_ci StrToF("+01234567", flags, Single::NaN(), &processed, &all_used)); 54562e5b6d6dSopenharmony_ci CHECK(all_used); 54572e5b6d6dSopenharmony_ci 54582e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0f, 54592e5b6d6dSopenharmony_ci StrToF("-01234567", flags, Single::NaN(), &processed, &all_used)); 54602e5b6d6dSopenharmony_ci CHECK(all_used); 54612e5b6d6dSopenharmony_ci 54622e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 012", flags, 0.0f, &processed, &all_used)); 54632e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 54642e5b6d6dSopenharmony_ci 54652e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 00", flags, 1.0f, &processed, &all_used)); 54662e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 54672e5b6d6dSopenharmony_ci 54682e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 012", flags, 1.0f, &processed, &all_used)); 54692e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 54702e5b6d6dSopenharmony_ci 54712e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 54722e5b6d6dSopenharmony_ci StrToF(" 0123456789", flags, Single::NaN(), &processed, &all_used)); 54732e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 54742e5b6d6dSopenharmony_ci 54752e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 54762e5b6d6dSopenharmony_ci StrToF(" 01234567", flags, Single::NaN(), &processed, &all_used)); 54772e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 54782e5b6d6dSopenharmony_ci 54792e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 54802e5b6d6dSopenharmony_ci StrToF(" + 01234567", flags, Single::NaN(), &processed, &all_used)); 54812e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 54822e5b6d6dSopenharmony_ci 54832e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 54842e5b6d6dSopenharmony_ci StrToF(" - 01234567", flags, Single::NaN(), &processed, &all_used)); 54852e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 54862e5b6d6dSopenharmony_ci 54872e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 012 ", flags, 0.0f, &processed, &all_used)); 54882e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 54892e5b6d6dSopenharmony_ci 54902e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 00 ", flags, 1.0f, &processed, &all_used)); 54912e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 54922e5b6d6dSopenharmony_ci 54932e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 012 ", flags, 1.0f, &processed, &all_used)); 54942e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 54952e5b6d6dSopenharmony_ci 54962e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 54972e5b6d6dSopenharmony_ci StrToF(" 0123456789 ", flags, Single::NaN(), &processed, &all_used)); 54982e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 54992e5b6d6dSopenharmony_ci 55002e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 55012e5b6d6dSopenharmony_ci StrToF(" 01234567 ", flags, Single::NaN(), &processed, &all_used)); 55022e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 55032e5b6d6dSopenharmony_ci 55042e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 55052e5b6d6dSopenharmony_ci StrToF(" + 01234567 ", flags, Single::NaN(), &processed, &all_used)); 55062e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 55072e5b6d6dSopenharmony_ci 55082e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 55092e5b6d6dSopenharmony_ci StrToF(" - 01234567 ", flags, Single::NaN(), &processed, &all_used)); 55102e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 55112e5b6d6dSopenharmony_ci 55122e5b6d6dSopenharmony_ci CHECK_EQ(10.0f, StrToF("012 ", flags, 0.0f, &processed, &all_used)); 55132e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 55142e5b6d6dSopenharmony_ci 55152e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("00 ", flags, 1.0f, &processed, &all_used)); 55162e5b6d6dSopenharmony_ci CHECK_EQ(2, processed); 55172e5b6d6dSopenharmony_ci 55182e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0f, 55192e5b6d6dSopenharmony_ci StrToF("0123456789 ", flags, Single::NaN(), &processed, &all_used)); 55202e5b6d6dSopenharmony_ci CHECK_EQ(10, processed); 55212e5b6d6dSopenharmony_ci 55222e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 55232e5b6d6dSopenharmony_ci StrToF("01234567 ", flags, Single::NaN(), &processed, &all_used)); 55242e5b6d6dSopenharmony_ci CHECK_EQ(8, processed); 55252e5b6d6dSopenharmony_ci 55262e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 55272e5b6d6dSopenharmony_ci StrToF("+01234567", flags, Single::NaN(), &processed, &all_used)); 55282e5b6d6dSopenharmony_ci CHECK(all_used); 55292e5b6d6dSopenharmony_ci 55302e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0f, 55312e5b6d6dSopenharmony_ci StrToF("-01234567", flags, Single::NaN(), &processed, &all_used)); 55322e5b6d6dSopenharmony_ci CHECK(all_used); 55332e5b6d6dSopenharmony_ci 55342e5b6d6dSopenharmony_ci CHECK_EQ(10.0f, StrToF("012foo ", flags, 0.0f, &processed, &all_used)); 55352e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 55362e5b6d6dSopenharmony_ci 55372e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("00foo ", flags, 1.0f, &processed, &all_used)); 55382e5b6d6dSopenharmony_ci CHECK_EQ(2, processed); 55392e5b6d6dSopenharmony_ci 55402e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0f, 55412e5b6d6dSopenharmony_ci StrToF("0123456789foo ", flags, Single::NaN(), 55422e5b6d6dSopenharmony_ci &processed, &all_used)); 55432e5b6d6dSopenharmony_ci CHECK_EQ(10, processed); 55442e5b6d6dSopenharmony_ci 55452e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 55462e5b6d6dSopenharmony_ci StrToF("01234567foo ", flags, Single::NaN(), &processed, &all_used)); 55472e5b6d6dSopenharmony_ci CHECK_EQ(8, processed); 55482e5b6d6dSopenharmony_ci 55492e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 55502e5b6d6dSopenharmony_ci StrToF("+01234567foo", flags, Single::NaN(), &processed, &all_used)); 55512e5b6d6dSopenharmony_ci CHECK_EQ(9, processed); 55522e5b6d6dSopenharmony_ci 55532e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0f, 55542e5b6d6dSopenharmony_ci StrToF("-01234567foo", flags, Single::NaN(), &processed, &all_used)); 55552e5b6d6dSopenharmony_ci CHECK_EQ(9, processed); 55562e5b6d6dSopenharmony_ci 55572e5b6d6dSopenharmony_ci CHECK_EQ(10.0f, StrToF("012 foo ", flags, 0.0f, &processed, &all_used)); 55582e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 55592e5b6d6dSopenharmony_ci 55602e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("00 foo ", flags, 1.0f, &processed, &all_used)); 55612e5b6d6dSopenharmony_ci CHECK_EQ(2, processed); 55622e5b6d6dSopenharmony_ci 55632e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0f, 55642e5b6d6dSopenharmony_ci StrToF("0123456789 foo ", flags, Single::NaN(), 55652e5b6d6dSopenharmony_ci &processed, &all_used)); 55662e5b6d6dSopenharmony_ci CHECK_EQ(10, processed); 55672e5b6d6dSopenharmony_ci 55682e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 55692e5b6d6dSopenharmony_ci StrToF("01234567 foo ", flags, Single::NaN(), 55702e5b6d6dSopenharmony_ci &processed, &all_used)); 55712e5b6d6dSopenharmony_ci CHECK_EQ(8, processed); 55722e5b6d6dSopenharmony_ci 55732e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 55742e5b6d6dSopenharmony_ci StrToF("+01234567 foo", flags, Single::NaN(), 55752e5b6d6dSopenharmony_ci &processed, &all_used)); 55762e5b6d6dSopenharmony_ci CHECK_EQ(9, processed); 55772e5b6d6dSopenharmony_ci 55782e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0f, 55792e5b6d6dSopenharmony_ci StrToF("-01234567 foo", flags, Single::NaN(), &processed, 55802e5b6d6dSopenharmony_ci &all_used)); 55812e5b6d6dSopenharmony_ci CHECK_EQ(9, processed); 55822e5b6d6dSopenharmony_ci 55832e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 55842e5b6d6dSopenharmony_ci StrToF("01234567e0", flags, Single::NaN(), &processed, &all_used)); 55852e5b6d6dSopenharmony_ci CHECK_EQ(8, processed); 55862e5b6d6dSopenharmony_ci 55872e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 55882e5b6d6dSopenharmony_ci StrToF("01234567e", flags, Single::NaN(), &processed, &all_used)); 55892e5b6d6dSopenharmony_ci CHECK_EQ(8, processed); 55902e5b6d6dSopenharmony_ci 55912e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_OCTALS | 55922e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_SPACES | 55932e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_JUNK; 55942e5b6d6dSopenharmony_ci CHECK_EQ(10.0f, StrToF("012", flags, 0.0f, &processed, &all_used)); 55952e5b6d6dSopenharmony_ci CHECK(all_used); 55962e5b6d6dSopenharmony_ci 55972e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("00", flags, 1.0f, &processed, &all_used)); 55982e5b6d6dSopenharmony_ci CHECK(all_used); 55992e5b6d6dSopenharmony_ci 56002e5b6d6dSopenharmony_ci CHECK_EQ(10.0f, StrToF("012", flags, 1.0f, &processed, &all_used)); 56012e5b6d6dSopenharmony_ci CHECK(all_used); 56022e5b6d6dSopenharmony_ci 56032e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0f, 56042e5b6d6dSopenharmony_ci StrToF("0123456789", flags, Single::NaN(), &processed, &all_used)); 56052e5b6d6dSopenharmony_ci CHECK(all_used); 56062e5b6d6dSopenharmony_ci 56072e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 56082e5b6d6dSopenharmony_ci StrToF("01234567", flags, Single::NaN(), &processed, &all_used)); 56092e5b6d6dSopenharmony_ci CHECK(all_used); 56102e5b6d6dSopenharmony_ci 56112e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 56122e5b6d6dSopenharmony_ci StrToF("+01234567", flags, Single::NaN(), &processed, &all_used)); 56132e5b6d6dSopenharmony_ci CHECK(all_used); 56142e5b6d6dSopenharmony_ci 56152e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0f, 56162e5b6d6dSopenharmony_ci StrToF("-01234567", flags, Single::NaN(), &processed, &all_used)); 56172e5b6d6dSopenharmony_ci CHECK(all_used); 56182e5b6d6dSopenharmony_ci 56192e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 012", flags, 0.0f, &processed, &all_used)); 56202e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 56212e5b6d6dSopenharmony_ci 56222e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 00", flags, 1.0f, &processed, &all_used)); 56232e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 56242e5b6d6dSopenharmony_ci 56252e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 012", flags, 1.0f, &processed, &all_used)); 56262e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 56272e5b6d6dSopenharmony_ci 56282e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 56292e5b6d6dSopenharmony_ci StrToF(" 0123456789", flags, Single::NaN(), &processed, &all_used)); 56302e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 56312e5b6d6dSopenharmony_ci 56322e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 56332e5b6d6dSopenharmony_ci StrToF(" 01234567", flags, Single::NaN(), &processed, &all_used)); 56342e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 56352e5b6d6dSopenharmony_ci 56362e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 56372e5b6d6dSopenharmony_ci StrToF(" + 01234567", flags, Single::NaN(), &processed, &all_used)); 56382e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 56392e5b6d6dSopenharmony_ci 56402e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 56412e5b6d6dSopenharmony_ci StrToF(" - 01234567", flags, Single::NaN(), &processed, &all_used)); 56422e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 56432e5b6d6dSopenharmony_ci 56442e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 012 ", flags, 0.0f, &processed, &all_used)); 56452e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 56462e5b6d6dSopenharmony_ci 56472e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 00 ", flags, 1.0f, &processed, &all_used)); 56482e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 56492e5b6d6dSopenharmony_ci 56502e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), StrToF(" 012 ", flags, 1.0f, &processed, &all_used)); 56512e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 56522e5b6d6dSopenharmony_ci 56532e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 56542e5b6d6dSopenharmony_ci StrToF(" 0123456789 ", flags, Single::NaN(), &processed, &all_used)); 56552e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 56562e5b6d6dSopenharmony_ci 56572e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 56582e5b6d6dSopenharmony_ci StrToF(" 01234567 ", flags, Single::NaN(), &processed, &all_used)); 56592e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 56602e5b6d6dSopenharmony_ci 56612e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 56622e5b6d6dSopenharmony_ci StrToF(" + 01234567 ", flags, Single::NaN(), &processed, &all_used)); 56632e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 56642e5b6d6dSopenharmony_ci 56652e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), 56662e5b6d6dSopenharmony_ci StrToF(" - 01234567 ", flags, Single::NaN(), &processed, &all_used)); 56672e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 56682e5b6d6dSopenharmony_ci 56692e5b6d6dSopenharmony_ci CHECK_EQ(10.0f, StrToF("012 ", flags, 0.0f, &processed, &all_used)); 56702e5b6d6dSopenharmony_ci CHECK(all_used); 56712e5b6d6dSopenharmony_ci 56722e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("00 ", flags, 1.0f, &processed, &all_used)); 56732e5b6d6dSopenharmony_ci CHECK(all_used); 56742e5b6d6dSopenharmony_ci 56752e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0f, 56762e5b6d6dSopenharmony_ci StrToF("0123456789 ", flags, Single::NaN(), &processed, &all_used)); 56772e5b6d6dSopenharmony_ci CHECK(all_used); 56782e5b6d6dSopenharmony_ci 56792e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 56802e5b6d6dSopenharmony_ci StrToF("01234567 ", flags, Single::NaN(), &processed, &all_used)); 56812e5b6d6dSopenharmony_ci CHECK(all_used); 56822e5b6d6dSopenharmony_ci 56832e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 56842e5b6d6dSopenharmony_ci StrToF("+01234567", flags, Single::NaN(), &processed, &all_used)); 56852e5b6d6dSopenharmony_ci CHECK(all_used); 56862e5b6d6dSopenharmony_ci 56872e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0f, 56882e5b6d6dSopenharmony_ci StrToF("-01234567", flags, Single::NaN(), &processed, &all_used)); 56892e5b6d6dSopenharmony_ci CHECK(all_used); 56902e5b6d6dSopenharmony_ci 56912e5b6d6dSopenharmony_ci CHECK_EQ(10.0f, StrToF("012foo ", flags, 0.0f, &processed, &all_used)); 56922e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 56932e5b6d6dSopenharmony_ci 56942e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("00foo ", flags, 1.0f, &processed, &all_used)); 56952e5b6d6dSopenharmony_ci CHECK_EQ(2, processed); 56962e5b6d6dSopenharmony_ci 56972e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0f, 56982e5b6d6dSopenharmony_ci StrToF("0123456789foo ", flags, Single::NaN(), 56992e5b6d6dSopenharmony_ci &processed, &all_used)); 57002e5b6d6dSopenharmony_ci CHECK_EQ(10, processed); 57012e5b6d6dSopenharmony_ci 57022e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 57032e5b6d6dSopenharmony_ci StrToF("01234567foo ", flags, Single::NaN(), &processed, &all_used)); 57042e5b6d6dSopenharmony_ci CHECK_EQ(8, processed); 57052e5b6d6dSopenharmony_ci 57062e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 57072e5b6d6dSopenharmony_ci StrToF("+01234567foo", flags, Single::NaN(), &processed, &all_used)); 57082e5b6d6dSopenharmony_ci CHECK_EQ(9, processed); 57092e5b6d6dSopenharmony_ci 57102e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0f, 57112e5b6d6dSopenharmony_ci StrToF("-01234567foo", flags, Single::NaN(), &processed, &all_used)); 57122e5b6d6dSopenharmony_ci CHECK_EQ(9, processed); 57132e5b6d6dSopenharmony_ci 57142e5b6d6dSopenharmony_ci CHECK_EQ(10.0f, StrToF("012 foo ", flags, 0.0f, &processed, &all_used)); 57152e5b6d6dSopenharmony_ci CHECK_EQ(4, processed); 57162e5b6d6dSopenharmony_ci 57172e5b6d6dSopenharmony_ci CHECK_EQ(0.0f, StrToF("00 foo ", flags, 1.0f, &processed, &all_used)); 57182e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 57192e5b6d6dSopenharmony_ci 57202e5b6d6dSopenharmony_ci CHECK_EQ(123456789.0f, 57212e5b6d6dSopenharmony_ci StrToF("0123456789 foo ", flags, Single::NaN(), 57222e5b6d6dSopenharmony_ci &processed, &all_used)); 57232e5b6d6dSopenharmony_ci CHECK_EQ(11, processed); 57242e5b6d6dSopenharmony_ci 57252e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 57262e5b6d6dSopenharmony_ci StrToF("01234567 foo ", flags, Single::NaN(), 57272e5b6d6dSopenharmony_ci &processed, &all_used)); 57282e5b6d6dSopenharmony_ci CHECK_EQ(9, processed); 57292e5b6d6dSopenharmony_ci 57302e5b6d6dSopenharmony_ci CHECK_EQ(342391.0f, 57312e5b6d6dSopenharmony_ci StrToF("+01234567 foo", flags, Single::NaN(), 57322e5b6d6dSopenharmony_ci &processed, &all_used)); 57332e5b6d6dSopenharmony_ci CHECK_EQ(10, processed); 57342e5b6d6dSopenharmony_ci 57352e5b6d6dSopenharmony_ci CHECK_EQ(-342391.0f, 57362e5b6d6dSopenharmony_ci StrToF("-01234567 foo", flags, Single::NaN(), 57372e5b6d6dSopenharmony_ci &processed, &all_used)); 57382e5b6d6dSopenharmony_ci CHECK_EQ(10, processed); 57392e5b6d6dSopenharmony_ci} 57402e5b6d6dSopenharmony_ci 57412e5b6d6dSopenharmony_ci 57422e5b6d6dSopenharmony_ciTEST(StringToFloatSpecialValues) { 57432e5b6d6dSopenharmony_ci int processed; 57442e5b6d6dSopenharmony_ci int flags = StringToDoubleConverter::NO_FLAGS; 57452e5b6d6dSopenharmony_ci 57462e5b6d6dSopenharmony_ci { 57472e5b6d6dSopenharmony_ci // Use 1.0 as junk_string_value. 57482e5b6d6dSopenharmony_ci StringToDoubleConverter converter(flags, 0.0f, 1.0f, "infinity", "NaN"); 57492e5b6d6dSopenharmony_ci 57502e5b6d6dSopenharmony_ci CHECK_EQ(Single::NaN(), converter.StringToDouble("+NaN", 4, &processed)); 57512e5b6d6dSopenharmony_ci CHECK_EQ(4, processed); 57522e5b6d6dSopenharmony_ci 57532e5b6d6dSopenharmony_ci CHECK_EQ(-Single::Infinity(), 57542e5b6d6dSopenharmony_ci converter.StringToDouble("-infinity", 9, &processed)); 57552e5b6d6dSopenharmony_ci CHECK_EQ(9, processed); 57562e5b6d6dSopenharmony_ci 57572e5b6d6dSopenharmony_ci CHECK_EQ(1.0f, converter.StringToDouble("Infinity", 8, &processed)); 57582e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 57592e5b6d6dSopenharmony_ci 57602e5b6d6dSopenharmony_ci CHECK_EQ(1.0f, converter.StringToDouble("++NaN", 5, &processed)); 57612e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 57622e5b6d6dSopenharmony_ci } 57632e5b6d6dSopenharmony_ci 57642e5b6d6dSopenharmony_ci { 57652e5b6d6dSopenharmony_ci // Use 1.0 as junk_string_value. 57662e5b6d6dSopenharmony_ci StringToDoubleConverter converter(flags, 0.0f, 1.0f, "+infinity", "1NaN"); 57672e5b6d6dSopenharmony_ci 57682e5b6d6dSopenharmony_ci // The '+' is consumed before trying to match the infinity string. 57692e5b6d6dSopenharmony_ci CHECK_EQ(1.0f, converter.StringToDouble("+infinity", 9, &processed)); 57702e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 57712e5b6d6dSopenharmony_ci 57722e5b6d6dSopenharmony_ci // The match for "1NaN" triggers, and doesn't let the 1234.0 complete. 57732e5b6d6dSopenharmony_ci CHECK_EQ(1.0f, converter.StringToDouble("1234.0", 6, &processed)); 57742e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 57752e5b6d6dSopenharmony_ci } 57762e5b6d6dSopenharmony_ci} 57772e5b6d6dSopenharmony_ci 57782e5b6d6dSopenharmony_ci 57792e5b6d6dSopenharmony_ciTEST(StringToDoubleFloatWhitespace) { 57802e5b6d6dSopenharmony_ci int flags; 57812e5b6d6dSopenharmony_ci int processed; 57822e5b6d6dSopenharmony_ci bool all_used; 57832e5b6d6dSopenharmony_ci 57842e5b6d6dSopenharmony_ci flags = StringToDoubleConverter::ALLOW_LEADING_SPACES | 57852e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_SPACES | 57862e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN; 57872e5b6d6dSopenharmony_ci 57882e5b6d6dSopenharmony_ci const char kWhitespaceAscii[] = { 57892e5b6d6dSopenharmony_ci 0x0A, 0x0D, 0x09, 0x0B, 0x0C, 0x20, 57902e5b6d6dSopenharmony_ci '-', 57912e5b6d6dSopenharmony_ci 0x0A, 0x0D, 0x09, 0x0B, 0x0C, 0x20, 57922e5b6d6dSopenharmony_ci '1', '.', '2', 57932e5b6d6dSopenharmony_ci 0x0A, 0x0D, 0x09, 0x0B, 0x0C, 0x20, 57942e5b6d6dSopenharmony_ci 0x00 57952e5b6d6dSopenharmony_ci }; 57962e5b6d6dSopenharmony_ci CHECK_EQ(-1.2, StrToD(kWhitespaceAscii, flags, Double::NaN(), 57972e5b6d6dSopenharmony_ci &processed, &all_used)); 57982e5b6d6dSopenharmony_ci CHECK(all_used); 57992e5b6d6dSopenharmony_ci CHECK_EQ(-1.2f, StrToF(kWhitespaceAscii, flags, Double::NaN(), 58002e5b6d6dSopenharmony_ci &processed, &all_used)); 58012e5b6d6dSopenharmony_ci CHECK(all_used); 58022e5b6d6dSopenharmony_ci 58032e5b6d6dSopenharmony_ci const uc16 kOghamSpaceMark = 0x1680; 58042e5b6d6dSopenharmony_ci const uc16 kMongolianVowelSeparator = 0x180E; 58052e5b6d6dSopenharmony_ci const uc16 kEnQuad = 0x2000; 58062e5b6d6dSopenharmony_ci const uc16 kEmQuad = 0x2001; 58072e5b6d6dSopenharmony_ci const uc16 kEnSpace = 0x2002; 58082e5b6d6dSopenharmony_ci const uc16 kEmSpace = 0x2003; 58092e5b6d6dSopenharmony_ci const uc16 kThreePerEmSpace = 0x2004; 58102e5b6d6dSopenharmony_ci const uc16 kFourPerEmSpace = 0x2005; 58112e5b6d6dSopenharmony_ci const uc16 kSixPerEmSpace = 0x2006; 58122e5b6d6dSopenharmony_ci const uc16 kFigureSpace = 0x2007; 58132e5b6d6dSopenharmony_ci const uc16 kPunctuationSpace = 0x2008; 58142e5b6d6dSopenharmony_ci const uc16 kThinSpace = 0x2009; 58152e5b6d6dSopenharmony_ci const uc16 kHairSpace = 0x200A; 58162e5b6d6dSopenharmony_ci const uc16 kNarrowNoBreakSpace = 0x202F; 58172e5b6d6dSopenharmony_ci const uc16 kMediumMathematicalSpace = 0x205F; 58182e5b6d6dSopenharmony_ci const uc16 kIdeographicSpace = 0x3000; 58192e5b6d6dSopenharmony_ci 58202e5b6d6dSopenharmony_ci const uc16 kWhitespace16[] = { 58212e5b6d6dSopenharmony_ci 0x0A, 0x0D, 0x09, 0x0B, 0x0C, 0x20, 0xA0, 0xFEFF, 58222e5b6d6dSopenharmony_ci kOghamSpaceMark, kMongolianVowelSeparator, kEnQuad, kEmQuad, 58232e5b6d6dSopenharmony_ci kEnSpace, kEmSpace, kThreePerEmSpace, kFourPerEmSpace, kSixPerEmSpace, 58242e5b6d6dSopenharmony_ci kFigureSpace, kPunctuationSpace, kThinSpace, kHairSpace, 58252e5b6d6dSopenharmony_ci kNarrowNoBreakSpace, kMediumMathematicalSpace, kIdeographicSpace, 58262e5b6d6dSopenharmony_ci '-', 58272e5b6d6dSopenharmony_ci 0x0A, 0x0D, 0x09, 0x0B, 0x0C, 0x20, 0xA0, 0xFEFF, 58282e5b6d6dSopenharmony_ci kOghamSpaceMark, kMongolianVowelSeparator, kEnQuad, kEmQuad, 58292e5b6d6dSopenharmony_ci kEnSpace, kEmSpace, kThreePerEmSpace, kFourPerEmSpace, kSixPerEmSpace, 58302e5b6d6dSopenharmony_ci kFigureSpace, kPunctuationSpace, kThinSpace, kHairSpace, 58312e5b6d6dSopenharmony_ci kNarrowNoBreakSpace, kMediumMathematicalSpace, kIdeographicSpace, 58322e5b6d6dSopenharmony_ci '1', '.', '2', 58332e5b6d6dSopenharmony_ci 0x0A, 0x0D, 0x09, 0x0B, 0x0C, 0x20, 0xA0, 0xFEFF, 58342e5b6d6dSopenharmony_ci kOghamSpaceMark, kMongolianVowelSeparator, kEnQuad, kEmQuad, 58352e5b6d6dSopenharmony_ci kEnSpace, kEmSpace, kThreePerEmSpace, kFourPerEmSpace, kSixPerEmSpace, 58362e5b6d6dSopenharmony_ci kFigureSpace, kPunctuationSpace, kThinSpace, kHairSpace, 58372e5b6d6dSopenharmony_ci kNarrowNoBreakSpace, kMediumMathematicalSpace, kIdeographicSpace, 58382e5b6d6dSopenharmony_ci }; 58392e5b6d6dSopenharmony_ci const int kWhitespace16Length = DOUBLE_CONVERSION_ARRAY_SIZE(kWhitespace16); 58402e5b6d6dSopenharmony_ci CHECK_EQ(-1.2, StrToD16(kWhitespace16, kWhitespace16Length, flags, 58412e5b6d6dSopenharmony_ci Double::NaN(), 58422e5b6d6dSopenharmony_ci &processed, &all_used)); 58432e5b6d6dSopenharmony_ci CHECK(all_used); 58442e5b6d6dSopenharmony_ci CHECK_EQ(-1.2f, StrToF16(kWhitespace16, kWhitespace16Length, flags, 58452e5b6d6dSopenharmony_ci Single::NaN(), 58462e5b6d6dSopenharmony_ci &processed, &all_used)); 58472e5b6d6dSopenharmony_ci CHECK(all_used); 58482e5b6d6dSopenharmony_ci} 58492e5b6d6dSopenharmony_ci 58502e5b6d6dSopenharmony_ci 58512e5b6d6dSopenharmony_ciTEST(StringToDoubleCaseInsensitiveSpecialValues) { 58522e5b6d6dSopenharmony_ci int processed = 0; 58532e5b6d6dSopenharmony_ci 58542e5b6d6dSopenharmony_ci int flags = StringToDoubleConverter::ALLOW_CASE_INSENSITIVITY | 58552e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_LEADING_SPACES | 58562e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_JUNK | 58572e5b6d6dSopenharmony_ci StringToDoubleConverter::ALLOW_TRAILING_SPACES; 58582e5b6d6dSopenharmony_ci 58592e5b6d6dSopenharmony_ci // Use 1.0 as junk_string_value. 58602e5b6d6dSopenharmony_ci StringToDoubleConverter converter(flags, 0.0, 1.0, "infinity", "nan"); 58612e5b6d6dSopenharmony_ci 58622e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), converter.StringToDouble("+nan", 4, &processed)); 58632e5b6d6dSopenharmony_ci CHECK_EQ(4, processed); 58642e5b6d6dSopenharmony_ci 58652e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), converter.StringToDouble("-nAN", 4, &processed)); 58662e5b6d6dSopenharmony_ci CHECK_EQ(4, processed); 58672e5b6d6dSopenharmony_ci 58682e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), converter.StringToDouble("nAN", 3, &processed)); 58692e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 58702e5b6d6dSopenharmony_ci 58712e5b6d6dSopenharmony_ci CHECK_EQ(Double::NaN(), converter.StringToDouble("nANabc", 6, &processed)); 58722e5b6d6dSopenharmony_ci CHECK_EQ(3, processed); 58732e5b6d6dSopenharmony_ci 58742e5b6d6dSopenharmony_ci CHECK_EQ(+Double::Infinity(), 58752e5b6d6dSopenharmony_ci converter.StringToDouble("+Infinity", 9, &processed)); 58762e5b6d6dSopenharmony_ci CHECK_EQ(9, processed); 58772e5b6d6dSopenharmony_ci 58782e5b6d6dSopenharmony_ci CHECK_EQ(-Double::Infinity(), 58792e5b6d6dSopenharmony_ci converter.StringToDouble("-INFinity", 9, &processed)); 58802e5b6d6dSopenharmony_ci CHECK_EQ(9, processed); 58812e5b6d6dSopenharmony_ci 58822e5b6d6dSopenharmony_ci CHECK_EQ(Double::Infinity(), 58832e5b6d6dSopenharmony_ci converter.StringToDouble("infINITY", 8, &processed)); 58842e5b6d6dSopenharmony_ci CHECK_EQ(8, processed); 58852e5b6d6dSopenharmony_ci 58862e5b6d6dSopenharmony_ci CHECK_EQ(1.0, converter.StringToDouble("INF", 3, &processed)); 58872e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 58882e5b6d6dSopenharmony_ci 58892e5b6d6dSopenharmony_ci CHECK_EQ(1.0, converter.StringToDouble("+inf", 4, &processed)); 58902e5b6d6dSopenharmony_ci CHECK_EQ(0, processed); 58912e5b6d6dSopenharmony_ci} 58922e5b6d6dSopenharmony_ci 58932e5b6d6dSopenharmony_ci 58942e5b6d6dSopenharmony_ciTEST(StringToTemplate) { 58952e5b6d6dSopenharmony_ci // Test StringToDoubleConverter::StringTo<T>. 58962e5b6d6dSopenharmony_ci 58972e5b6d6dSopenharmony_ci const StringToDoubleConverter converter(StringToDoubleConverter::ALLOW_HEX, 0.0, Double::NaN(), "inf", "nan"); 58982e5b6d6dSopenharmony_ci 58992e5b6d6dSopenharmony_ci // First simply check conversion from "0" and "1": 59002e5b6d6dSopenharmony_ci for (int i = 0; i <= 1; ++i) 59012e5b6d6dSopenharmony_ci { 59022e5b6d6dSopenharmony_ci const char c = '0' + i; 59032e5b6d6dSopenharmony_ci 59042e5b6d6dSopenharmony_ci int processed = 0; 59052e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(i), converter.StringTo<double>(&c, 1, &processed)); 59062e5b6d6dSopenharmony_ci CHECK_EQ(1, processed); 59072e5b6d6dSopenharmony_ci 59082e5b6d6dSopenharmony_ci processed = 0; 59092e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(i), converter.StringTo<float>(&c, 1, &processed)); 59102e5b6d6dSopenharmony_ci CHECK_EQ(1, processed); 59112e5b6d6dSopenharmony_ci 59122e5b6d6dSopenharmony_ci const uc16 buffer16[1] = { static_cast<uc16>(c) }; 59132e5b6d6dSopenharmony_ci 59142e5b6d6dSopenharmony_ci processed = 0; 59152e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<double>(i), converter.StringTo<double>(buffer16, 1, &processed)); 59162e5b6d6dSopenharmony_ci CHECK_EQ(1, processed); 59172e5b6d6dSopenharmony_ci 59182e5b6d6dSopenharmony_ci processed = 0; 59192e5b6d6dSopenharmony_ci CHECK_EQ(static_cast<float>(i), converter.StringTo<float>(buffer16, 1, &processed)); 59202e5b6d6dSopenharmony_ci CHECK_EQ(1, processed); 59212e5b6d6dSopenharmony_ci } 59222e5b6d6dSopenharmony_ci { 59232e5b6d6dSopenharmony_ci // A number that can be represented by a double, but not by a float. 59242e5b6d6dSopenharmony_ci // Allows testing that StringTo<double> behaves like StringToDouble 59252e5b6d6dSopenharmony_ci // (and not like StringToFloat). 59262e5b6d6dSopenharmony_ci const char buffer[] = "1e+100"; 59272e5b6d6dSopenharmony_ci const int length = DOUBLE_CONVERSION_ARRAY_SIZE(buffer) - 1; 59282e5b6d6dSopenharmony_ci 59292e5b6d6dSopenharmony_ci int processed1 = 1; 59302e5b6d6dSopenharmony_ci int processed2 = 2; 59312e5b6d6dSopenharmony_ci 59322e5b6d6dSopenharmony_ci CHECK_EQ(converter.StringToDouble(buffer, length, &processed1), 59332e5b6d6dSopenharmony_ci converter.StringTo<double>(buffer, length, &processed2)); 59342e5b6d6dSopenharmony_ci CHECK_EQ(processed1, processed2); 59352e5b6d6dSopenharmony_ci 59362e5b6d6dSopenharmony_ci uc16 buffer16[DOUBLE_CONVERSION_ARRAY_SIZE(buffer)]; 59372e5b6d6dSopenharmony_ci 59382e5b6d6dSopenharmony_ci for (int i = 0; i <= length; ++i) { 59392e5b6d6dSopenharmony_ci buffer16[i] = buffer[i]; 59402e5b6d6dSopenharmony_ci } 59412e5b6d6dSopenharmony_ci 59422e5b6d6dSopenharmony_ci processed1 = 1; 59432e5b6d6dSopenharmony_ci processed2 = 2; 59442e5b6d6dSopenharmony_ci 59452e5b6d6dSopenharmony_ci CHECK_EQ(converter.StringToDouble(buffer16, length, &processed1), 59462e5b6d6dSopenharmony_ci converter.StringTo<double>(buffer16, length, &processed2)); 59472e5b6d6dSopenharmony_ci CHECK_EQ(processed1, processed2); 59482e5b6d6dSopenharmony_ci } 59492e5b6d6dSopenharmony_ci { 59502e5b6d6dSopenharmony_ci // The double rounding example from TEST(StringToFloatHexString), which 59512e5b6d6dSopenharmony_ci // yields a slightly different result from StringToFloat than from 59522e5b6d6dSopenharmony_ci // StringToDouble. Allows testing that StringTo<float> behaves like 59532e5b6d6dSopenharmony_ci // StringToFloat (rather than like StringToDouble). 59542e5b6d6dSopenharmony_ci const char buffer[] = "0x100000100000008"; 59552e5b6d6dSopenharmony_ci const int length = DOUBLE_CONVERSION_ARRAY_SIZE(buffer) - 1; 59562e5b6d6dSopenharmony_ci 59572e5b6d6dSopenharmony_ci int processed1 = 1; 59582e5b6d6dSopenharmony_ci int processed2 = 2; 59592e5b6d6dSopenharmony_ci 59602e5b6d6dSopenharmony_ci CHECK_EQ(converter.StringToFloat(buffer, length, &processed1), 59612e5b6d6dSopenharmony_ci converter.StringTo<float>(buffer, length, &processed2)); 59622e5b6d6dSopenharmony_ci CHECK_EQ(processed1, processed2); 59632e5b6d6dSopenharmony_ci 59642e5b6d6dSopenharmony_ci uc16 buffer16[DOUBLE_CONVERSION_ARRAY_SIZE(buffer)]; 59652e5b6d6dSopenharmony_ci 59662e5b6d6dSopenharmony_ci for (int i = 0; i <= length; ++i) { 59672e5b6d6dSopenharmony_ci buffer16[i] = buffer[i]; 59682e5b6d6dSopenharmony_ci } 59692e5b6d6dSopenharmony_ci 59702e5b6d6dSopenharmony_ci processed1 = 1; 59712e5b6d6dSopenharmony_ci processed2 = 2; 59722e5b6d6dSopenharmony_ci 59732e5b6d6dSopenharmony_ci CHECK_EQ(converter.StringToFloat(buffer16, length, &processed1), 59742e5b6d6dSopenharmony_ci converter.StringTo<float>(buffer16, length, &processed2)); 59752e5b6d6dSopenharmony_ci CHECK_EQ(processed1, processed2); 59762e5b6d6dSopenharmony_ci } 59772e5b6d6dSopenharmony_ci} 5978