]> source.dussan.org Git - poi.git/commitdiff
fixed bug in junit which was exposed due to new caching feature of the formula evaluator
authorJosh Micich <josh@apache.org>
Mon, 8 Sep 2008 18:04:34 +0000 (18:04 +0000)
committerJosh Micich <josh@apache.org>
Mon, 8 Sep 2008 18:04:34 +0000 (18:04 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@693179 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java

index 4f2bf1ce077ed5f622bc25344d3ca01dd53d72c8..70a54b5ef92112dda6443a0f916241497fc92dc4 100644 (file)
@@ -26,79 +26,77 @@ import org.apache.poi.ss.usermodel.Workbook;
 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);
+       }
 }