From fdc20e96efa6ace08d39d47935c9a285bacc5ecf Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Wed, 25 May 2022 15:23:51 +0000 Subject: [PATCH] extend dget test git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1901246 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/ss/formula/functions/TestDGet.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/poi/src/test/java/org/apache/poi/ss/formula/functions/TestDGet.java b/poi/src/test/java/org/apache/poi/ss/formula/functions/TestDGet.java index 6947f8d67b..cfbf0b832a 100644 --- a/poi/src/test/java/org/apache/poi/ss/formula/functions/TestDGet.java +++ b/poi/src/test/java/org/apache/poi/ss/formula/functions/TestDGet.java @@ -38,7 +38,7 @@ public class TestDGet { //https://support.microsoft.com/en-us/office/dget-function-455568bf-4eef-45f7-90f0-ec250d00892e @Test void testMicrosoftExample1() throws IOException { - try (HSSFWorkbook wb = initWorkbook1()) { + try (HSSFWorkbook wb = initWorkbook1(false)) { HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb); HSSFCell cell = wb.getSheetAt(0).getRow(0).createCell(100); assertError(fe, cell, "DGET(A5:E11, \"Yield\", A1:A3)", FormulaError.NUM); @@ -46,11 +46,24 @@ public class TestDGet { } } - private HSSFWorkbook initWorkbook1() { + @Test + void testMicrosoftExample1Variant() throws IOException { + try (HSSFWorkbook wb = initWorkbook1(true)) { + HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb); + HSSFCell cell = wb.getSheetAt(0).getRow(0).createCell(100); + assertDouble(fe, cell, "DGET(A5:E11, \"Yield\", A1:F3)", 6); + } + } + + private HSSFWorkbook initWorkbook1(boolean adjustAppleCondition) { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet(); addRow(sheet, 0, "Tree", "Height", "Age", "Yield", "Profit", "Height"); - addRow(sheet, 1, "=Apple", ">10", null, null, null, "<16"); + if (adjustAppleCondition) { + addRow(sheet, 1, "=Apple", ">=8", null, null, null, "<12"); + } else { + addRow(sheet, 1, "=Apple", ">10", null, null, null, "<16"); + } addRow(sheet, 2, "Pear", ">12"); addRow(sheet, 3); addRow(sheet, 4, "Tree", "Height", "Age", "Yield", "Profit");