]> source.dussan.org Git - poi.git/commitdiff
Add failing (but disabled) test from bug #44691
authorNick Burch <nick@apache.org>
Thu, 27 Mar 2008 18:24:39 +0000 (18:24 +0000)
committerNick Burch <nick@apache.org>
Thu, 27 Mar 2008 18:24:39 +0000 (18:24 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@641934 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestBug44691.java [new file with mode: 0644]

diff --git a/src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestBug44691.java b/src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestBug44691.java
new file mode 100644 (file)
index 0000000..59b04b4
--- /dev/null
@@ -0,0 +1,70 @@
+/* ====================================================================
+   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.hssf.usermodel;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+import junit.framework.TestCase;
+
+import org.apache.poi.hssf.util.CellReference;
+
+/**
+ * The PMT formula seems to be giving some grief
+ */
+public final class TestBug44691 extends TestCase {
+       String dirname;
+
+       protected void setUp() throws Exception {
+               super.setUp();
+               dirname = System.getProperty("HSSF.testdata.path");
+       }
+
+       public void DISABLEDtestBug44691() throws Exception {
+               HSSFWorkbook outWorkbook = new HSSFWorkbook();
+               HSSFSheet outPMTSheet = outWorkbook.createSheet("PMT Sheet");
+               HSSFRow row = outPMTSheet.createRow((short) 0);
+               HSSFCell cell = row.createCell((short) 0);
+               cell.setCellType(HSSFCell.CELL_TYPE_FORMULA);
+               cell.setCellFormula("PMT(0.09/12,48,-10000)");
+
+               ByteArrayOutputStream baos = new ByteArrayOutputStream();
+               outWorkbook.write(baos);
+               ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+
+               HSSFWorkbook inWorkbook = new HSSFWorkbook(bais);
+
+               HSSFSheet inPMTSheet = inWorkbook.getSheet("PMT Sheet");
+               HSSFFormulaEvaluator evaluator = new
+               HSSFFormulaEvaluator(inPMTSheet, inWorkbook);
+               CellReference cellReference = new CellReference("A1");
+               HSSFRow inRow = inPMTSheet.getRow(cellReference.getRow());
+               HSSFCell inCell = inRow.getCell(cellReference.getCol());
+               
+               assertEquals("PMT(0.09/12,48,-10000)", 
+                               inCell.getCellFormula());
+               assertEquals(HSSFCell.CELL_TYPE_FORMULA, inCell.getCellType());
+               
+               evaluator.setCurrentRow(inRow);
+               HSSFFormulaEvaluator.CellValue inCellValue =
+                       evaluator.evaluate(inCell);
+               
+               assertEquals(0, inCellValue.getErrorValue());
+               assertEquals(HSSFCell.CELL_TYPE_NUMERIC, inCellValue.getCellType());
+               assertEquals(248.85, inCellValue.getNumberValue(), 0.0001);
+       }
+}