You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2008/09/13 15:48:31 UTC

svn commit: r694947 [6/6] - in /poi/branches/ooxml: ./ src/documentation/content/xdocs/ src/java/org/apache/poi/hssf/extractor/ src/java/org/apache/poi/hssf/model/ src/java/org/apache/poi/hssf/record/ src/java/org/apache/poi/hssf/record/aggregates/ src...

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestLookupFunctionsFromSpreadsheet.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestLookupFunctionsFromSpreadsheet.java?rev=694947&r1=694946&r2=694947&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestLookupFunctionsFromSpreadsheet.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestLookupFunctionsFromSpreadsheet.java Sat Sep 13 06:48:27 2008
@@ -37,33 +37,33 @@
  * Tests lookup functions (VLOOKUP, HLOOKUP, LOOKUP, MATCH) as loaded from a test data spreadsheet.<p/>
  * These tests have been separated from the common function and operator tests because the lookup
  * functions have more complex test cases and test data setup.
- * 
+ *
  * Tests for bug fixes and specific/tricky behaviour can be found in the corresponding test class
  * (<tt>TestXxxx</tt>) of the target (<tt>Xxxx</tt>) implementor, where execution can be observed
  *  more easily.
- * 
+ *
  * @author Josh Micich
  */
 public final class TestLookupFunctionsFromSpreadsheet extends TestCase {
-	
+
 	private static final class Result {
 		public static final int SOME_EVALUATIONS_FAILED = -1;
 		public static final int ALL_EVALUATIONS_SUCCEEDED = +1;
 		public static final int NO_EVALUATIONS_FOUND = 0;
 	}
 
-	/** 
+	/**
 	 * This class defines constants for navigating around the test data spreadsheet used for these tests.
 	 */
 	private static final class SS {
-		
+
 		/** Name of the test spreadsheet (found in the standard test data folder) */
 		public final static String FILENAME = "LookupFunctionsTestCaseData.xls";
-		
+
 		/** Name of the first sheet in the spreadsheet (contains comments) */
 		public final static String README_SHEET_NAME = "Read Me";
-		
-		
+
+
 		/** Row (zero-based) in each sheet where the evaluation cases start.   */
 		public static final int START_TEST_CASES_ROW_INDEX = 4; // Row '5'
 		/**  Index of the column that contains the function names */
@@ -71,15 +71,15 @@
 		public static final int COLUMN_INDEX_EVALUATION = 1; // Column 'B'
 		public static final int COLUMN_INDEX_EXPECTED_RESULT = 2; // Column 'C'
 		public static final int COLUMN_ROW_COMMENT = 3; // Column 'D'
-	
+
 		/** Used to indicate when there are no more test cases on the current sheet   */
 		public static final String TEST_CASES_END_MARKER = "<end>";
 		/** Used to indicate that the test on the current row should be ignored */
 		public static final String SKIP_CURRENT_TEST_CASE_MARKER = "<skip>";
-	
+
 	}
 
- 	// Note - multiple failures are aggregated before ending.  
+	// Note - multiple failures are aggregated before ending.
 	// If one or more functions fail, a single AssertionFailedError is thrown at the end
 	private int _sheetFailureCount;
 	private int _sheetSuccessCount;
@@ -105,19 +105,19 @@
 		if(actual.getCellType() != expected.getCellType()) {
 			throw wrongTypeError(msg, expected, actual);
 		}
-		
-		
+
+
 		switch (expected.getCellType()) {
 			case HSSFCell.CELL_TYPE_BOOLEAN:
 				assertEquals(msg, expected.getBooleanCellValue(), actual.getBooleanValue());
 				break;
 			case HSSFCell.CELL_TYPE_FORMULA: // will never be used, since we will call method after formula evaluation
-				throw new AssertionFailedError("Cannot expect formula as result of formula evaluation: " + msg);
+				throw new IllegalStateException("Cannot expect formula as result of formula evaluation: " + msg);
 			case HSSFCell.CELL_TYPE_NUMERIC:
 				assertEquals(expected.getNumericCellValue(), actual.getNumberValue(), 0.0);
 				break;
 			case HSSFCell.CELL_TYPE_STRING:
-				assertEquals(msg, expected.getRichStringCellValue().getString(), actual.getRichTextStringValue().getString());
+				assertEquals(msg, expected.getRichStringCellValue().getString(), actual.getStringValue());
 				break;
 		}
 	}
@@ -125,14 +125,14 @@
 
 	private static AssertionFailedError wrongTypeError(String msgPrefix, HSSFCell expectedCell, CellValue actualValue) {
 		return new AssertionFailedError(msgPrefix + " Result type mismatch. Evaluated result was "
-				+ formatValue(actualValue) 
+				+ actualValue.formatAsString()
 				+ " but the expected result was "
 				+ formatValue(expectedCell)
 				);
 	}
 	private static AssertionFailedError unexpectedError(String msgPrefix, HSSFCell expected, int actualErrorCode) {
 		return new AssertionFailedError(msgPrefix + " Error code ("
-				+ ErrorEval.getText(actualErrorCode) 
+				+ ErrorEval.getText(actualErrorCode)
 				+ ") was evaluated, but the expected result was "
 				+ formatValue(expected)
 				);
@@ -141,15 +141,15 @@
 
 	private static void confirmErrorResult(String msgPrefix, int expectedErrorCode, CellValue actual) {
 		if(actual.getCellType() != HSSFCell.CELL_TYPE_ERROR) {
-			throw new AssertionFailedError(msgPrefix + " Expected cell error (" 
+			throw new AssertionFailedError(msgPrefix + " Expected cell error ("
 					+ ErrorEval.getText(expectedErrorCode) + ") but actual value was "
-					+ formatValue(actual));
+					+ actual.formatAsString());
 		}
 		if(expectedErrorCode != actual.getErrorValue()) {
-			throw new AssertionFailedError(msgPrefix + " Expected cell error code (" 
-					+ ErrorEval.getText(expectedErrorCode) 
+			throw new AssertionFailedError(msgPrefix + " Expected cell error code ("
+					+ ErrorEval.getText(expectedErrorCode)
 					+ ") but actual error code was ("
-					+ ErrorEval.getText(actual.getErrorValue()) 
+					+ ErrorEval.getText(actual.getErrorValue())
 					+ ")");
 		}
 	}
@@ -164,57 +164,48 @@
 		}
 		throw new RuntimeException("Unexpected cell type of expected value (" + expecedCell.getCellType() + ")");
 	}
-	private static String formatValue(CellValue actual) {
-		switch (actual.getCellType()) {
-			case HSSFCell.CELL_TYPE_BLANK: return "<blank>";
-			case HSSFCell.CELL_TYPE_BOOLEAN: return String.valueOf(actual.getBooleanValue());
-			case HSSFCell.CELL_TYPE_NUMERIC: return String.valueOf(actual.getNumberValue());
-			case HSSFCell.CELL_TYPE_STRING: return actual.getRichTextStringValue().getString();
-		}
-		throw new RuntimeException("Unexpected cell type of evaluated value (" + actual.getCellType() + ")");
-	}
 
 
-	protected void setUp() throws Exception {
+	protected void setUp() {
 		_sheetFailureCount = 0;
 		_sheetSuccessCount = 0;
 		_evaluationFailureCount = 0;
 		_evaluationSuccessCount = 0;
 	}
-	
+
 	public void testFunctionsFromTestSpreadsheet() {
 		HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook(SS.FILENAME);
-   	
+
 		confirmReadMeSheet(workbook);
 		int nSheets = workbook.getNumberOfSheets();
 		for(int i=1; i< nSheets; i++) {
 			int sheetResult = processTestSheet(workbook, i, workbook.getSheetName(i));
 			switch(sheetResult) {
-				case Result.ALL_EVALUATIONS_SUCCEEDED: _sheetSuccessCount ++; break; 
-				case Result.SOME_EVALUATIONS_FAILED: _sheetFailureCount ++; break; 
+				case Result.ALL_EVALUATIONS_SUCCEEDED: _sheetSuccessCount ++; break;
+				case Result.SOME_EVALUATIONS_FAILED: _sheetFailureCount ++; break;
 			}
 		}
-		
+
 		// confirm results
-		String successMsg = "There were " 
+		String successMsg = "There were "
 				+ _sheetSuccessCount + " successful sheets(s) and "
 				+ _evaluationSuccessCount + " function(s) without error";
- 		if(_sheetFailureCount > 0) {
+		if(_sheetFailureCount > 0) {
 			String msg = _sheetFailureCount + " sheets(s) failed with "
 			+ _evaluationFailureCount + " evaluation(s).  " + successMsg;
 			throw new AssertionFailedError(msg);
 		}
- 		if(false) { // normally no output for successful tests
- 			System.out.println(getClass().getName() + ": " + successMsg);
- 		}
+		if(false) { // normally no output for successful tests
+			System.out.println(getClass().getName() + ": " + successMsg);
+		}
 	}
 
 	private int processTestSheet(HSSFWorkbook workbook, int sheetIndex, String sheetName) {
 		HSSFSheet sheet = workbook.getSheetAt(sheetIndex);
-		HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(sheet, workbook);
+		HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(workbook);
 		int maxRows = sheet.getLastRowNum()+1;
 		int result = Result.NO_EVALUATIONS_FOUND; // so far
-		
+
 		String currentGroupComment = null;
 		for(int rowIndex=SS.START_TEST_CASES_ROW_INDEX; rowIndex<maxRows; rowIndex++) {
 			HSSFRow r = sheet.getRow(rowIndex);
@@ -240,7 +231,7 @@
 			CellValue actualValue = evaluator.evaluate(c);
 			HSSFCell expectedValueCell = r.getCell(SS.COLUMN_INDEX_EXPECTED_RESULT);
 			String rowComment = getRowCommentColumnValue(r);
-			
+
 			String msgPrefix = formatTestCaseDetails(sheetName, r.getRowNum(), c, currentGroupComment, rowComment);
 			try {
 				confirmExpectedResult(msgPrefix, expectedValueCell, actualValue);
@@ -257,22 +248,22 @@
 				printShortStackTrace(System.err, e);
 				result = Result.SOME_EVALUATIONS_FAILED;
 			}
-			
+
 		}
-		throw new RuntimeException("Missing end marker '" + SS.TEST_CASES_END_MARKER 
+		throw new RuntimeException("Missing end marker '" + SS.TEST_CASES_END_MARKER
 				+ "' on sheet '" + sheetName + "'");
-		
+
 	}
 
 
 	private static String formatTestCaseDetails(String sheetName, int rowNum, HSSFCell c, String currentGroupComment,
 			String rowComment) {
-		
+
 		StringBuffer sb = new StringBuffer();
 		CellReference cr = new CellReference(sheetName, rowNum, c.getCellNum(), false, false);
 		sb.append(cr.formatAsString());
 		sb.append(" {=").append(c.getCellFormula()).append("}");
-		
+
 		if(currentGroupComment != null) {
 			sb.append(" '");
 			sb.append(currentGroupComment);
@@ -288,13 +279,13 @@
 				sb.append("' ");
 			}
 		}
-		
+
 		return sb.toString();
 	}
 
 	/**
-	 * Asserts that the 'read me' comment page exists, and has this class' name in one of the 
-	 * cells.  This back-link is to make it easy to find this class if a reader encounters the 
+	 * Asserts that the 'read me' comment page exists, and has this class' name in one of the
+	 * cells.  This back-link is to make it easy to find this class if a reader encounters the
 	 * spreadsheet first.
 	 */
 	private void confirmReadMeSheet(HSSFWorkbook workbook) {
@@ -313,7 +304,7 @@
 	 */
 	private static void printShortStackTrace(PrintStream ps, Throwable e) {
 		StackTraceElement[] stes = e.getStackTrace();
-		
+
 		int startIx = 0;
 		// skip any top frames inside junit.framework.Assert
 		while(startIx<stes.length) {
@@ -339,17 +330,17 @@
 		for(int i=startIx; i<endIx; i++) {
 			ps.println("\tat " + stes[i].toString());
 		}
-		
+
 	}
 
 	private static String getRowCommentColumnValue(HSSFRow r) {
 		return getCellTextValue(r, SS.COLUMN_ROW_COMMENT, "row comment");
 	}
-	
+
 	private static String getMarkerColumnValue(HSSFRow r) {
 		return getCellTextValue(r, SS.COLUMN_INDEX_MARKER, "marker");
 	}
-	
+
 	/**
 	 * @return <code>null</code> if cell is missing, empty or blank
 	 */
@@ -367,7 +358,7 @@
 		if(cell.getCellType() == HSSFCell.CELL_TYPE_STRING) {
 			return cell.getRichStringCellValue().getString();
 		}
-		
+
 		throw new RuntimeException("Bad cell type for '" + columnName + "' column: ("
 				+ cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")");
 	}

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestMid.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestMid.java?rev=694947&r1=694946&r2=694947&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestMid.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestMid.java Sat Sep 13 06:48:27 2008
@@ -38,7 +38,7 @@
 
 	private static Eval invokeMid(Eval text, Eval startPos, Eval numChars) {
 		Eval[] args = new Eval[] { text, startPos, numChars, };
-		return new Mid().evaluate(args, -1, (short)-1);
+		return TextFunction.MID.evaluate(args, -1, (short)-1);
 	}
 
 	private void confirmMid(Eval text, Eval startPos, Eval numChars, String expected) {

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestPmt.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestPmt.java?rev=694947&r1=694946&r2=694947&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestPmt.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestPmt.java Sat Sep 13 06:48:27 2008
@@ -36,7 +36,7 @@
 		assertEquals(expected, ne.getNumberValue(), 0.00005);
 	}
 	private static Eval invoke(Eval[] args) {
-		return new Pmt().evaluate(args, -1, (short)-1);
+		return FinanceFunction.PMT.evaluate(args, -1, (short)-1);
 	}
 	/**
 	 * Invocation when not expecting an error result

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestRoundFuncs.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestRoundFuncs.java?rev=694947&r1=694946&r2=694947&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestRoundFuncs.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestRoundFuncs.java Sat Sep 13 06:48:27 2008
@@ -17,24 +17,25 @@
 
 package org.apache.poi.hssf.record.formula.functions;
 
+import junit.framework.TestCase;
+
 import org.apache.poi.hssf.record.formula.eval.ErrorEval;
 import org.apache.poi.hssf.record.formula.eval.Eval;
 import org.apache.poi.hssf.record.formula.eval.NumberEval;
 import org.apache.poi.hssf.record.formula.eval.StringEval;
 
-import junit.framework.TestCase;
-
 /**
  * Test cases for ROUND(), ROUNDUP(), ROUNDDOWN()
  * 
  * @author Josh Micich
  */
 public final class TestRoundFuncs extends TestCase {
+	private static final NumericFunction F = null;
 	public void testRounddownWithStringArg() {
 		
 		Eval strArg = new StringEval("abc");
 		Eval[] args = { strArg, new NumberEval(2), };
-		Eval result = new Rounddown().evaluate(args, -1, (short)-1);
+		Eval result = F.ROUNDDOWN.evaluate(args, -1, (short)-1);
 		assertEquals(ErrorEval.VALUE_INVALID, result);
 	}
 	
@@ -42,7 +43,7 @@
 		
 		Eval strArg = new StringEval("abc");
 		Eval[] args = { strArg, new NumberEval(2), };
-		Eval result = new Roundup().evaluate(args, -1, (short)-1);
+		Eval result = F.ROUNDUP.evaluate(args, -1, (short)-1);
 		assertEquals(ErrorEval.VALUE_INVALID, result);
 	}
 	

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestStatsLib.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestStatsLib.java?rev=694947&r1=694946&r2=694947&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestStatsLib.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestStatsLib.java Sat Sep 13 06:48:27 2008
@@ -20,6 +20,11 @@
  */
 package org.apache.poi.hssf.record.formula.functions;
 
+import junit.framework.AssertionFailedError;
+
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.EvaluationException;
+
 
 /**
  * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
@@ -181,49 +186,53 @@
     }
 
     public void testMode() {
-        double[] v = null;
+        double[] v;
         double d, x = 0;
         
         v = new double[] {1,2,3,4,5,6,7,8,9,10};
-        d = StatsLib.mode(v);
-        x = Double.NaN;
-        assertEquals("mode ", x, d);
+        confirmMode(v, null);
         
         v = new double[] {1,1,1,1,1,1,1,1,1,1};
-        d = StatsLib.mode(v);
-        x = 1;
-        assertEquals("mode ", x, d);
+        confirmMode(v, 1.0);
         
         v = new double[] {0,0,0,0,0,0,0,0,0,0};
-        d = StatsLib.mode(v);
-        x = 0;
-        assertEquals("mode ", x, d);
+        confirmMode(v, 0.0);
         
         v = new double[] {1,2,1,2,1,2,1,2,1,2};
-        d = StatsLib.mode(v);
-        x = 1;
-        assertEquals("mode ", x, d);
+        confirmMode(v, 1.0);
         
         v = new double[] {123.12,33.3333,2d/3d,5.37828,0.999};
-        d = StatsLib.mode(v);
-        x = Double.NaN;
-        assertEquals("mode ", x, d);
+        confirmMode(v, null);
         
         v = new double[] {-1,-2,-3,-4,-5,-6,-7,-8,-9,-10};
-        d = StatsLib.mode(v);
-        x = Double.NaN;
-        assertEquals("mode ", x, d);
+        confirmMode(v, null);
         
         v = new double[] {1,2,3,4,1,1,1,1,0,0,0,0,0};
-        d = StatsLib.mode(v);
-        x = 1;
-        assertEquals("mode ", x, d);
+        confirmMode(v, 1.0);
         
         v = new double[] {0,1,2,3,4,1,1,1,0,0,0,0,1};
-        d = StatsLib.mode(v);
-        x = 0;
-        assertEquals("mode ", x, d);
+        confirmMode(v, 0.0);
+    }
+    private static void confirmMode(double[] v, double expectedResult) {
+    	confirmMode(v, new Double(expectedResult));
+    }
+    private static void confirmMode(double[] v, Double expectedResult) {
+    	double actual;
+		try {
+			actual = Mode.evaluate(v);
+			if (expectedResult == null) {
+				throw new AssertionFailedError("Expected N/A exception was not thrown");
+			}
+		} catch (EvaluationException e) {
+			if (expectedResult == null) {
+				assertEquals(ErrorEval.NA, e.getErrorEval());
+				return;
+			}
+			throw new RuntimeException(e);
+		}
+    	assertEquals("mode", expectedResult.doubleValue(), actual);
     }
+    
 
     public void testStddev() {
         double[] v = null;

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestTrim.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestTrim.java?rev=694947&r1=694946&r2=694947&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestTrim.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestTrim.java Sat Sep 13 06:48:27 2008
@@ -35,7 +35,7 @@
 	
 	private static Eval invokeTrim(Eval text) {
 		Eval[] args = new Eval[] { text, };
-		return new Trim().evaluate(args, -1, (short)-1);
+		return TextFunction.TRIM.evaluate(args, -1, (short)-1);
 	}
 
 	private void confirmTrim(Eval text, String expected) {

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBug42464.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBug42464.java?rev=694947&r1=694946&r2=694947&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBug42464.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBug42464.java Sat Sep 13 06:48:27 2008
@@ -43,10 +43,9 @@
 	}
 	
 	private static void process(HSSFWorkbook wb) {
+		HSSFFormulaEvaluator eval =	new HSSFFormulaEvaluator(wb);
 		for(int i=0; i<wb.getNumberOfSheets(); i++) {
 			HSSFSheet s = wb.getSheetAt(i);
-			HSSFFormulaEvaluator eval =
-				new HSSFFormulaEvaluator(s, wb);
 			
 			Iterator it = s.rowIterator();
 			while(it.hasNext()) {

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBug43093.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBug43093.java?rev=694947&r1=694946&r2=694947&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBug43093.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBug43093.java Sat Sep 13 06:48:27 2008
@@ -39,7 +39,7 @@
 	}
 
 	public void testBug43093() {
-		HSSFWorkbook     xlw    = new HSSFWorkbook();
+		HSSFWorkbook xlw = new HSSFWorkbook();
 
 		addNewSheetWithCellsA1toD4(xlw, 1);
 		addNewSheetWithCellsA1toD4(xlw, 2);
@@ -51,7 +51,7 @@
 		HSSFCell  s2E4 = s2r3.createCell(4);
 		s2E4.setCellFormula("SUM(s3!B2:C3)");
 
-		HSSFFormulaEvaluator eva = new HSSFFormulaEvaluator(s2, xlw);
+		HSSFFormulaEvaluator eva = new HSSFFormulaEvaluator(xlw);
 		double d = eva.evaluate(s2E4).getNumberValue();
 
 		// internalEvaluate(...) Area3DEval.: 311+312+321+322 expected

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=694947&r1=694946&r2=694947&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Sat Sep 13 06:48:27 2008
@@ -963,7 +963,7 @@
         writeOutAndReadBack(wb);
         assertTrue("no errors writing sample xls", true);
     }
-    
+
     /**
      * Problems with extracting check boxes from
      *  HSSFObjectData
@@ -975,35 +975,35 @@
         // Take a look at the embeded objects
         List objects = wb.getAllEmbeddedObjects();
         assertEquals(1, objects.size());
-        
+
         HSSFObjectData obj = (HSSFObjectData)objects.get(0);
         assertNotNull(obj);
-        
+
         // Peek inside the underlying record
         EmbeddedObjectRefSubRecord rec = obj.findObjectRecord();
         assertNotNull(rec);
-        
+
         assertEquals(32, rec.field_1_stream_id_offset);
         assertEquals(0, rec.field_6_stream_id); // WRONG!
         assertEquals("Forms.CheckBox.1", rec.field_5_ole_classname);
         assertEquals(12, rec.remainingBytes.length);
-        
+
         // Doesn't have a directory
         assertFalse(obj.hasDirectoryEntry());
         assertNotNull(obj.getObjectData());
         assertEquals(12, obj.getObjectData().length);
         assertEquals("Forms.CheckBox.1", obj.getOLE2ClassName());
-        
+
         try {
             obj.getDirectory();
             fail();
         } catch(FileNotFoundException e) {
-        	// expectd during successful test
+            // expectd during successful test
         } catch (IOException e) {
-			throw new RuntimeException(e);
-		}
+            throw new RuntimeException(e);
+        }
     }
-    
+
     /**
      * Test that we can delete sheets without
      *  breaking the build in named ranges
@@ -1013,73 +1013,73 @@
         HSSFWorkbook wb = openSample("30978-alt.xls");
         assertEquals(1, wb.getNumberOfNames());
         assertEquals(3, wb.getNumberOfSheets());
-        
+
         // Check all names fit within range, and use
         //  DeletedArea3DPtg
         Workbook w = wb.getWorkbook();
         for(int i=0; i<w.getNumNames(); i++) {
             NameRecord r = w.getNameRecord(i);
             assertTrue(r.getSheetNumber() <= wb.getNumberOfSheets());
-            
+
             Ptg[] nd = r.getNameDefinition();
             assertEquals(1, nd.length);
             assertTrue(nd[0] instanceof DeletedArea3DPtg);
         }
-        
-        
+
+
         // Delete the 2nd sheet
         wb.removeSheetAt(1);
-        
-        
+
+
         // Re-check
         assertEquals(1, wb.getNumberOfNames());
         assertEquals(2, wb.getNumberOfSheets());
-        
+
         for(int i=0; i<w.getNumNames(); i++) {
             NameRecord r = w.getNameRecord(i);
             assertTrue(r.getSheetNumber() <= wb.getNumberOfSheets());
-            
+
             Ptg[] nd = r.getNameDefinition();
             assertEquals(1, nd.length);
             assertTrue(nd[0] instanceof DeletedArea3DPtg);
         }
-        
-        
+
+
         // Save and re-load
         wb = writeOutAndReadBack(wb);
         w = wb.getWorkbook();
-        
+
         assertEquals(1, wb.getNumberOfNames());
         assertEquals(2, wb.getNumberOfSheets());
-        
+
         for(int i=0; i<w.getNumNames(); i++) {
             NameRecord r = w.getNameRecord(i);
             assertTrue(r.getSheetNumber() <= wb.getNumberOfSheets());
-            
+
             Ptg[] nd = r.getNameDefinition();
             assertEquals(1, nd.length);
             assertTrue(nd[0] instanceof DeletedArea3DPtg);
         }
     }
-    
+
     /**
      * Test that fonts get added properly
      */
     public void test45338() {
         HSSFWorkbook wb = new HSSFWorkbook();
         assertEquals(4, wb.getNumberOfFonts());
-        
+
         HSSFSheet s = wb.createSheet();
         s.createRow(0);
         s.createRow(1);
         HSSFCell c1 = s.getRow(0).createCell(0);
         HSSFCell c2 = s.getRow(1).createCell(0);
-        
+
         assertEquals(4, wb.getNumberOfFonts());
-        
+
         HSSFFont f1 = wb.getFontAt((short)0);
         assertEquals(400, f1.getBoldweight());
-        
+
         // Check that asking for the same font
         //  multiple times gives you the same thing.
         // Otherwise, our tests wouldn't work!
@@ -1096,22 +1096,22 @@
                 !=
                 wb.getFontAt((short)2)
         );
-        
+
         // Look for a new font we have
         //  yet to add
         assertNull(
             wb.findFont(
-                (short)11, (short)123, (short)22, 
+                (short)11, (short)123, (short)22,
                 "Thingy", false, true, (short)2, (byte)2
             )
         );
-        
+
         HSSFFont nf = wb.createFont();
         assertEquals(5, wb.getNumberOfFonts());
-        
+
         assertEquals(5, nf.getIndex());
         assertEquals(nf, wb.getFontAt((short)5));
-        
+
         nf.setBoldweight((short)11);
         nf.setColor((short)123);
         nf.setFontHeight((short)22);
@@ -1120,32 +1120,32 @@
         nf.setStrikeout(true);
         nf.setTypeOffset((short)2);
         nf.setUnderline((byte)2);
-        
+
         assertEquals(5, wb.getNumberOfFonts());
         assertEquals(nf, wb.getFontAt((short)5));
-        
+
         // Find it now
         assertNotNull(
             wb.findFont(
-                (short)11, (short)123, (short)22, 
+                (short)11, (short)123, (short)22,
                 "Thingy", false, true, (short)2, (byte)2
             )
         );
         assertEquals(
             5,
             wb.findFont(
-                   (short)11, (short)123, (short)22, 
+                   (short)11, (short)123, (short)22,
                    "Thingy", false, true, (short)2, (byte)2
                ).getIndex()
         );
         assertEquals(nf,
                wb.findFont(
-                   (short)11, (short)123, (short)22, 
+                   (short)11, (short)123, (short)22,
                    "Thingy", false, true, (short)2, (byte)2
                )
         );
     }
-    
+
     /**
      * From the mailing list - ensure we can handle a formula
      *  containing a zip code, eg ="70164"
@@ -1162,63 +1162,59 @@
         c1.setCellFormula("70164");
         c2.setCellFormula("\"70164\"");
         c3.setCellFormula("\"90210\"");
-        
+
         // Check the formulas
         assertEquals("70164.0", c1.getCellFormula());
         assertEquals("\"70164\"", c2.getCellFormula());
-        
+
         // And check the values - blank
-        assertEquals(0.0, c1.getNumericCellValue(), 0.00001);
-        assertEquals("", c1.getRichStringCellValue().getString());
-        assertEquals(0.0, c2.getNumericCellValue(), 0.00001);
-        assertEquals("", c2.getRichStringCellValue().getString());
-        assertEquals(0.0, c3.getNumericCellValue(), 0.00001);
-        assertEquals("", c3.getRichStringCellValue().getString());
-        
+        confirmCachedValue(0.0, c1);
+        confirmCachedValue(0.0, c2);
+        confirmCachedValue(0.0, c3);
+
         // Try changing the cached value on one of the string
         //  formula cells, so we can see it updates properly
         c3.setCellValue(new HSSFRichTextString("test"));
-        assertEquals(0.0, c3.getNumericCellValue(), 0.00001);
-        assertEquals("test", c3.getRichStringCellValue().getString());
-        
-        
+        confirmCachedValue("test", c3);
+        try {
+            c3.getNumericCellValue();
+            throw new AssertionFailedError("exception should have been thrown");
+        } catch (IllegalStateException e) {
+            assertEquals("Cannot get a numeric value from a text formula cell", e.getMessage());
+        }
+
+
         // Now evaluate, they should all be changed
-        HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator(s, wb);
+        HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator(wb);
         eval.evaluateFormulaCell(c1);
         eval.evaluateFormulaCell(c2);
         eval.evaluateFormulaCell(c3);
-        
+
         // Check that the cells now contain
         //  the correct values
-        assertEquals(70164.0, c1.getNumericCellValue(), 0.00001);
-        assertEquals("", c1.getRichStringCellValue().getString());
-        assertEquals(0.0, c2.getNumericCellValue(), 0.00001);
-        assertEquals("70164", c2.getRichStringCellValue().getString());
-        assertEquals(0.0, c3.getNumericCellValue(), 0.00001);
-        assertEquals("90210", c3.getRichStringCellValue().getString());
-  
-        
+        confirmCachedValue(70164.0, c1);
+        confirmCachedValue("70164", c2);
+        confirmCachedValue("90210", c3);
+
+
         // Write and read
         HSSFWorkbook nwb = writeOutAndReadBack(wb);
         HSSFSheet ns = nwb.getSheetAt(0);
         HSSFCell nc1 = ns.getRow(0).getCell(0);
         HSSFCell nc2 = ns.getRow(0).getCell(1);
         HSSFCell nc3 = ns.getRow(0).getCell(2);
-        
+
         // Re-check
-        assertEquals(70164.0, nc1.getNumericCellValue(), 0.00001);
-        assertEquals("", nc1.getRichStringCellValue().getString());
-        assertEquals(0.0, nc2.getNumericCellValue(), 0.00001);
-        assertEquals("70164", nc2.getRichStringCellValue().getString());
-        assertEquals(0.0, nc3.getNumericCellValue(), 0.00001);
-        assertEquals("90210", nc3.getRichStringCellValue().getString());
-        
+        confirmCachedValue(70164.0, nc1);
+        confirmCachedValue("70164", nc2);
+        confirmCachedValue("90210", nc3);
+
         CellValueRecordInterface[] cvrs = ns.getSheet().getValueRecords();
         for (int i = 0; i < cvrs.length; i++) {
             CellValueRecordInterface cvr = cvrs[i];
             if(cvr instanceof FormulaRecordAggregate) {
                 FormulaRecordAggregate fr = (FormulaRecordAggregate)cvr;
-                
+
                 if(i == 0) {
                     assertEquals(70164.0, fr.getFormulaRecord().getValue(), 0.0001);
                     assertNull(fr.getStringRecord());
@@ -1235,7 +1231,18 @@
         }
         assertEquals(3, cvrs.length);
     }
-    
+
+    private static void confirmCachedValue(double expectedValue, HSSFCell cell) {
+        assertEquals(HSSFCell.CELL_TYPE_FORMULA, cell.getCellType());
+        assertEquals(HSSFCell.CELL_TYPE_NUMERIC, cell.getCachedFormulaResultType());
+        assertEquals(expectedValue, cell.getNumericCellValue(), 0.0);
+    }
+    private static void confirmCachedValue(String expectedValue, HSSFCell cell) {
+        assertEquals(HSSFCell.CELL_TYPE_FORMULA, cell.getCellType());
+        assertEquals(HSSFCell.CELL_TYPE_STRING, cell.getCachedFormulaResultType());
+        assertEquals(expectedValue, cell.getRichStringCellValue().getString());
+    }
+
     /**
      * Problem with "Vector Rows", eg a whole
      *  column which is set to the result of
@@ -1244,37 +1251,37 @@
      *  {=sin(B1:B9){9,1)[rownum][0]
      * In this sample file, the vector column
      *  is C, and the data column is B.
-     *  
+     *
      * For now, blows up with an exception from ExtPtg
      *  Expected ExpPtg to be converted from Shared to Non-Shared...
      */
     public void DISABLEDtest43623() {
         HSSFWorkbook wb = openSample("43623.xls");
         assertEquals(1, wb.getNumberOfSheets());
-        
+
         HSSFSheet s1 = wb.getSheetAt(0);
-        
+
         HSSFCell c1 = s1.getRow(0).getCell(2);
         HSSFCell c2 = s1.getRow(1).getCell(2);
         HSSFCell c3 = s1.getRow(2).getCell(2);
-        
+
         // These formula contents are a guess...
         assertEquals("{=sin(B1:B9){9,1)[0][0]", c1.getCellFormula());
         assertEquals("{=sin(B1:B9){9,1)[1][0]", c2.getCellFormula());
         assertEquals("{=sin(B1:B9){9,1)[2][0]", c3.getCellFormula());
-        
+
         // Save and re-open, ensure it still works
         HSSFWorkbook nwb = writeOutAndReadBack(wb);
         HSSFSheet ns1 = nwb.getSheetAt(0);
         HSSFCell nc1 = ns1.getRow(0).getCell(2);
         HSSFCell nc2 = ns1.getRow(1).getCell(2);
         HSSFCell nc3 = ns1.getRow(2).getCell(2);
-        
+
         assertEquals("{=sin(B1:B9){9,1)[0][0]", nc1.getCellFormula());
         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
@@ -1282,48 +1289,48 @@
     public void test30635() {
         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(0);
         assertEquals(0, r.getFirstCellNum());
         assertEquals(1, r.getLastCellNum()); // last cell # + 1
         assertEquals(1, r.getPhysicalNumberOfCells());
-        
+
         r.createCell(1);
         assertEquals(0, r.getFirstCellNum());
         assertEquals(2, r.getLastCellNum()); // last cell # + 1
         assertEquals(2, r.getPhysicalNumberOfCells());
-        
+
         r.createCell(4);
         assertEquals(0, r.getFirstCellNum());
         assertEquals(5, r.getLastCellNum()); // last cell # + 1
         assertEquals(3, r.getPhysicalNumberOfCells());
     }
-    
+
     /**
      * Data Tables - ptg 0x2
      */
@@ -1332,25 +1339,25 @@
         HSSFSheet s;
         HSSFRow r;
         HSSFCell c;
-        
+
         // Check the contents of the formulas
-        
+
         // E4 to G9 of sheet 4 make up the table
         s = wb.getSheet("OneVariable Table Completed");
         r = s.getRow(3);
         c = r.getCell(4);
         assertEquals(HSSFCell.CELL_TYPE_FORMULA, c.getCellType());
-        
+
         // TODO - check the formula once tables and
         //  arrays are properly supported
 
-        
+
         // E4 to H9 of sheet 5 make up the table
         s = wb.getSheet("TwoVariable Table Example");
         r = s.getRow(3);
         c = r.getCell(4);
         assertEquals(HSSFCell.CELL_TYPE_FORMULA, c.getCellType());
-        
+
         // TODO - check the formula once tables and
         //  arrays are properly supported
     }
@@ -1363,7 +1370,7 @@
         HSSFSheet sh = wb.getSheetAt(0);
         for(short i=0; i < 30; i++) sh.autoSizeColumn(i);
      }
-    
+
     /**
      * We used to add too many UncalcRecords to sheets
      *  with diagrams on. Don't any more
@@ -1373,41 +1380,41 @@
         wb.getSheetAt(0).setForceFormulaRecalculation(true);
         wb.getSheetAt(1).setForceFormulaRecalculation(false);
         wb.getSheetAt(2).setForceFormulaRecalculation(true);
-        
+
         // Write out and back in again
         // This used to break
         HSSFWorkbook nwb = writeOutAndReadBack(wb);
-        
+
         // Check now set as it should be
         assertTrue(nwb.getSheetAt(0).getForceFormulaRecalculation());
         assertFalse(nwb.getSheetAt(1).getForceFormulaRecalculation());
         assertTrue(nwb.getSheetAt(2).getForceFormulaRecalculation());
     }
-    
+
     /**
      * Very hidden sheets not displaying as such
      */
     public void test45761() {
-    	HSSFWorkbook wb = openSample("45761.xls");
-    	assertEquals(3, wb.getNumberOfSheets());
-    	
-    	assertFalse(wb.isSheetHidden(0));
-    	assertFalse(wb.isSheetVeryHidden(0));
-    	assertTrue(wb.isSheetHidden(1));
-    	assertFalse(wb.isSheetVeryHidden(1));
-    	assertFalse(wb.isSheetHidden(2));
-    	assertTrue(wb.isSheetVeryHidden(2));
-    	
-    	// Change 0 to be very hidden, and re-load
-    	wb.setSheetHidden(0, 2);
-    	
+        HSSFWorkbook wb = openSample("45761.xls");
+        assertEquals(3, wb.getNumberOfSheets());
+
+        assertFalse(wb.isSheetHidden(0));
+        assertFalse(wb.isSheetVeryHidden(0));
+        assertTrue(wb.isSheetHidden(1));
+        assertFalse(wb.isSheetVeryHidden(1));
+        assertFalse(wb.isSheetHidden(2));
+        assertTrue(wb.isSheetVeryHidden(2));
+
+        // Change 0 to be very hidden, and re-load
+        wb.setSheetHidden(0, 2);
+
         HSSFWorkbook nwb = writeOutAndReadBack(wb);
 
-    	assertFalse(nwb.isSheetHidden(0));
-    	assertTrue(nwb.isSheetVeryHidden(0));
-    	assertTrue(nwb.isSheetHidden(1));
-    	assertFalse(nwb.isSheetVeryHidden(1));
-    	assertFalse(nwb.isSheetHidden(2));
-    	assertTrue(nwb.isSheetVeryHidden(2));
+        assertFalse(nwb.isSheetHidden(0));
+        assertTrue(nwb.isSheetVeryHidden(0));
+        assertTrue(nwb.isSheetHidden(1));
+        assertFalse(nwb.isSheetVeryHidden(1));
+        assertFalse(nwb.isSheetHidden(2));
+        assertTrue(nwb.isSheetVeryHidden(2));
     }
 }

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java?rev=694947&r1=694946&r2=694947&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java Sat Sep 13 06:48:27 2008
@@ -117,7 +117,7 @@
 
 		HSSFSheet sheet = wb.getSheetAt(0);
 
-		HSSFFormulaEvaluator eva = new HSSFFormulaEvaluator(sheet, wb);
+		HSSFFormulaEvaluator eva = new HSSFFormulaEvaluator(wb);
 
 		row = sheet.getRow(0);
 		cell = row.getCell(0);
@@ -177,7 +177,7 @@
 
 		HSSFSheet sheet = wb.getSheetAt(0);
 
-		HSSFFormulaEvaluator eva = new HSSFFormulaEvaluator(sheet, wb);
+		HSSFFormulaEvaluator eva = new HSSFFormulaEvaluator(wb);
 
 		// =index(C:C,2,1) -> 2
 		HSSFRow rowIDX = sheet.getRow(3);
@@ -238,7 +238,7 @@
 
 		cell.setCellFormula("1=1");
 
-		HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(sheet, wb);
+		HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
 		try {
 			fe.evaluateInCell(cell);
 		} catch (NumberFormatException e) {
@@ -257,7 +257,7 @@
 		int numSheets = wb.getNumberOfSheets();
 		for (int i = 0; i < numSheets; i++) {
 			HSSFSheet s = wb.getSheetAt(i);
-			HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator(s, wb);
+			HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator(wb);
 
 			for (Iterator rows = s.rowIterator(); rows.hasNext();) {
 				HSSFRow r = (HSSFRow) rows.next();
@@ -276,7 +276,7 @@
 		HSSFRow row = sheet.createRow(1);
 		HSSFCell cell = row.createCell(0);
 		cell.setCellFormula("na()"); // this formula evaluates to an Excel error code '#N/A'
-		HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(sheet, wb);
+		HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
 		try {
 			fe.evaluateInCell(cell);
 		} catch (NumberFormatException e) {
@@ -312,7 +312,7 @@
 		
 		// Choose cell A9, so that the failing test case doesn't take too long to execute.
 		HSSFCell cell = row.getCell(8);
-		HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(sheet, wb);
+		HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb);
 		evaluator.evaluate(cell);
 		int evalCount = evaluator.getEvaluationCount();
 		// With caching, the evaluationCount is 8 which is a big improvement

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorDocs.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorDocs.java?rev=694947&r1=694946&r2=694947&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorDocs.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorDocs.java Sat Sep 13 06:48:27 2008
@@ -68,7 +68,7 @@
 		// uses evaluateFormulaCell()
 		for(int sheetNum = 0; sheetNum < wb.getNumberOfSheets(); sheetNum++) {
 			HSSFSheet sheet = wb.getSheetAt(sheetNum);
-			HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(sheet, wb);
+			HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb);
 
 			for(Iterator rit = sheet.rowIterator(); rit.hasNext();) {
 				HSSFRow r = (HSSFRow)rit.next();
@@ -103,7 +103,7 @@
 		// uses evaluateInCell()
 		for(int sheetNum = 0; sheetNum < wb.getNumberOfSheets(); sheetNum++) {
 			HSSFSheet sheet = wb.getSheetAt(sheetNum);
-			HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(sheet, wb);
+			HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb);
 
 			for(Iterator rit = sheet.rowIterator(); rit.hasNext();) {
 				HSSFRow r = (HSSFRow)rit.next();

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java?rev=694947&r1=694946&r2=694947&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java Sat Sep 13 06:48:27 2008
@@ -243,7 +243,7 @@
 		assertEquals("SUM(12.25,12.25)/100", formatter.formatCellValue(cell));
 
 		// now with a formula evaluator
-		HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb.getSheetAt(0), wb);
+		HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb);
 		log(formatter.formatCellValue(cell, evaluator) + "\t\t\t (with evaluator)");
 		assertEquals("24.50%", formatter.formatCellValue(cell,evaluator));
 	}
@@ -257,7 +257,7 @@
 		Iterator it = row.cellIterator();
 		Format defaultFormat = new DecimalFormat("Balance $#,#00.00 USD;Balance -$#,#00.00 USD");
 		formatter.setDefaultNumberFormat(defaultFormat);
-		double value = 10d;
+
 		log("\n==== DEFAULT NUMBER FORMAT ====");
 		while (it.hasNext()) {
 			HSSFCell cell = (HSSFCell) it.next();

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java?rev=694947&r1=694946&r2=694947&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java Sat Sep 13 06:48:27 2008
@@ -35,7 +35,7 @@
 		HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("testNames.xls");
 		HSSFSheet sheet = wb.getSheetAt(0);
 		HSSFCell cell = sheet.getRow(8).getCell(0);
-		HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(sheet, wb);
+		HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
 		CellValue cv = fe.evaluate(cell);
 		assertEquals(HSSFCell.CELL_TYPE_NUMERIC, cv.getCellType());
 		assertEquals(3.72, cv.getNumberValue(), 0.0);
@@ -67,7 +67,7 @@
 		setValue(sheet, 3, 6, 100.0);
 		
 		
-		HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(sheet, wb);
+		HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
 		assertEquals(26.0, fe.evaluate(cell0).getNumberValue(), 0.0);
 		assertEquals(56.0, fe.evaluate(cell1).getNumberValue(), 0.0);
 	}



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