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 2012/02/08 18:22:47 UTC

svn commit: r1241993 - in /poi/trunk: src/testcases/org/apache/poi/ss/formula/functions/TestCountFuncs.java test-data/spreadsheet/51498.xls

Author: nick
Date: Wed Feb  8 17:22:46 2012
New Revision: 1241993

URL: http://svn.apache.org/viewvc?rev=1241993&view=rev
Log:
Unit test from Maciej for bug #51498

Added:
    poi/trunk/test-data/spreadsheet/51498.xls   (with props)
Modified:
    poi/trunk/src/testcases/org/apache/poi/ss/formula/functions/TestCountFuncs.java

Modified: poi/trunk/src/testcases/org/apache/poi/ss/formula/functions/TestCountFuncs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/formula/functions/TestCountFuncs.java?rev=1241993&r1=1241992&r2=1241993&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/formula/functions/TestCountFuncs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/formula/functions/TestCountFuncs.java Wed Feb  8 17:22:46 2012
@@ -17,6 +17,9 @@
 
 package org.apache.poi.ss.formula.functions;
 
+import java.util.Arrays;
+import java.util.List;
+
 import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
 
@@ -36,6 +39,7 @@ import org.apache.poi.hssf.usermodel.HSS
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.CellValue;
+import org.apache.poi.ss.usermodel.FormulaEvaluator;
 
 /**
  * Test cases for COUNT(), COUNTA() COUNTIF(), COUNTBLANK()
@@ -357,6 +361,33 @@ public final class TestCountFuncs extend
 		confirmPredicate(false, mp, ErrorEval.REF_INVALID);
 	}
 
+   /**
+    * Bug #51498 - Check that CountIf behaves correctly for GTE, LTE
+    *  and NEQ cases
+    */
+	public void testCountifLTEGTE() throws Exception {
+		final int REF_COL = 4;
+		final int EVAL_COL = 3;
+		
+		// Note - POI currently agrees with OpenOffice on certain blank cell cases,
+		//  while Excel can differ. This is the list of checks to skip
+		List<Integer> skipRowsPendingExcelVsOpenOffice = Arrays.asList(
+		      new Integer[] {3});
+
+      HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("51498.xls");
+		FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
+		HSSFSheet sheet = workbook.getSheetAt(0);
+		for (int i = 0; i < 8; i++) {
+		   if (skipRowsPendingExcelVsOpenOffice.contains(i)) {
+		      // Skip the check for now
+		      continue;
+		   }
+			CellValue expected = evaluator.evaluate(sheet.getRow(i).getCell(REF_COL));
+			CellValue actual = evaluator.evaluate(sheet.getRow(i).getCell(EVAL_COL));
+			assertEquals(expected.formatAsString(), actual.formatAsString());
+		}
+	}
+
 	public void testWildCards() {
 		I_MatchPredicate mp;
 

Added: poi/trunk/test-data/spreadsheet/51498.xls
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/51498.xls?rev=1241993&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/spreadsheet/51498.xls
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



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