]> source.dussan.org Git - poi.git/commitdiff
#58532 Enable more of the padding cell format tests, but a few remain to be fixed
authorNick Burch <nick@apache.org>
Sat, 24 Oct 2015 23:57:49 +0000 (23:57 +0000)
committerNick Burch <nick@apache.org>
Sat, 24 Oct 2015 23:57:49 +0000 (23:57 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1710407 13f79535-47bb-0310-9956-ffa450edef68

src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java

index c090ab3672d456f22fb85014b6065fdb77f333cc..421b10c370cdaa9117ee788d85d8b539fda18a02 100644 (file)
@@ -505,16 +505,29 @@ public class TestDataFormatter {
        assertEquals("1901/01/01", dfUS.formatRawCellContents(367.0, -1, "yyyy\\/mm\\/dd"));
     }
 
-    // TODO Fix this to work
     @Test
-    @Ignore("CellFormat and DataFormatter don't quite agree...")
-    public void testOther() {
+    public void testFormatsWithPadding() {
         DataFormatter dfUS = new DataFormatter(Locale.US, true);
 
-        assertEquals("  12.34 ", dfUS.formatRawCellContents( 12.34, -1, "_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-"));
-        assertEquals("- 12.34 ", dfUS.formatRawCellContents(-12.34, -1, "_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-"));
-        assertEquals(" -   ", dfUS.formatRawCellContents(0.0, -1, "_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-"));
-        assertEquals(" $-   ", dfUS.formatRawCellContents(0.0, -1, "_-$* #,##0.00_-;-$* #,##0.00_-;_-$* \"-\"??_-;_-@_-"));
+        // These request space-padding, based on the cell width
+        // There should always be one space after, variable (non-zero) amount before
+        // Because the Cell Width isn't available, this gets emulated with
+        //  4 leading spaces, or a minus then 3 leading spaces
+        // This isn't all that consistent, but it's the best we can really manage...
+        assertEquals("    1,234.56 ", dfUS.formatRawCellContents( 1234.56, -1, "_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-"));
+        assertEquals("-   1,234.56 ", dfUS.formatRawCellContents(-1234.56, -1, "_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-"));
+        assertEquals("    12.34 ", dfUS.formatRawCellContents( 12.34, -1, "_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-"));
+        assertEquals("-   12.34 ", dfUS.formatRawCellContents(-12.34, -1, "_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-"));
+        
+        assertEquals("    0.10 ", dfUS.formatRawCellContents( 0.1, -1, "_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-"));
+        assertEquals("-   0.10 ", dfUS.formatRawCellContents(-0.1, -1, "_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-"));
+        // TODO Fix this, we are randomly adding a 0 at the end that souldn't be there
+        //assertEquals("     -   ", dfUS.formatRawCellContents(0.0, -1, "_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-"));
+        
+        assertEquals(" $   1.10 ", dfUS.formatRawCellContents( 1.1, -1, "_-$* #,##0.00_-;-$* #,##0.00_-;_-$* \"-\"??_-;_-@_-"));
+        assertEquals("-$   1.10 ", dfUS.formatRawCellContents(-1.1, -1, "_-$* #,##0.00_-;-$* #,##0.00_-;_-$* \"-\"??_-;_-@_-"));
+        // TODO Fix this, we are randomly adding a 0 at the end that souldn't be there
+        //assertEquals(" $    -   ", dfUS.formatRawCellContents( 0.0, -1, "_-$* #,##0.00_-;-$* #,##0.00_-;_-$* \"-\"??_-;_-@_-"));
     }
     
     @Test