aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2020-04-11 15:36:27 +0000
committerNick Burch <nick@apache.org>2020-04-11 15:36:27 +0000
commit2b2631225de52a93fcc6e7f8a5a33589a44a54ff (patch)
tree0627ab75923039a7399f0d64bf6b60f196c0b1cf /src/testcases/org
parent0ea6b0800d83b12680ccc765662183b6b23ec4ae (diff)
downloadpoi-2b2631225de52a93fcc6e7f8a5a33589a44a54ff.tar.gz
poi-2b2631225de52a93fcc6e7f8a5a33589a44a54ff.zip
#64319 Tighten the scientific format code to avoid making eg TRUE into TRUE+, handle formats like 0E-0, and ensure formats like 0E0 work correctly
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1876396 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org')
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java b/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java
index 2949caed96..77f1ca3d3b 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java
@@ -974,23 +974,47 @@ public class TestDataFormatter {
* A numeric format string like 0E+0 should be E+
*/
@Test
- @Ignore("Bug #64319 is currently failing")
public void testWithEinFormat() throws Exception {
DataFormatter formatter = new DataFormatter();
+
+ // Format string literals with an E in them shouldn't be
+ // treated as a Scientific format, so shouldn't become E+
assertEquals("TRUE", formatter.formatRawCellContents(1.0, 170,
- "\"TRUE\";\"TRUE\";\"FALSE\""));
- assertEquals("TRUE", formatter.formatRawCellContents(0.0, 170,
- "\"TRUE\";\"TRUE\";\"FALSE\""));
+ "\"TRUE\";\"FALSE\";\"ZERO\""));
+ assertEquals("ZERO", formatter.formatRawCellContents(0.0, 170,
+ "\"TRUE\";\"FALSE\";\"ZERO\""));
assertEquals("FALSE", formatter.formatRawCellContents(-1.0, 170,
- "\"TRUE\";\"TRUE\";\"FALSE\""));
+ "\"TRUE\";\"FALSE\";\"ZERO\""));
+
+ // Explicit Scientific format does need E+
assertEquals("1E+05", formatter.formatRawCellContents(1e05, 170,
"0E+00"));
assertEquals("1E+10", formatter.formatRawCellContents(1e10, 170,
"0E+00"));
+ assertEquals("1E-10", formatter.formatRawCellContents(1e-10, 170,
+ "0E+00"));
+
+ // Large numbers with "General" need E+
+ assertEquals("100000", formatter.formatRawCellContents(1e05, -1, "General"));
+ assertEquals("1E+12", formatter.formatRawCellContents(1e12, -1, "General"));
+
+ // Less common Scientific-like formats which don't ask for
+ // the + on >1 exponentials don't need it adding
+ // (Java will put the -ve ones in for E-## automatically)
assertEquals("1E5", formatter.formatRawCellContents(1e05, 170,
"0E0"));
assertEquals("1E10", formatter.formatRawCellContents(1e10, 170,
"0E0"));
+ assertEquals("1E-10", formatter.formatRawCellContents(1e-10, 170,
+ "0E0"));
+
+ assertEquals("1E5", formatter.formatRawCellContents(1e05, 170,
+ "0E-0"));
+ assertEquals("1E10", formatter.formatRawCellContents(1e10, 170,
+ "0E-0"));
+ assertEquals("1E-10", formatter.formatRawCellContents(1e-10, 170,
+ "0E-0"));
+
}
private void doFormatTestSequential(DataFormatter formatter) {