poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1717163 - /poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
Date Mon, 30 Nov 2015 04:38:05 GMT
Author: onealj
Date: Mon Nov 30 04:38:04 2015
New Revision: 1717163

URL: http://svn.apache.org/viewvc?rev=1717163&view=rev
Log:
break testBoolErr into 2 unit tests. The test shouldn't be aware of the underlying implementation
for HSSFRows, and shorter tests are better

Modified:
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java?rev=1717163&r1=1717162&r2=1717163&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java Mon Nov 30 04:38:04
2015
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertNot
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
 
 import java.io.IOException;
 import java.util.Calendar;
@@ -140,46 +141,92 @@ public abstract class BaseTestCell {
 	}
 
 	/**
-	 * test that Boolean and Error types (BoolErrRecord) are supported properly.
+	 * test that Boolean (BoolErrRecord) are supported properly.
+	 * @see testErr
 	 */
 	@Test
-	public void testBoolErr() throws Exception {
+	public void testBool() throws IOException {
 
 		Workbook wb1 = _testDataProvider.createWorkbook();
 		Sheet s = wb1.createSheet("testSheet1");
 		Row r;
 		Cell c;
+		// B1
 		r = s.createRow(0);
 		c=r.createCell(1);
-		//c.setCellType(HSSFCell.CELL_TYPE_BOOLEAN);
+		assumeTrue(0 == c.getRowIndex());
+		assumeTrue(1 == c.getColumnIndex());
 		c.setCellValue(true);
 
+		// C1
 		c=r.createCell(2);
-		//c.setCellType(HSSFCell.CELL_TYPE_BOOLEAN);
+		assumeTrue(0 == c.getRowIndex());
+		assumeTrue(2 == c.getColumnIndex());
 		c.setCellValue(false);
 
+		Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
+		wb1.close();
+		
+		s = wb2.getSheet("testSheet1");
+		r = s.getRow(0);
+		assumeTrue("Row 1 should have 2 cells", 2 == r.getPhysicalNumberOfCells());
+		
+		c = r.getCell(1);
+		assumeTrue(0 == c.getRowIndex());
+        assumeTrue(1 == c.getColumnIndex());
+		assertEquals(Cell.CELL_TYPE_BOOLEAN, c.getCellType());
+		assertEquals("B1 value", true, c.getBooleanCellValue());
+		
+		c = r.getCell(2);
+		assumeTrue(0 == c.getRowIndex());
+		assumeTrue(2 == c.getColumnIndex());
+		assertEquals(Cell.CELL_TYPE_BOOLEAN, c.getCellType());
+		assertEquals("C1 value", false, c.getBooleanCellValue());
+		
+		wb2.close();
+	}
+	
+	/**
+	 * test that Error types (BoolErrRecord) are supported properly.
+	 * @see testBool
+	 */
+	@Test
+	public void testErr() throws IOException {
+
+		Workbook wb1 = _testDataProvider.createWorkbook();
+		Sheet s = wb1.createSheet("testSheet1");
+		Row r;
+		Cell c;
+
+		// B1
 		r = s.createRow(1);
 		c=r.createCell(1);
-		//c.setCellType(HSSFCell.CELL_TYPE_ERROR);
-		c.setCellErrorValue((byte)0);
+		assumeTrue(0 == c.getRowIndex());
+		assumeTrue(1 == c.getColumnIndex());
+		c.setCellErrorValue(FormulaError.NULL.getCode());
 
+		// C1
 		c=r.createCell(2);
-		//c.setCellType(HSSFCell.CELL_TYPE_ERROR);
-		c.setCellErrorValue((byte)7);
+		assumeTrue(0 == c.getRowIndex());
+		assumeTrue(2 == c.getColumnIndex());
+		c.setCellErrorValue(FormulaError.DIV0.getCode());
 
 		Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
 		wb1.close();
-		s = wb2.getSheetAt(0);
+
+		s = wb2.getSheet("testSheet1");
+
 		r = s.getRow(0);
+		assumeTrue("Row 1 should have 2 cells", 2 == r.getPhysicalNumberOfCells());
+
 		c = r.getCell(1);
-		assertTrue("boolean value 0,1 = true",c.getBooleanCellValue());
-		c = r.getCell(2);
-		assertTrue("boolean value 0,2 = false",c.getBooleanCellValue()==false);
-		r = s.getRow(1);
-		c = r.getCell(1);
-		assertTrue("boolean value 0,1 = 0",c.getErrorCellValue() == 0);
+		assertEquals(Cell.CELL_TYPE_ERROR, c.getCellType());
+		assertEquals("B2 value == #NULL!", FormulaError.NULL.getCode(), c.getErrorCellValue());
+
 		c = r.getCell(2);
-		assertTrue("boolean value 0,2 = 7",c.getErrorCellValue() == 7);
+		assertEquals(Cell.CELL_TYPE_ERROR, c.getCellType());
+		assertEquals("C2 value == #DIV/0!", FormulaError.DIV0.getCode(), c.getErrorCellValue());
+
 		wb2.close();
 	}
 



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


Mime
View raw message