poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r675793 - /poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
Date Thu, 10 Jul 2008 22:43:02 GMT
Author: nick
Date: Thu Jul 10 15:43:01 2008
New Revision: 675793

URL: http://svn.apache.org/viewvc?rev=675793&view=rev
Log:
Add a test to show that the behaviour around bug #30635 is exactly as you would expect, and
the bug report is invalid

Modified:
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=675793&r1=675792&r2=675793&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Thu Jul 10 15:43:01
2008
@@ -1272,4 +1272,53 @@
         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());
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message