]> source.dussan.org Git - poi.git/commitdiff
add broken test that prvis new averageif code is incorrect
authorPJ Fanning <fanningpj@apache.org>
Fri, 29 Apr 2022 20:26:52 +0000 (20:26 +0000)
committerPJ Fanning <fanningpj@apache.org>
Fri, 29 Apr 2022 20:26:52 +0000 (20:26 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1900397 13f79535-47bb-0310-9956-ffa450edef68

poi/src/test/java/org/apache/poi/ss/formula/functions/TestAverageIf.java

index ed18f31daec97f0b2bb6ebb86e8f876144433d1b..396b4e79ec65b2b9a0f92293145f7f19213a3fbf 100644 (file)
@@ -23,9 +23,7 @@ import static org.apache.poi.ss.util.Utils.*;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.hssf.usermodel.HSSFCell;
-import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.formula.OperationEvaluationContext;
@@ -34,9 +32,12 @@ import org.apache.poi.ss.formula.eval.NumberEval;
 import org.apache.poi.ss.formula.eval.NumericValueEval;
 import org.apache.poi.ss.formula.eval.StringEval;
 import org.apache.poi.ss.formula.eval.ValueEval;
-import org.apache.poi.ss.usermodel.FormulaError;
+import org.apache.poi.ss.usermodel.FormulaEvaluator;
+import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
 
+import java.io.IOException;
+
 
 /**
  * Test cases for AVERAGEIFS()
@@ -117,4 +118,22 @@ final class TestAverageIf {
         confirm(24500, args);
     }
 
+    @Disabled("broken test")
+    @Test
+    void testExample2() throws IOException {
+        try (HSSFWorkbook wb = new HSSFWorkbook()) {
+            HSSFSheet sheet = wb.createSheet();
+            addRow(sheet, 0, "Region", "Profits (Thousands)");
+            addRow(sheet, 1, "East", 45678);
+            addRow(sheet, 2, "West", 23789);
+            addRow(sheet, 3, "North", -4789);
+            addRow(sheet, 4, "South (New Office)", 0);
+            addRow(sheet, 5, "Midwest", 9678);
+            FormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator();
+            HSSFCell testCell = sheet.getRow(0).createCell(100);
+            assertDouble(formulaEvaluator, testCell, "AVERAGEIF(A2:A6,\"=*West\",B2:B6)", 16733.5);
+            assertDouble(formulaEvaluator, testCell, "AVERAGEIF(A2:A6,\"<>*(New Office)\",B2:B6)", 18589);
+        }
+    }
+
 }