pjfanning commented on code in PR #330:
URL: https://github.com/apache/poi/pull/330#discussion_r862011973


##########
poi/src/test/java/org/apache/poi/ss/formula/functions/TestAverageIf.java:
##########
@@ -0,0 +1,106 @@
+/*
+ *  ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one or more
+ *    contributor license agreements.  See the NOTICE file distributed with
+ *    this work for additional information regarding copyright ownership.
+ *    The ASF licenses this file to You under the Apache License, Version 2.0
+ *    (the "License"); you may not use this file except in compliance with
+ *    the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ * ====================================================================
+ */
+
+package org.apache.poi.ss.formula.functions;
+
+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;
+import org.apache.poi.ss.formula.eval.ErrorEval;
+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.junit.jupiter.api.Test;
+
+import java.io.IOException;
+
+/**
+ * Test cases for AVERAGEIFS()
+ */
+final class TestAverageIf {
+
+    private static final OperationEvaluationContext EC = new 
OperationEvaluationContext(null, null, 0, 1, 0, null);
+
+    private static ValueEval invokeAverageif(ValueEval[] args) {
+        return new AverageIf().evaluate(args, EC);
+    }
+
+    private static void confirmDouble(double expected, ValueEval actualEval) {
+        assertTrue(actualEval instanceof NumericValueEval, "Expected numeric 
result");
+        NumericValueEval nve = (NumericValueEval)actualEval;
+        assertEquals(expected, nve.getNumberValue(), 0);
+    }
+
+    private static void confirm(double expectedResult, ValueEval[] args) {
+        confirmDouble(expectedResult, invokeAverageif(args));
+    }
+
+    private static void confirmError(ErrorEval errorEval, ValueEval[] args) {
+        ValueEval actualEval = invokeAverageif(args);
+        assertEquals(errorEval, actualEval);
+    }
+
+    /**
+     *  Example 1 from
+     *  
https://support.microsoft.com/en-us/office/maxifs-function-dfd611e6-da2c-488a-919b-9b6376b28883

Review Comment:
   can you use the examples from 
https://support.microsoft.com/en-us/office/averageif-function-faec8e2e-0dec-4308-af69-f5576d8ac642
 though - ie the data and test scenarios?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to