diff options
author | PJ Fanning <fanningpj@apache.org> | 2021-07-28 16:56:36 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2021-07-28 16:56:36 +0000 |
commit | 01b94f181719814e1e1a1e84005cd21b61686e2e (patch) | |
tree | 11adc4c02ae04ed8b7231d87c560092162cf3681 /poi/src/test | |
parent | cec2d2b4cc345434f6bb8043c5f8a130bab30f41 (diff) | |
download | poi-01b94f181719814e1e1a1e84005cd21b61686e2e.tar.gz poi-01b94f181719814e1e1a1e84005cd21b61686e2e.zip |
[bug-65165] invalid date values not handled correctly in DateValue function
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1891858 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi/src/test')
-rw-r--r-- | poi/src/test/java/org/apache/poi/ss/formula/functions/TestDateValue.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/poi/src/test/java/org/apache/poi/ss/formula/functions/TestDateValue.java b/poi/src/test/java/org/apache/poi/ss/formula/functions/TestDateValue.java index 9738546998..ae0ae805c3 100644 --- a/poi/src/test/java/org/apache/poi/ss/formula/functions/TestDateValue.java +++ b/poi/src/test/java/org/apache/poi/ss/formula/functions/TestDateValue.java @@ -25,11 +25,7 @@ import java.time.Year; import java.time.temporal.ChronoUnit; import java.util.Locale; -import org.apache.poi.ss.formula.eval.BlankEval; -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.ss.formula.eval.*; import org.apache.poi.util.LocaleUtil; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; @@ -88,6 +84,16 @@ final class TestDateValue { } } + @Test + void testInvalidDateValue() { + assertEquals(ErrorEval.VALUE_INVALID, invokeDateValue(new StringEval("not-date")), + "not-date evals to invalid"); + assertEquals(ErrorEval.VALUE_INVALID, invokeDateValue(BoolEval.FALSE), + "false evals to invalid"); + assertEquals(ErrorEval.VALUE_INVALID, invokeDateValue(new NumberEval(Math.E)), + "Math.E evals to invalid"); + } + private ValueEval invokeDateValue(ValueEval text) { return new DateValue().evaluate(0, 0, text); } |