aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases
diff options
context:
space:
mode:
authorYegor Kozlov <yegor@apache.org>2010-05-22 16:06:36 +0000
committerYegor Kozlov <yegor@apache.org>2010-05-22 16:06:36 +0000
commit6fd6e4ba8410d97f6c4810d5d34d63414f734294 (patch)
treecee301825cde97ba1a4a364e60181c9b29c75dd4 /src/testcases
parentdaad262fbce4dde7519d1c2a9f46e4751a0668cf (diff)
downloadpoi-6fd6e4ba8410d97f6c4810d5d34d63414f734294.tar.gz
poi-6fd6e4ba8410d97f6c4810d5d34d63414f734294.zip
Fixed tests failing in non-english locales, see Bugzilla 49191
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@947310 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases')
-rw-r--r--src/testcases/org/apache/poi/hssf/record/formula/functions/TestText.java17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/testcases/org/apache/poi/hssf/record/formula/functions/TestText.java b/src/testcases/org/apache/poi/hssf/record/formula/functions/TestText.java
index c3e429bc15..53f7d5a884 100644
--- a/src/testcases/org/apache/poi/hssf/record/formula/functions/TestText.java
+++ b/src/testcases/org/apache/poi/hssf/record/formula/functions/TestText.java
@@ -17,6 +17,10 @@
package org.apache.poi.hssf.record.formula.functions;
+import java.text.DecimalFormatSymbols;
+import java.text.SimpleDateFormat;
+import java.util.GregorianCalendar;
+
import junit.framework.TestCase;
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
import org.apache.poi.hssf.record.formula.eval.NumberEval;
@@ -46,20 +50,22 @@ public final class TestText extends TestCase {
ValueEval formatArg = new StringEval("#,###.00000");
ValueEval[] args = { numArg, formatArg };
ValueEval result = T.TEXT.evaluate(args, -1, (short)-1);
- ValueEval testResult = new StringEval("321,321.32100");
+ char groupSeparator = DecimalFormatSymbols.getInstance().getGroupingSeparator();
+ char decimalSeparator = DecimalFormatSymbols.getInstance().getDecimalSeparator();
+ ValueEval testResult = new StringEval("321" + groupSeparator + "321" + decimalSeparator + "32100");
assertEquals(testResult.toString(), result.toString());
numArg = new NumberEval(321.321);
formatArg = new StringEval("00000.00000");
args[0] = numArg;
args[1] = formatArg;
result = T.TEXT.evaluate(args, -1, (short)-1);
- testResult = new StringEval("00321.32100");
+ testResult = new StringEval("00321" + decimalSeparator + "32100");
assertEquals(testResult.toString(), result.toString());
formatArg = new StringEval("$#.#");
args[1] = formatArg;
result = T.TEXT.evaluate(args, -1, (short)-1);
- testResult = new StringEval("$321.3");
+ testResult = new StringEval("$321" + decimalSeparator + "3");
assertEquals(testResult.toString(), result.toString());
}
@@ -94,10 +100,13 @@ public final class TestText extends TestCase {
ValueEval testResult = new StringEval("16:11:1900 07:42:14");
assertEquals(testResult.toString(), result.toString());
+ // this line is intended to compute how "November" would look like in the current locale
+ String november = new SimpleDateFormat("MMMM").format(new GregorianCalendar(2010,10,15).getTime());
+
formatArg = new StringEval("MMMM dd, yyyy");
args[1] = formatArg;
result = T.TEXT.evaluate(args, -1, (short)-1);
- testResult = new StringEval("November 16, 1900");
+ testResult = new StringEval(november + " 16, 1900");
assertEquals(testResult.toString(), result.toString());
}