Path: blob/master/test/jdk/java/text/Format/DecimalFormat/GoldenDoubleValues.java
41152 views
/*1* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/* Set of constants and values used in RoundingAndPropertyTest.java.24*25* There are 5 different information in this class:26* - TestLocale is the locale used by RoundingAndPropertyTest regression test27* when calling DecimalFormat.format() on either the set of DecimalGoldenValues28* or CurrencyGoldenValues.29* See main method of RoundingAndPropertyTest.30*31* - FullLocalizationTestLocale is the locale used by RoundingAndPropertyTest32* regression test when calling DecimalFormat.format() on the set of values33* (DecimalLocalizationValues) used to test that localization of digits34* happens correctly when needed.35* See main method of RoundingAndPropertyTest.36*37* - DecimalLocalizationValues is an array containing all the double values used38* to check that localization of digits happens correctly when needed.39* See RoundingAndPropertyTest.testLocalizationValues() method.40*41* - DecimalGoldenValues and CurrencyGoldenValues are arrays containing all the42* double values that will be used as input when checking correctness of43* results returned by DecimalFormat.format().44* 2 arrays are needed since decimal and currency formatting patterns require45* a different number of digits after decimal point.46* See RoundingAndPropertyTest.testGoldenValues() method.47*48* - PROPERTY_CHECK_POSITIVE_VALUE and PROPERTY_CHECK_NEGATIVE_VALUE are the49* double values used for testing the validity of the property changes call50* in the fast-path case. The locale used in that case is TestLocale.51* See RoundingAndPropertyTest.testSettersAndFastPath() method.52*/5354import java.util.*;5556class GoldenDoubleValues {5758// TestLocale is the testing locale used by RoundingAndPropertyTest test,59// when testing the golden double values60static final Locale TestLocale = new Locale("en", "US");616263// FullTestLocale is the testing locale used by RoundingAndPropertyTest test,64// when testing full localization of double values.65static final Locale FullLocalizationTestLocale = new Locale("hi", "IN");666768/* Below are the two double values used for exercising the changes of69* of DecimalFormat properties and symbols. These values are also used70* as golden values (see golden arrays below).71*/7273/* PROPERTY_CHECK_NEGATIVE_VALUE is the negative double value used for74* testing the validity of the property changes for fast-path.75* See testSettersAndFastPath() in RoundingAndPropertyTest test.76*/77static final double PROPERTY_CHECK_NEGATIVE_VALUE = -2147483646.2334997d;7879/* PROPERTY_CHECK_POSITIVE_VALUE is the positive double value used for80* testing the validity of the property changes for fast-path.81* See testSettersAndFastPath() in RoundingAndPropertyTest test.82*/83static final double PROPERTY_CHECK_POSITIVE_VALUE = 2147483646.2335003d;8485/* --- Array of double values to test localization ------------------------86*87* For most locales, effective localization does not happen on digits, i.e.88* the digits are not changed due to localization. In order to check that89* fast-path localize correctly digits in such a case, the array of double90* values below deals with all the case of localization that may happen on91* digits92*/93static final double[] DecimalLocalizationValues = {941.123,9512.123,96123.123,971234.123,9812345.123,99123456.123,1001234567.123,10112345678.123,102123456789.123,1031234567890.123,1041234.0,1051234.9,1061234.99,1071234.999108};109110111/* --- Arrays of golden double values ----------------------------------112*113* The GoldenValues arrays are used as input values for checking the114* correctness of the DecimalFormat.format() call results done in115* RoundingAndPropertyTest regression test. The results are compared to the116* expected ones found in GoldenFormattedValues. For each value in the117* arrays there is a corresponding expected string result found,118* represented as an array of unicode values, at the same index in the119* related GoldenFormattedValues array. The string returned by the format120* call and the found in GoldenFormattedValues array must be equal for the121* result to be considered valid.122* See RoundingAndPropertyTest.testGoldenValues() method.123*124* We need 2 such GoldenValues arrays since the decimal and currency125* formatting rules require different number of digits after decimal point.126*127* Thus we have two different arrays of golden values:128* - DecimalGoldenValues for the decimal case.129* - CurrencyGoldenValues for the currency case.130*131* They are associated to related GoldenFormattedValues arrays, generated by132* running RoundingAndPropertyTest with a "gengold" argument:133* - DecimalGoldenFormattedValues for the decimal case.134* - CurrencyGoldenFormattedValues for the currency case.135* These two generated arrays are found in GoldenFormattedValues.java file.136*137* The impact of the formatting rules is as follows, because the pattern138* rule for the fractional part is different for decimal and currency139* patterns:140* - in decimal case one must output the first non-zero 3 digits of141* fractional part 1.1232 => "1.123" and 1.12016789 => "1.12"142* - in currency case the first 2 fractional digits are always output143* 1.1232 => "1.12" and 1.0016789 => "1.00"144*145* Thus we need a different number of fractional digits when we specify146* below the golden double values to check, and most of the decimal and147* currency golden values differ only in the number of fractional digits.148*149* The list below exercises almost all code pathes of the fast-path150* algorithm except localization of digits.151*/152153// --- The set of golden values for the Decimal formatting case --------154static final double[] DecimalGoldenValues = {155// Testing of specific values156+0.0,157-0.0,158Double.MIN_VALUE,159Double.MIN_NORMAL,160PROPERTY_CHECK_NEGATIVE_VALUE,161PROPERTY_CHECK_POSITIVE_VALUE,162-2147483647.9996,1632147483647.9996,164-1999999999.9994997,1651999999999.9995003,166// Testing fast-path range checks (all outside bounds)167Double.NaN,168Double.POSITIVE_INFINITY,169Double.NEGATIVE_INFINITY,170Double.MAX_VALUE,171-9876543210.9876543,1729876543210.9876543,173-1234567890.1234567E128,1741234567890.1234567E128,175// Testing of integral string size1761.123,17712.123,178123.123,1791234.123,18012345.123,181123456.123,1821234567.123,18312345678.123,184123456789.123,1851234567890.123,186-1.123,187-12.123,188-123.123,189-1234.123,190-12345.123,191-123456.123,192-1234567.123,193-12345678.123,194-123456789.123,195-1234567890.123,196// Testing of fractional string size1970.1,1980.12,1990.123,2000.1234,20110.1,20210.12,20310.123,20410.1234,205100.1,206100.12,207100.123,208100.1234,2091000.1,2101000.12,2111000.123,2121000.1234,21310000.1,21410000.12,21510000.123,21610000.1234,217100000.1,218100000.12,219100000.123,220100000.1234,2211000000.1,2221000000.12,2231000000.123,2241000000.1234,22510000000.1,22610000000.12,22710000000.123,22810000000.1234,229100000000.1,230100000000.12,231100000000.123,232100000000.1234,2331000000000.1,2341000000000.12,2351000000000.123,2361000000000.1234,237-0.1,238-0.12,239-0.123,240-0.1234,241-10.1,242-10.12,243-10.123,244-10.1234,245-100.1,246-100.12,247-100.123,248-100.1234,249-1000.1,250-1000.12,251-1000.123,252-1000.1234,253-10000.1,254-10000.12,255-10000.123,256-10000.1234,257-100000.1,258-100000.12,259-100000.123,260-100000.1234,261-1000000.1,262-1000000.12,263-1000000.123,264-1000000.1234,265-10000000.1,266-10000000.12,267-10000000.123,268-10000000.1234,269-100000000.1,270-100000000.12,271-100000000.123,272-100000000.1234,273-1000000000.1,274-1000000000.12,275-1000000000.123,276-1000000000.1234,277// Testing of special rounding cases2781.9993,27912.9993,280123.9993,2811234.9993,28212345.9993,283123456.9993,2841234567.9993,28512345678.9993,286123456789.9993,2871234567890.9993,2881.9996,28912.9996,290123.9996,2911234.9996,29212345.9996,293123456.9996,2941234567.9996,29512345678.9996,296123456789.9996,2971234567890.9996,298-1.9993,299-12.9993,300-123.9993,301-1234.9993,302-12345.9993,303-123456.9993,304-1234567.9993,305-12345678.9993,306-123456789.9993,307-1234567890.9993,308-1.9996,309-12.9996,310-123.9996,311-1234.9996,312-12345.9996,313-123456.9996,314-1234567.9996,315-12345678.9996,316-123456789.9996,317-1234567890.9996,318109.9996,3191099.9996,32010999.9996,321109999.9996,3221099999.9996,32310999999.9996,324109999999.9996,3251099999999.9996,326-109.9996,327-1099.9996,328-10999.9996,329-109999.9996,330-1099999.9996,331-10999999.9996,332-109999999.9996,333-1099999999.9996,3341.9996,33519.9996,336199.9996,3371999.9996,33819999.9996,339199999.9996,3401999999.9996,34119999999.9996,342199999999.9996,3431999999999.9996,344-1.9996,345-19.9996,346-199.9996,347-1999.9996,348-19999.9996,349-199999.9996,350-1999999.9996,351-19999999.9996,352-199999999.9996,353-1999999999.9996,354// Testing for all nines cases3559.9996,35699.9996,357999.9996,3589999.9996,35999999.9996,360999999.9996,3619999999.9996,36299999999.9996,363999999999.9996,3649.999,36599.999,366999.999,3679999.999,36899999.999,369999999.999,3709999999.999,37199999999.999,372999999999.999,373-9.9996,374-99.9996,375-999.9996,376-9999.9996,377-99999.9996,378-999999.9996,379-9999999.9996,380-99999999.9996,381-999999999.9996,382-9.999,383-99.999,384-999.999,385-9999.999,386-99999.999,387-999999.999,388-9999999.999,389-99999999.999,390-999999999.999,391// Testing for no Fractional part cases3921.0,39312.0,394123.0,3951234.0,39612345.0,397123456.0,3981234567.0,39912345678.0,400123456789.0,4011234567890.0,402-1.0,403-12.0,404-123.0,405-1234.0,406-12345.0,407-123456.0,408-1234567.0,409-12345678.0,410-123456789.0,411-1234567890.0,412// Testing of tricky cases413-2599.399999990123,414-2599.339999990123,415-2599.333999990123,4161.000099999999818,4171.000199999999818,4181.000299999999818,4191.000399999999818,4201.000499999999818,4211.000599999999818,4221.000699999999818,4231.000799999999818,4241.000899999999818,4251.000999999999818,4261.2224999999999980,4271.2224999999999981,4281.2224999999999982,4291.2224999999999983,4301.2224999999999984,4311.2224999999999985,4321.2224999999999986,4331.2224999999999987,4341.2224999999999988,4351.2224999999999989,4361.2224999999999990,4371.2224999999999991,4381.2224999999999992,4391.2224999999999993,4401.2224999999999994,4411.2224999999999995,4421.2224999999999996,4431.2224999999999997,4441.2224999999999998,445// 1.2225 and 1.2224999999999999 have the same double approximation4461.2225,4471.2225000000000001,4481.2225000000000002,4491.2225000000000003,4501.2225000000000004,4511.2225000000000005,4521.2225000000000006,4531.2225000000000007,4541.2225000000000008,4551.2225000000000009,4561.2225000000000010,4571.2225000000000011,4581.2225000000000012,4591.2225000000000013,4601.2225000000000014,4611.2225000000000015,4621.2225000000000016,4631.2225000000000017,4641.2225000000000018,4651.2225000000000019,466// Tricky rounding cases around tie values467100913.67050000005,468199999.99895901306,469251846.3465,470253243.8825000001,471365045.85349999997,472314734.9615,473541133.9755,474858372.1225,4751000999.9995000001,4761347505.7825,4773358844.1975,4789997979.4085,4799993743.1585,4809938671.9085,4813385302.5465,4823404642.6605,4833431280.0865,4843438756.4754999997,4853446053.7874999996,4863457917.5125,4873465393.9014999997,4883484734.0154999997,4893492031.3274999997,4903503895.0525,4913511371.4414999997,4923518668.7534999996,4933530532.4785,4943538008.8674999997,4953545306.1794999996,4963557169.9045,4973557348.9814999998,4983564646.2934999997,4993583986.4074999997,5003591283.7194999997,5013603147.4445,5023610623.8334999997,5033617921.1454999996,5043629784.8705,5053637261.2594999997,5063656422.2965,5073656601.3734999998,5083663898.6854999997,5093675762.4105,5103683238.7994999997,5113690536.1114999996,5123702399.8365,5133709876.2254999997,5143717173.5374999996,5153729037.2625,5163736513.6514999997,5173755853.7654999997,5183763151.0774999997,5193775014.8025,5203782491.1914999997,5213789788.5034999996,5223801652.2285,5233809128.6174999997,5243816425.9294999996,5253828289.6545,5263828468.7314999998,5273835766.0434999997,5283855106.1574999997,5293862403.4694999997,5303874267.1945,5313881743.5834999997,5323889040.8954999996,5333900904.6205,5343908381.0094999997,5353927542.0465,5363927721.1234999998,5373935018.4354999997,5383946882.1605,5393954358.5494999997,5403961655.8614999996,5413973519.5865,5423980995.9754999997,5433988293.2874999996,5444000157.0125,5454007633.4014999997,5464026973.5154999997,5474034270.8274999997,5484046134.5525,5494053610.9414999997,5504060908.2534999996,5514072771.9785,5524080248.3674999997,5534087545.6794999996,5544099409.4045,5554099588.4814999998,5564106885.7934999997,5574126225.9074999997,5584133523.2194999997,5594145386.9445,5604152863.3334999997,5614160160.6454999996,5624172024.3705,5634179500.7594999997,5644198661.7965,5654203407.2865,5664210704.5985,5674213435.4975568};569570// --- The set of golden values for the currency formatting case --------571static final double[] CurrencyGoldenValues = {572// Testing of specific values573+0.0,574-0.0,575Double.MIN_VALUE,576Double.MIN_NORMAL,577PROPERTY_CHECK_NEGATIVE_VALUE,578PROPERTY_CHECK_POSITIVE_VALUE,579-2147483647.996,5802147483647.996,581-1999999999.9949997,5821999999999.9950003,583// Testing fast-path range checks (all outside bounds)584Double.NaN,585Double.POSITIVE_INFINITY,586Double.NEGATIVE_INFINITY,587Double.MAX_VALUE,588-9876543210.9876543,5899876543210.9876543,590-1234567890.1234567E128,5911234567890.1234567E128,592// Testing of integral string size5931.12,59412.12,595123.12,5961234.12,59712345.12,598123456.12,5991234567.12,60012345678.12,601123456789.12,6021234567890.12,603-1.12,604-12.12,605-123.12,606-1234.12,607-12345.12,608-123456.12,609-1234567.12,610-12345678.12,611-123456789.12,612-1234567890.12,613// Testing of fractional string size6140.1,6150.12,6160.123,61710.1,61810.12,61910.123,620100.1,621100.12,622100.123,6231000.1,6241000.12,6251000.123,62610000.1,62710000.12,62810000.123,629100000.1,630100000.12,631100000.123,6321000000.1,6331000000.12,6341000000.123,63510000000.1,63610000000.12,63710000000.123,638100000000.1,639100000000.12,640100000000.123,6411000000000.1,6421000000000.12,6431000000000.123,644-0.1,645-0.12,646-0.123,647-10.1,648-10.12,649-10.123,650-100.1,651-100.12,652-100.123,653-1000.1,654-1000.12,655-1000.123,656-10000.1,657-10000.12,658-10000.123,659-100000.1,660-100000.12,661-100000.123,662-1000000.1,663-1000000.12,664-1000000.123,665-10000000.1,666-10000000.12,667-10000000.123,668-100000000.1,669-100000000.12,670-100000000.123,671-1000000000.1,672-1000000000.12,673-1000000000.123,674// Testing of special rounding cases6751.993,67612.993,677123.993,6781234.993,67912345.993,680123456.993,6811234567.993,68212345678.993,683123456789.993,6841234567890.993,6851.996,68612.996,687123.996,6881234.996,68912345.996,690123456.996,6911234567.996,69212345678.996,693123456789.996,6941234567890.996,695-1.993,696-12.993,697-123.993,698-1234.993,699-12345.993,700-123456.993,701-1234567.993,702-12345678.993,703-123456789.993,704-1234567890.993,705-1.996,706-12.996,707-123.996,708-1234.996,709-12345.996,710-123456.996,711-1234567.996,712-12345678.996,713-123456789.996,714-1234567890.996,715109.996,7161099.996,71710999.996,718109999.996,7191099999.996,72010999999.996,721109999999.996,7221099999999.996,723-109.996,724-1099.996,725-10999.996,726-109999.996,727-1099999.996,728-10999999.996,729-109999999.996,730-1099999999.996,7311.996,73219.996,733199.996,7341999.996,73519999.996,736199999.996,7371999999.996,73819999999.996,739199999999.996,7401999999999.996,741-1.996,742-19.996,743-199.996,744-1999.996,745-19999.996,746-199999.996,747-1999999.996,748-19999999.996,749-199999999.996,750-1999999999.996,751// Testing of all nines cases7529.996,75399.996,754999.996,7559999.996,75699999.996,757999999.996,7589999999.996,75999999999.996,760999999999.996,7619.99,76299.99,763999.99,7649999.99,76599999.99,766999999.99,7679999999.99,76899999999.99,769999999999.99,770-9.996,771-99.996,772-999.996,773-9999.996,774-99999.996,775-999999.996,776-9999999.996,777-99999999.996,778-999999999.996,779-9.99,780-99.99,781-999.99,782-9999.99,783-99999.99,784-999999.99,785-9999999.99,786-99999999.99,787-999999999.99,788// Testing of no Fractional part cases7891.0,79012.0,791123.0,7921234.0,79312345.0,794123456.0,7951234567.0,79612345678.0,797123456789.0,7981234567890.0,799-1.0,800-12.0,801-123.0,802-1234.0,803-12345.0,804-123456.0,805-1234567.0,806-12345678.0,807-123456789.0,808-1234567890.0,809// Testing of tricky cases810-2599.399999990123,811-2599.339999990123,812-2599.333999990123,8131.000999999999818,8141.001999999999818,8151.002999999999818,8161.003999999999818,8171.004999999999818,8181.005999999999818,8191.006999999999818,8201.007999999999818,8211.008999999999818,8221.009999999999818,8231.224999999999980,8241.224999999999981,8251.224999999999982,8261.224999999999983,8271.224999999999984,8281.224999999999985,8291.224999999999986,8301.224999999999987,8311.224999999999988,8321.224999999999989,8331.224999999999990,8341.224999999999991,8351.224999999999992,8361.224999999999993,8371.224999999999994,8381.224999999999995,8391.224999999999996,8401.224999999999997,8411.224999999999998,8421.224999999999999,8431.225,8441.225000000000001,8451.225000000000002,8461.225000000000003,8471.225000000000004,8481.225000000000005,8491.225000000000006,8501.225000000000007,8511.225000000000008,8521.225000000000009,8531.225000000000010,8541.225000000000011,8551.225000000000012,8561.225000000000013,8571.225000000000014,8581.225000000000015,8591.225000000000016,8601.225000000000017,8611.225000000000018,8621.225000000000019,863// Tricky rounding cases around tie values8641009136.7050000005,8652518463.465,8662532438.825000001,8673650458.5349999997,8683147349.615,8695411339.755,8708583721.225,87113475057.825,87233588441.975,87399979794.085,87499937431.585,87599386719.085,87633853025.465,87734046426.605,87834312800.865,87934387564.754999997,88034460537.874999996,88134579175.125,88234653939.014999997,88334847340.154999997,88434920313.274999997,88535038950.525,88635113714.414999997,88735186687.534999996,88835305324.785,88935380088.674999997,89035453061.794999996,89135571699.045,89235573489.814999998,89335646462.934999997,89435839864.074999997,89535912837.194999997,89636031474.445,89736106238.334999997,89836179211.454999996,89936297848.705,90036372612.594999997,90136564222.965,90236566013.734999998,90336638986.854999997,90436757624.105,90536832387.994999997,90636905361.114999996,90737023998.365,90837098762.254999997,90937171735.374999996,91037290372.625,91137365136.514999997,91237558537.654999997,91337631510.774999997,91437750148.025,91537824911.914999997,91637897885.034999996,91738016522.285,91838091286.174999997,91938164259.294999996,92038282896.545,92138284687.314999998,92238357660.434999997,92338551061.574999997,92438624034.694999997,92538742671.945,92638817435.834999997,92738890408.954999996,92839009046.205,92939083810.094999997,93039275420.465,93139277211.234999998,93239350184.354999997,93339468821.605,93439543585.494999997,93539616558.614999996,93639735195.865,93739809959.754999997,93839882932.874999996,93940001570.125,94040076334.014999997,94140269735.154999997,94240342708.274999997,94340461345.525,94440536109.414999997,94540609082.534999996,94640727719.785,94740802483.674999997,94840875456.794999996,94940994094.045,95040995884.814999998,95141068857.934999997,95241262259.074999997,95341335232.194999997,95441453869.445,95541528633.334999997,95641601606.454999996,95741720243.705,95841795007.594999997,95941986617.965,96042034072.865,96142107045.985,96242134354.975963};964}965966967