diff options
author | PJ Fanning <fanningpj@apache.org> | 2021-08-06 15:41:16 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2021-08-06 15:41:16 +0000 |
commit | 828cf12f08cbe9c09772bab17b0dc43db36f6ef1 (patch) | |
tree | fa4189f7e30d58e50528067b1dbc8464bfe089c2 | |
parent | b864503d477b114d00b6f7b078f906a3ccb1f55f (diff) | |
download | poi-828cf12f08cbe9c09772bab17b0dc43db36f6ef1.tar.gz poi-828cf12f08cbe9c09772bab17b0dc43db36f6ef1.zip |
extend tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1892043 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | poi/src/test/java/org/apache/poi/ss/formula/eval/TestOperandResolver.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/poi/src/test/java/org/apache/poi/ss/formula/eval/TestOperandResolver.java b/poi/src/test/java/org/apache/poi/ss/formula/eval/TestOperandResolver.java index bba36e207a..20253fbf9a 100644 --- a/poi/src/test/java/org/apache/poi/ss/formula/eval/TestOperandResolver.java +++ b/poi/src/test/java/org/apache/poi/ss/formula/eval/TestOperandResolver.java @@ -94,6 +94,27 @@ final class TestOperandResolver { } @Test + void testCoerceDateTimeStringToNumber() throws EvaluationException { + Map<String, Double> values = new LinkedHashMap<>(); + values.put("2019/1/18 12:00", 43483.5); + values.put("2019/1/18 6:00 AM", 43483.25); + values.put("18-Jan-2019 6:00 PM", 43483.75); + values.put("2019/1/18 15:15:15", 43483.63559027778); + values.put("18-Jan-2019 6:15:15 PM", 43483.76059027778); + + for (String str : values.keySet()) { + try { + assertEquals(OperandResolver.coerceValueToDouble(new StringEval(str)), values.get(str), 0.00001); + } catch (EvaluationException e) { + fail("While handling: " + str + ". " + + "This failure can indicate that the wrong locale is used during test-execution, " + + "ensure you run with english/US via -Duser.language=en -Duser.country=US. " + + "Having: " + System.getProperty("user.language") + "/" + System.getProperty("user.country"), e); + } + } + } + + @Test void testCoerceTimeStringToNumber() throws EvaluationException { Map<String, Double> values = new LinkedHashMap<>(); values.put("00:00", 0.0); |