]> source.dussan.org Git - poi.git/commitdiff
Add unit test showing that bug #51024 is incorrect
authorNick Burch <nick@apache.org>
Fri, 8 Apr 2011 15:23:18 +0000 (15:23 +0000)
committerNick Burch <nick@apache.org>
Fri, 8 Apr 2011 15:23:18 +0000 (15:23 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1090293 13f79535-47bb-0310-9956-ffa450edef68

src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java

index b3c525ae92d934b714810db5351eea4da99ada99..cb1ba7da91438817d45ba8c16c058a8224eb3065 100644 (file)
@@ -2075,4 +2075,34 @@ if(1==2) {
        assertEquals("SECOND(A1)", s.getRow(7).getCell(0).getCellFormula());
        assertEquals(54.0+24.0-60, s.getRow(7).getCell(0).getNumericCellValue());
     }
+    
+    /**
+     * HLookup and VLookup with optional arguments 
+     */
+    public void test51024() throws Exception {
+       HSSFWorkbook wb = new HSSFWorkbook();
+       HSSFSheet s = wb.createSheet();
+       HSSFRow r1 = s.createRow(0);
+       HSSFRow r2 = s.createRow(1);
+       
+       r1.createCell(0).setCellValue("v A1");
+       r2.createCell(0).setCellValue("v A2");
+       r1.createCell(1).setCellValue("v B1");
+       
+       HSSFCell c = r1.createCell(4);
+       
+       HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator(wb);
+       
+       c.setCellFormula("VLOOKUP(\"v A1\", A1:B2, 1)");
+       assertEquals("v A1", eval.evaluate(c).getStringValue());
+       
+       c.setCellFormula("VLOOKUP(\"v A1\", A1:B2, 1, 1)");
+       assertEquals("v A1", eval.evaluate(c).getStringValue());
+       
+       c.setCellFormula("HLOOKUP(\"v A1\", A1:B2, 1)");
+       assertEquals("v A1", eval.evaluate(c).getStringValue());
+       
+       c.setCellFormula("HLOOKUP(\"v A1\", A1:B2, 1, 1)");
+       assertEquals("v A1", eval.evaluate(c).getStringValue());
+    }
 }