freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject [2/3] incubator-freemarker git commit: Environment independence of tests: DecimalFormat symbols
Date Tue, 14 Mar 2017 20:48:27 GMT
Environment independence of tests: DecimalFormat symbols


Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/98fd94e5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/98fd94e5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/98fd94e5

Branch: refs/heads/3
Commit: 98fd94e5737ef204df6c85a0d32840d828708b4b
Parents: 2ed315e
Author: ddekany <ddekany@apache.org>
Authored: Tue Mar 14 15:26:36 2017 +0100
Committer: ddekany <ddekany@apache.org>
Committed: Tue Mar 14 15:26:36 2017 +0100

----------------------------------------------------------------------
 .../impl/ExtendedDecimalFormatTest.java         | 36 +++++++++++---------
 1 file changed, 20 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/98fd94e5/src/test/java/org/apache/freemarker/core/valueformat/impl/ExtendedDecimalFormatTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/core/valueformat/impl/ExtendedDecimalFormatTest.java
b/src/test/java/org/apache/freemarker/core/valueformat/impl/ExtendedDecimalFormatTest.java
index 1146676..9625a5e 100644
--- a/src/test/java/org/apache/freemarker/core/valueformat/impl/ExtendedDecimalFormatTest.java
+++ b/src/test/java/org/apache/freemarker/core/valueformat/impl/ExtendedDecimalFormatTest.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.*;
 
 import java.io.IOException;
 import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
 import java.text.ParseException;
 import java.util.Locale;
 
@@ -35,12 +36,13 @@ import org.junit.Test;
 public class ExtendedDecimalFormatTest extends TemplateTest {
     
     private static final Locale LOC = Locale.US;
-    
+    private static final DecimalFormatSymbols SYMS = DecimalFormatSymbols.getInstance(LOC);
+
     @Test
     public void testNonExtended() throws ParseException {
         for (String fStr : new String[] { "0.00", "0.###", "#,#0.###", "#0.####", "0.0;m",
"0.0;",
                 "0'x'", "0'x';'m'", "0';'", "0';';m", "0';';'#'m';'", "0';;'", "" }) {
-            assertFormatsEquivalent(new DecimalFormat(fStr), ExtendedDecimalFormatParser.parse(fStr,
LOC));
+            assertFormatsEquivalent(new DecimalFormat(fStr, SYMS), ExtendedDecimalFormatParser.parse(fStr,
LOC));
         }
         
         try {
@@ -58,18 +60,20 @@ public class ExtendedDecimalFormatTest extends TemplateTest {
 
     @Test
     public void testNonExtended2() throws ParseException {
-        assertFormatsEquivalent(new DecimalFormat("0.0"), ExtendedDecimalFormatParser.parse("0.0;",
LOC));
-        assertFormatsEquivalent(new DecimalFormat("0.0"), ExtendedDecimalFormatParser.parse("0.0;;",
LOC));
-        assertFormatsEquivalent(new DecimalFormat("0.0;m"), ExtendedDecimalFormatParser.parse("0.0;m;",
LOC));
-        assertFormatsEquivalent(new DecimalFormat(""), ExtendedDecimalFormatParser.parse(";;",
LOC));
-        assertFormatsEquivalent(new DecimalFormat("0'x'"), ExtendedDecimalFormatParser.parse("0'x';;",
LOC));
-        assertFormatsEquivalent(new DecimalFormat("0'x';'m'"), ExtendedDecimalFormatParser.parse("0'x';'m';",
LOC));
-        assertFormatsEquivalent(new DecimalFormat("0';'"), ExtendedDecimalFormatParser.parse("0';';;",
LOC));
-        assertFormatsEquivalent(new DecimalFormat("0';';m"), ExtendedDecimalFormatParser.parse("0';';m;",
LOC));
-        assertFormatsEquivalent(new DecimalFormat("0';';'#'m';'"), ExtendedDecimalFormatParser.parse("0';';'#'m';';",
-                LOC));
-        assertFormatsEquivalent(new DecimalFormat("0';;'"), ExtendedDecimalFormatParser.parse("0';;';;",
LOC));
-        
+        assertFormatsEquivalent(new DecimalFormat("0.0", SYMS), ExtendedDecimalFormatParser.parse("0.0;",
LOC));
+        assertFormatsEquivalent(new DecimalFormat("0.0", SYMS), ExtendedDecimalFormatParser.parse("0.0;;",
LOC));
+        assertFormatsEquivalent(new DecimalFormat("0.0;m", SYMS), ExtendedDecimalFormatParser.parse("0.0;m;",
LOC));
+        assertFormatsEquivalent(new DecimalFormat("", SYMS), ExtendedDecimalFormatParser.parse(";;",
LOC));
+        assertFormatsEquivalent(new DecimalFormat("0'x'", SYMS), ExtendedDecimalFormatParser.parse("0'x';;",
LOC));
+        assertFormatsEquivalent(new DecimalFormat("0'x';'m'", SYMS),
+                ExtendedDecimalFormatParser.parse("0'x';'m';", LOC));
+        assertFormatsEquivalent(new DecimalFormat("0';'", SYMS), ExtendedDecimalFormatParser.parse("0';';;",
LOC));
+        assertFormatsEquivalent(new DecimalFormat("0';';m", SYMS), ExtendedDecimalFormatParser.parse("0';';m;",
LOC));
+        assertFormatsEquivalent(new DecimalFormat("0';';'#'m';'", SYMS),
+                ExtendedDecimalFormatParser.parse("0';';'#'m';';", LOC));
+        assertFormatsEquivalent(new DecimalFormat("0';;'", SYMS),
+                ExtendedDecimalFormatParser.parse("0';;';;", LOC));
+
         try {
             new DecimalFormat(";m");
             fail();
@@ -320,11 +324,11 @@ public class ExtendedDecimalFormatTest extends TemplateTest {
     
     private void assertFormatsEquivalent(DecimalFormat dfExpected, DecimalFormat dfActual)
{
         for (int signum : new int[] { 1, -1 }) {
-            assertFormatsEquivalent(dfExpected, dfActual, signum * 0);
+            assertFormatsEquivalent(dfExpected, dfActual, 0);
             assertFormatsEquivalent(dfExpected, dfActual, signum * 0.5);
             assertFormatsEquivalent(dfExpected, dfActual, signum * 0.25);
             assertFormatsEquivalent(dfExpected, dfActual, signum * 0.125);
-            assertFormatsEquivalent(dfExpected, dfActual, signum * 1);
+            assertFormatsEquivalent(dfExpected, dfActual, signum);
             assertFormatsEquivalent(dfExpected, dfActual, signum * 10);
             assertFormatsEquivalent(dfExpected, dfActual, signum * 100);
             assertFormatsEquivalent(dfExpected, dfActual, signum * 1000);


Mime
View raw message