You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2022/05/26 12:00:10 UTC

svn commit: r1901284 - /poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestSubtotal.java

Author: fanningpj
Date: Thu May 26 12:00:09 2022
New Revision: 1901284

URL: http://svn.apache.org/viewvc?rev=1901284&view=rev
Log:
[bug-66093] add tests

Modified:
    poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestSubtotal.java

Modified: poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestSubtotal.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestSubtotal.java?rev=1901284&r1=1901283&r2=1901284&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestSubtotal.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestSubtotal.java Thu May 26 12:00:09 2022
@@ -323,6 +323,105 @@ final class TestSubtotal {
     }
 
     @Test
+    void testStdevp() throws IOException {
+
+        try (Workbook wb = new HSSFWorkbook()) {
+            FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
+
+            Sheet sh = wb.createSheet();
+            Cell a1 = sh.createRow(1).createCell(1);
+            a1.setCellValue(1);
+            Cell a2 = sh.createRow(2).createCell(1);
+            a2.setCellValue(3);
+            Cell a3 = sh.createRow(3).createCell(1);
+            a3.setCellFormula("SUBTOTAL(8,B2:B3)");
+            Cell a4 = sh.createRow(4).createCell(1);
+            a4.setCellValue(1);
+            Cell a5 = sh.createRow(5).createCell(1);
+            a5.setCellValue(7);
+            Cell a6 = sh.createRow(6).createCell(1);
+            a6.setCellFormula("SUBTOTAL(8,B2:B6)*2 + 2");
+            Cell a7 = sh.createRow(7).createCell(1);
+            a7.setCellFormula("SUBTOTAL(8,B2:B7)");
+            Cell a8 = sh.createRow(8).createCell(1);
+            a8.setCellFormula("SUBTOTAL(8,B2,B3,B4,B5,B6,B7,B8)");
+
+            fe.evaluateAll();
+
+            assertEquals(1.0, a3.getNumericCellValue(), 0.00001);
+            assertEquals(6.898979, a6.getNumericCellValue(), 0.00001);
+            assertEquals(2.44949, a7.getNumericCellValue(), 0.00001);
+            assertEquals(2.44949, a8.getNumericCellValue(), 0.00001);
+        }
+    }
+
+    @Test
+    void testVar() throws IOException {
+
+        try (Workbook wb = new HSSFWorkbook()) {
+            FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
+
+            Sheet sh = wb.createSheet();
+            Cell a1 = sh.createRow(1).createCell(1);
+            a1.setCellValue(1);
+            Cell a2 = sh.createRow(2).createCell(1);
+            a2.setCellValue(3);
+            Cell a3 = sh.createRow(3).createCell(1);
+            a3.setCellFormula("SUBTOTAL(10,B2:B3)");
+            Cell a4 = sh.createRow(4).createCell(1);
+            a4.setCellValue(1);
+            Cell a5 = sh.createRow(5).createCell(1);
+            a5.setCellValue(7);
+            Cell a6 = sh.createRow(6).createCell(1);
+            a6.setCellFormula("SUBTOTAL(10,B2:B6)*2 + 2");
+            Cell a7 = sh.createRow(7).createCell(1);
+            a7.setCellFormula("SUBTOTAL(10,B2:B7)");
+            Cell a8 = sh.createRow(8).createCell(1);
+            a8.setCellFormula("SUBTOTAL(10,B2,B3,B4,B5,B6,B7,B8)");
+
+            fe.evaluateAll();
+
+            assertEquals(2.0, a3.getNumericCellValue());
+            assertEquals(18.0, a6.getNumericCellValue());
+            assertEquals(8.0, a7.getNumericCellValue());
+            assertEquals(8.0, a8.getNumericCellValue());
+        }
+    }
+
+    @Test
+    void testVarp() throws IOException {
+
+        try (Workbook wb = new HSSFWorkbook()) {
+            FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
+
+            Sheet sh = wb.createSheet();
+            Cell a1 = sh.createRow(1).createCell(1);
+            a1.setCellValue(1);
+            Cell a2 = sh.createRow(2).createCell(1);
+            a2.setCellValue(3);
+            Cell a3 = sh.createRow(3).createCell(1);
+            a3.setCellFormula("SUBTOTAL(11,B2:B3)");
+            Cell a4 = sh.createRow(4).createCell(1);
+            a4.setCellValue(1);
+            Cell a5 = sh.createRow(5).createCell(1);
+            a5.setCellValue(7);
+            Cell a6 = sh.createRow(6).createCell(1);
+            a6.setCellFormula("SUBTOTAL(11,B2:B6)*2 + 2");
+            Cell a7 = sh.createRow(7).createCell(1);
+            a7.setCellFormula("SUBTOTAL(11,B2:B7)");
+            Cell a8 = sh.createRow(8).createCell(1);
+            a8.setCellFormula("SUBTOTAL(11,B2,B3,B4,B5,B6,B7,B8)");
+
+            fe.evaluateAll();
+
+            assertEquals(1.0, a3.getNumericCellValue());
+            assertEquals(14.0, a6.getNumericCellValue());
+            assertEquals(6.0, a7.getNumericCellValue());
+            assertEquals(6.0, a8.getNumericCellValue());
+        }
+    }
+
+    @Test
     void test50209() throws IOException {
         Workbook wb = new HSSFWorkbook();
         Sheet sh = wb.createSheet();



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