You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by jo...@apache.org on 2008/09/08 20:04:35 UTC
svn commit: r693179 -
/poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java
Author: josh
Date: Mon Sep 8 11:04:34 2008
New Revision: 693179
URL: http://svn.apache.org/viewvc?rev=693179&view=rev
Log:
fixed bug in junit which was exposed due to new caching feature of the formula evaluator
Modified:
poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java
Modified: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java?rev=693179&r1=693178&r2=693179&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java (original)
+++ poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java Mon Sep 8 11:04:34 2008
@@ -26,79 +26,77 @@
import junit.framework.TestCase;
public class TestXSSFFormulaEvaluation extends TestCase {
- public TestXSSFFormulaEvaluation(String name) {
+ public TestXSSFFormulaEvaluation(String name) {
super(name);
// Use system out logger
- System.setProperty(
- "org.apache.poi.util.POILogger",
- "org.apache.poi.util.SystemOutLogger"
- );
+ System.setProperty(
+ "org.apache.poi.util.POILogger",
+ "org.apache.poi.util.SystemOutLogger"
+ );
}
- public void testSimpleArithmatic() throws Exception {
- Workbook wb = new XSSFWorkbook();
- Sheet s = wb.createSheet();
- Row r = s.createRow(0);
-
- Cell c1 = r.createCell(0);
- c1.setCellFormula("1+5");
- assertTrue( Double.isNaN(c1.getNumericCellValue()) );
-
- Cell c2 = r.createCell(1);
- c2.setCellFormula("10/2");
- assertTrue( Double.isNaN(c2.getNumericCellValue()) );
-
- FormulaEvaluator fe = new FormulaEvaluator(s, wb);
- fe.setCurrentRow(r);
-
- fe.evaluateFormulaCell(c1);
- fe.evaluateFormulaCell(c2);
-
- assertEquals(6.0, c1.getNumericCellValue(), 0.0001);
- assertEquals(5.0, c2.getNumericCellValue(), 0.0001);
- }
-
- public void testSumCount() throws Exception {
- Workbook wb = new XSSFWorkbook();
- Sheet s = wb.createSheet();
- Row r = s.createRow(0);
- r.createCell(0).setCellValue(2.5);
- r.createCell(1).setCellValue(1.1);
- r.createCell(2).setCellValue(3.2);
- r.createCell(4).setCellValue(10.7);
-
- r = s.createRow(1);
-
- Cell c1 = r.createCell(0);
- c1.setCellFormula("SUM(A1:B1)");
- assertTrue( Double.isNaN(c1.getNumericCellValue()) );
-
- Cell c2 = r.createCell(1);
- c2.setCellFormula("SUM(A1:E1)");
- assertTrue( Double.isNaN(c2.getNumericCellValue()) );
-
- Cell c3 = r.createCell(2);
- c3.setCellFormula("COUNT(A1:A1)");
- assertTrue( Double.isNaN(c3.getNumericCellValue()) );
+ public void testSimpleArithmatic() {
+ Workbook wb = new XSSFWorkbook();
+ Sheet s = wb.createSheet();
+ Row r = s.createRow(0);
+
+ Cell c1 = r.createCell(0);
+ c1.setCellFormula("1+5");
+ assertTrue( Double.isNaN(c1.getNumericCellValue()) );
+
+ Cell c2 = r.createCell(1);
+ c2.setCellFormula("10/2");
+ assertTrue( Double.isNaN(c2.getNumericCellValue()) );
+
+ FormulaEvaluator fe = new FormulaEvaluator(s, wb);
+
+ fe.evaluateFormulaCell(c1);
+ fe.evaluateFormulaCell(c2);
+
+ assertEquals(6.0, c1.getNumericCellValue(), 0.0001);
+ assertEquals(5.0, c2.getNumericCellValue(), 0.0001);
+ }
+
+ public void testSumCount() {
+ Workbook wb = new XSSFWorkbook();
+ Sheet s = wb.createSheet();
+ Row r = s.createRow(0);
+ r.createCell(0).setCellValue(2.5);
+ r.createCell(1).setCellValue(1.1);
+ r.createCell(2).setCellValue(3.2);
+ r.createCell(4).setCellValue(10.7);
+
+ r = s.createRow(1);
+
+ Cell c1 = r.createCell(0);
+ c1.setCellFormula("SUM(A1:B1)");
+ assertTrue( Double.isNaN(c1.getNumericCellValue()) );
+
+ Cell c2 = r.createCell(1);
+ c2.setCellFormula("SUM(A1:E1)");
+ assertTrue( Double.isNaN(c2.getNumericCellValue()) );
+
+ Cell c3 = r.createCell(2);
+ c3.setCellFormula("COUNT(A1:A1)");
+ assertTrue( Double.isNaN(c3.getNumericCellValue()) );
- Cell c4 = r.createCell(2);
- c4.setCellFormula("COUNTA(A1:E1)");
- assertTrue( Double.isNaN(c4.getNumericCellValue()) );
+ Cell c4 = r.createCell(3);
+ c4.setCellFormula("COUNTA(A1:E1)");
+ assertTrue( Double.isNaN(c4.getNumericCellValue()) );
- // Evaluate and test
- FormulaEvaluator fe = new FormulaEvaluator(s, wb);
- fe.setCurrentRow(r);
-
- fe.evaluateFormulaCell(c1);
- fe.evaluateFormulaCell(c2);
- fe.evaluateFormulaCell(c3);
- fe.evaluateFormulaCell(c4);
-
- assertEquals(3.6, c1.getNumericCellValue(), 0.0001);
- assertEquals(17.5, c2.getNumericCellValue(), 0.0001);
- assertEquals(1, c3.getNumericCellValue(), 0.0001);
- assertEquals(4, c4.getNumericCellValue(), 0.0001);
- }
+ // Evaluate and test
+ FormulaEvaluator fe = new FormulaEvaluator(s, wb);
+
+ fe.evaluateFormulaCell(c1);
+ fe.evaluateFormulaCell(c2);
+ fe.evaluateFormulaCell(c3);
+ fe.evaluateFormulaCell(c4);
+
+ assertEquals(3.6, c1.getNumericCellValue(), 0.0001);
+ assertEquals(17.5, c2.getNumericCellValue(), 0.0001);
+ assertEquals(1, c3.getNumericCellValue(), 0.0001);
+ assertEquals(4, c4.getNumericCellValue(), 0.0001);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org