aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2020-06-15 20:51:36 +0000
committerDominik Stadler <centic@apache.org>2020-06-15 20:51:36 +0000
commit6eafee01d4c6126bccaecf195743552e0187c08a (patch)
treedf82f2a40a00c820cbe515127b8738c1d121232e /src/testcases/org/apache
parentb6ea06d220c334f1232ae9cfa6675e8bbde35f06 (diff)
downloadpoi-6eafee01d4c6126bccaecf195743552e0187c08a.tar.gz
poi-6eafee01d4c6126bccaecf195743552e0187c08a.zip
Add some more tests from bug 63819
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1878867 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache')
-rw-r--r--src/testcases/org/apache/poi/ss/formula/functions/TestDateValue.java29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestDateValue.java b/src/testcases/org/apache/poi/ss/formula/functions/TestDateValue.java
index fb185cc7fb..1598c7a8f0 100644
--- a/src/testcases/org/apache/poi/ss/formula/functions/TestDateValue.java
+++ b/src/testcases/org/apache/poi/ss/formula/functions/TestDateValue.java
@@ -18,13 +18,15 @@
package org.apache.poi.ss.formula.functions;
import org.apache.poi.ss.formula.eval.BlankEval;
-import org.apache.poi.ss.formula.eval.BoolEval;
import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.eval.NumberEval;
import org.apache.poi.ss.formula.eval.StringEval;
import org.apache.poi.ss.formula.eval.ValueEval;
+import org.apache.poi.util.LocaleUtil;
import org.junit.Test;
+import java.util.Locale;
+
import static org.junit.Assert.assertEquals;
/**
@@ -49,10 +51,23 @@ public final class TestDateValue {
confirmDateValue(new StringEval("FEB/1/2020"), 43862);
confirmDateValue(new StringEval("2020/02/01"), 43862);
- confirmDateValue(new StringEval(""), BlankEval.instance);
- confirmDateValue(BlankEval.instance, BlankEval.instance);
+ confirmDateValue(new StringEval(""));
+ confirmDateValue(BlankEval.instance);
+
+ confirmDateValueError(new StringEval("non-date text"));
+
+ LocaleUtil.setUserLocale(Locale.ENGLISH);
+ try {
+ // // EXCEL
+ confirmDateValue(new StringEval("8/22/2011"), 40777); // Serial number of a date entered as text.
+ confirmDateValue(new StringEval("22-MAY-2011"), 40685); // Serial number of a date entered as text.
+ confirmDateValue(new StringEval("2011/02/23"), 40597); // Serial number of a date entered as text.
- confirmDateValue(new StringEval("non-date text"), ErrorEval.VALUE_INVALID);
+ // LibreOffice compatibility
+ confirmDateValue(new StringEval("1954-07-20"), 19925);
+ } finally {
+ LocaleUtil.setUserLocale(null);
+ }
}
private ValueEval invokeDateValue(ValueEval text) {
@@ -65,14 +80,14 @@ public final class TestDateValue {
assertEquals(expected, ((NumberEval) result).getNumberValue(), 0.0001);
}
- private void confirmDateValue(ValueEval text, BlankEval expected) {
+ private void confirmDateValue(ValueEval text) {
ValueEval result = invokeDateValue(text);
assertEquals(BlankEval.class, result.getClass());
}
- private void confirmDateValue(ValueEval text, ErrorEval expected) {
+ private void confirmDateValueError(ValueEval text) {
ValueEval result = invokeDateValue(text);
assertEquals(ErrorEval.class, result.getClass());
- assertEquals(expected.getErrorCode(), ((ErrorEval) result).getErrorCode());
+ assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), ((ErrorEval) result).getErrorCode());
}
} \ No newline at end of file