]> source.dussan.org Git - poi.git/commitdiff
Add a test to show that the behaviour around bug #30635 is exactly as you would expec...
authorNick Burch <nick@apache.org>
Thu, 10 Jul 2008 22:43:01 +0000 (22:43 +0000)
committerNick Burch <nick@apache.org>
Thu, 10 Jul 2008 22:43:01 +0000 (22:43 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@675793 13f79535-47bb-0310-9956-ffa450edef68

src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java

index fde53ba6a3877904ce94e225422fb96f72d34b99..643dfb3b566a1d2095648adaad716b749fc26b22 100644 (file)
@@ -1272,4 +1272,53 @@ public final class TestBugs extends TestCase {
         assertEquals("{=sin(B1:B9){9,1)[1][0]", nc2.getCellFormula());
         assertEquals("{=sin(B1:B9){9,1)[2][0]", nc3.getCellFormula());
     }
+    
+    /**
+     * People are all getting confused about the last
+     *  row and cell number
+     */
+    public void test30635() throws Exception {
+       HSSFWorkbook wb = new HSSFWorkbook();
+       HSSFSheet s = wb.createSheet();
+       
+       // No rows, everything is 0
+       assertEquals(0, s.getFirstRowNum());
+       assertEquals(0, s.getLastRowNum());
+       assertEquals(0, s.getPhysicalNumberOfRows());
+       
+       // One row, most things are 0, physical is 1
+       s.createRow(0);
+       assertEquals(0, s.getFirstRowNum());
+       assertEquals(0, s.getLastRowNum());
+       assertEquals(1, s.getPhysicalNumberOfRows());
+       
+       // And another, things change
+       s.createRow(4);
+       assertEquals(0, s.getFirstRowNum());
+       assertEquals(4, s.getLastRowNum());
+       assertEquals(2, s.getPhysicalNumberOfRows());
+       
+       
+       // Now start on cells
+       HSSFRow r = s.getRow(0);
+       assertEquals(-1, r.getFirstCellNum());
+       assertEquals(-1, r.getLastCellNum());
+       assertEquals(0, r.getPhysicalNumberOfCells());
+       
+       // Add a cell, things move off -1
+       r.createCell((short)0);
+       assertEquals(0, r.getFirstCellNum());
+       assertEquals(1, r.getLastCellNum()); // last cell # + 1
+       assertEquals(1, r.getPhysicalNumberOfCells());
+       
+       r.createCell((short)1);
+       assertEquals(0, r.getFirstCellNum());
+       assertEquals(2, r.getLastCellNum()); // last cell # + 1
+       assertEquals(2, r.getPhysicalNumberOfCells());
+       
+       r.createCell((short)4);
+       assertEquals(0, r.getFirstCellNum());
+       assertEquals(5, r.getLastCellNum()); // last cell # + 1
+       assertEquals(3, r.getPhysicalNumberOfCells());
+    }
 }