Fix typo in r5450 (period rather than comma in LOCLAIZED_COMMA_EQUIVALENTS)
and added tests that would have caught it.
Patch by: jat
Review by: andreasst (TBR)
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@5476 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/i18n/client/NumberFormat.java b/user/src/com/google/gwt/i18n/client/NumberFormat.java
index 7bda9e8..53172d6 100644
--- a/user/src/com/google/gwt/i18n/client/NumberFormat.java
+++ b/user/src/com/google/gwt/i18n/client/NumberFormat.java
@@ -327,7 +327,7 @@
// Localized characters for dot and comma in number patterns, used to produce
// the latin mapping for arbitrary locales. Any separator not in either of
// these strings will be mapped to non-breaking space (U+00A0).
- private static final String LOCALIZED_COMMA_EQUIVALENTS = ".\u060C\u066B\u3001\uFE10\uFE11\uFE50\uFE51\uFF0C\uFF64";
+ private static final String LOCALIZED_COMMA_EQUIVALENTS = ",\u060C\u066B\u3001\uFE10\uFE11\uFE50\uFE51\uFF0C\uFF64";
private static final String LOCALIZED_DOT_EQUIVALENTS = ".\u2024\u3002\uFE12\uFE52\uFF0E\uFF61";
// Constants for characters used in programmatic (unlocalized) patterns.
diff --git a/user/test/com/google/gwt/i18n/client/NumberFormat_en_Test.java b/user/test/com/google/gwt/i18n/client/NumberFormat_en_Test.java
index 4ed1cd9..25b6e3d 100644
--- a/user/test/com/google/gwt/i18n/client/NumberFormat_en_Test.java
+++ b/user/test/com/google/gwt/i18n/client/NumberFormat_en_Test.java
@@ -245,6 +245,20 @@
assertEquals("1234567890", str);
}
+ public void testForceLatin() {
+ assertFalse(NumberFormat.forcedLatinDigits());
+ NumberFormat.setForcedLatinDigits(true);
+ assertTrue(NumberFormat.forcedLatinDigits());
+ NumberFormat decLatin = NumberFormat.getDecimalFormat();
+ assertEquals("1,003.14", decLatin.format(1003.14));
+ assertEquals("-1,003.14", decLatin.format(-1003.14));
+ NumberFormat.setForcedLatinDigits(false);
+ assertFalse(NumberFormat.forcedLatinDigits());
+ assertEquals("3.14", decLatin.format(3.14));
+ NumberFormat unforced = NumberFormat.getDecimalFormat();
+ assertEquals("3.14", unforced.format(3.14));
+ }
+
public void testNegative() {
String str;
diff --git a/user/test/com/google/gwt/i18n/client/NumberFormat_fr_Test.java b/user/test/com/google/gwt/i18n/client/NumberFormat_fr_Test.java
index 2f0a55a..b86fd6a 100644
--- a/user/test/com/google/gwt/i18n/client/NumberFormat_fr_Test.java
+++ b/user/test/com/google/gwt/i18n/client/NumberFormat_fr_Test.java
@@ -201,6 +201,20 @@
assertEquals("1234567890", str);
}
+ public void testForceLatin() {
+ assertFalse(NumberFormat.forcedLatinDigits());
+ NumberFormat.setForcedLatinDigits(true);
+ assertTrue(NumberFormat.forcedLatinDigits());
+ NumberFormat decLatin = NumberFormat.getDecimalFormat();
+ assertEquals("1\u00A0003,14", decLatin.format(1003.14));
+ assertEquals("-1\u00A0003,14", decLatin.format(-1003.14));
+ NumberFormat.setForcedLatinDigits(false);
+ assertFalse(NumberFormat.forcedLatinDigits());
+ assertEquals("3,14", decLatin.format(3.14));
+ NumberFormat unforced = NumberFormat.getDecimalFormat();
+ assertEquals("3,14", unforced.format(3.14));
+ }
+
public void testPerMill() {
String str;