source: josm/trunk/test/unit/org/openstreetmap/josm/tools/JosmDecimalFormatSymbolsProviderTest.java@ 13124

Last change on this file since 13124 was 13124, checked in by Don-vip, 6 years ago

fix #15552 - fix parsing of decimal numbers

  • Property svn:eol-style set to native
File size: 1.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.tools;
3
4import static org.junit.Assert.assertEquals;
5
6import java.util.Locale;
7
8import org.junit.Rule;
9import org.junit.Test;
10import org.openstreetmap.josm.testutils.JOSMTestRules;
11
12import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
13
14/**
15 * Unit tests of {@link JosmDecimalFormatSymbolsProvider}.
16 */
17public class JosmDecimalFormatSymbolsProviderTest {
18
19 /**
20 * Setup rule.
21 */
22 @Rule
23 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
24 public JOSMTestRules test = new JOSMTestRules();
25
26 /**
27 * Test {@link JosmDecimalFormatSymbolsProvider#parseDouble}.
28 */
29 @Test
30 public void testParseDouble() {
31 final Locale defLocale = Locale.getDefault();
32 try {
33 Locale.setDefault(Locale.ENGLISH);
34 assertEquals(0.3, JosmDecimalFormatSymbolsProvider.parseDouble("0.3"), 1e-7);
35 assertEquals(0.3, JosmDecimalFormatSymbolsProvider.parseDouble("0,3"), 1e-7);
36 Locale.setDefault(Locale.FRENCH);
37 assertEquals(0.3, JosmDecimalFormatSymbolsProvider.parseDouble("0.3"), 1e-7);
38 assertEquals(0.3, JosmDecimalFormatSymbolsProvider.parseDouble("0,3"), 1e-7);
39 } finally {
40 Locale.setDefault(defLocale);
41 }
42 }
43}
Note: See TracBrowser for help on using the repository browser.