LEFT | RIGHT |
1 // © 2016 and later: Unicode, Inc. and others. | 1 // © 2016 and later: Unicode, Inc. and others. |
2 // License & terms of use: http://www.unicode.org/copyright.html#License | 2 // License & terms of use: http://www.unicode.org/copyright.html#License |
3 /* | 3 /* |
4 ******************************************************************************* | 4 ******************************************************************************* |
5 * Copyright (C) 2001-2012, International Business Machines Corporation and * | 5 * Copyright (C) 2001-2012, International Business Machines Corporation and * |
6 * others. All Rights Reserved. * | 6 * others. All Rights Reserved. * |
7 ******************************************************************************* | 7 ******************************************************************************* |
8 */ | 8 */ |
9 | 9 |
10 /** | 10 /** |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 } | 167 } |
168 } | 168 } |
169 } | 169 } |
170 | 170 |
171 //Test New serialized DecimalFormat(2.0) read old serialized forms of Decima
lFormat(1.3.1.1) | 171 //Test New serialized DecimalFormat(2.0) read old serialized forms of Decima
lFormat(1.3.1.1) |
172 @Test | 172 @Test |
173 public void TestSerialization() throws IOException{ | 173 public void TestSerialization() throws IOException{ |
174 byte[][] contents = NumberFormatSerialTestData.getContent(); | 174 byte[][] contents = NumberFormatSerialTestData.getContent(); |
175 double data = 1234.56; | 175 double data = 1234.56; |
176 String[] expected = { | 176 String[] expected = { |
177 "1,234.56", "$1,234.56", "123,456%", "1.23456E3"}; | 177 "1,234.56", "$1,234.56", "1.23456E3", "1,234.56"}; |
178 for (int i = 0; i < 4; ++i) { | 178 for (int i = 0; i < 4; ++i) { |
179 ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStre
am(contents[i])); | 179 ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStre
am(contents[i])); |
180 try { | 180 try { |
181 NumberFormat format = (NumberFormat) ois.readObject(); | 181 NumberFormat format = (NumberFormat) ois.readObject(); |
182 String result = format.format(data); | 182 String result = format.format(data); |
183 if (result.equals(expected[i])) { | 183 assertEquals("Deserialization new version should read old versio
n", expected[i], result); |
184 logln("OK: Deserialized bogus NumberFormat(new version read
old version)"); | |
185 } else { | |
186 errln("FAIL: the test data formats are not euqal"); | |
187 } | |
188 } catch (Exception e) { | 184 } catch (Exception e) { |
189 warnln("FAIL: " + e.getMessage()); | 185 warnln("FAIL: " + e.getMessage()); |
190 } | 186 } |
191 } | 187 } |
192 } | 188 } |
193 | 189 |
194 /* | 190 /* |
195 * Test case for JB#5509, strict parsing issue | 191 * Test case for JB#5509, strict parsing issue |
196 */ | 192 */ |
197 @Test | 193 @Test |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 @Test | 383 @Test |
388 public void TestAffixesNoCurrency() { | 384 public void TestAffixesNoCurrency() { |
389 ULocale locale = new ULocale("en"); | 385 ULocale locale = new ULocale("en"); |
390 DecimalFormat nf = (DecimalFormat) NumberFormat.getInstance(locale, Numb
erFormat.PLURALCURRENCYSTYLE); | 386 DecimalFormat nf = (DecimalFormat) NumberFormat.getInstance(locale, Numb
erFormat.PLURALCURRENCYSTYLE); |
391 assertEquals( | 387 assertEquals( |
392 "Positive suffix should contain the single currency sign when no cur
rency is set", | 388 "Positive suffix should contain the single currency sign when no cur
rency is set", |
393 " \u00A4", | 389 " \u00A4", |
394 nf.getPositiveSuffix()); | 390 nf.getPositiveSuffix()); |
395 } | 391 } |
396 } | 392 } |
LEFT | RIGHT |