aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2012-02-08 17:22:46 +0000
committerNick Burch <nick@apache.org>2012-02-08 17:22:46 +0000
commitc8e2fe7f5ed42cb2b53761a59f8c5adaa1d4af6f (patch)
treec5cc8fd3efd08f6f635cae619c18afde24c668de /src
parente5bdcdd83584a2c2d3b2c8e2028459e0eee5a51a (diff)
downloadpoi-c8e2fe7f5ed42cb2b53761a59f8c5adaa1d4af6f.tar.gz
poi-c8e2fe7f5ed42cb2b53761a59f8c5adaa1d4af6f.zip
Unit test from Maciej for bug #51498
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1241993 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/testcases/org/apache/poi/ss/formula/functions/TestCountFuncs.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestCountFuncs.java b/src/testcases/org/apache/poi/ss/formula/functions/TestCountFuncs.java
index 8897feb60e..a01a92aa00 100644
--- a/src/testcases/org/apache/poi/ss/formula/functions/TestCountFuncs.java
+++ b/src/testcases/org/apache/poi/ss/formula/functions/TestCountFuncs.java
@@ -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.HSSFRow;
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 extends TestCase {
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;