diff options
author | Josh Micich <josh@apache.org> | 2008-09-17 22:08:15 +0000 |
---|---|---|
committer | Josh Micich <josh@apache.org> | 2008-09-17 22:08:15 +0000 |
commit | 9a127374b3b59a0818cff5337e004916943c4f9c (patch) | |
tree | ba6b9e14a925af380d9ae5c76612d38f2941da84 | |
parent | a8e8ae739ab5ef59c641987e4540abca425e7c8a (diff) | |
download | poi-9a127374b3b59a0818cff5337e004916943c4f9c.tar.gz poi-9a127374b3b59a0818cff5337e004916943c4f9c.zip |
merged 696109,696111 from trunk - (Added junit for bug 45732)
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@696492 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/testcases/org/apache/poi/hssf/data/FormulaEvalTestData.xls | bin | 157184 -> 157184 bytes | |||
-rwxr-xr-x | src/testcases/org/apache/poi/hssf/record/formula/functions/AllIndividualFunctionEvaluationTests.java | 1 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/hssf/record/formula/functions/TestNper.java | 67 |
3 files changed, 68 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/hssf/data/FormulaEvalTestData.xls b/src/testcases/org/apache/poi/hssf/data/FormulaEvalTestData.xls Binary files differindex f806c792f6..344a072cdf 100644 --- a/src/testcases/org/apache/poi/hssf/data/FormulaEvalTestData.xls +++ b/src/testcases/org/apache/poi/hssf/data/FormulaEvalTestData.xls diff --git a/src/testcases/org/apache/poi/hssf/record/formula/functions/AllIndividualFunctionEvaluationTests.java b/src/testcases/org/apache/poi/hssf/record/formula/functions/AllIndividualFunctionEvaluationTests.java index 4ae90d067b..c57c40b62a 100755 --- a/src/testcases/org/apache/poi/hssf/record/formula/functions/AllIndividualFunctionEvaluationTests.java +++ b/src/testcases/org/apache/poi/hssf/record/formula/functions/AllIndividualFunctionEvaluationTests.java @@ -41,6 +41,7 @@ public final class AllIndividualFunctionEvaluationTests { result.addTestSuite(TestMid.class); result.addTestSuite(TestMathX.class); result.addTestSuite(TestMatch.class); + result.addTestSuite(TestNper.class); result.addTestSuite(TestPmt.class); result.addTestSuite(TestOffset.class); result.addTestSuite(TestRowCol.class); diff --git a/src/testcases/org/apache/poi/hssf/record/formula/functions/TestNper.java b/src/testcases/org/apache/poi/hssf/record/formula/functions/TestNper.java new file mode 100644 index 0000000000..a2bb0f6adb --- /dev/null +++ b/src/testcases/org/apache/poi/hssf/record/formula/functions/TestNper.java @@ -0,0 +1,67 @@ +/* ==================================================================== + 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.record.formula.functions; + +import org.apache.poi.hssf.record.formula.eval.Eval; +import org.apache.poi.hssf.record.formula.eval.NumberEval; +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFErrorConstants; +import org.apache.poi.hssf.usermodel.HSSFFont; +import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; + +import junit.framework.AssertionFailedError; +import junit.framework.TestCase; + +/** + * + * @author Josh Micich + */ +public final class TestNper extends TestCase { + public void testSimpleEvaluate() { + + Eval[] args = { + new NumberEval(0.05), + new NumberEval(250), + new NumberEval(-1000), + }; + Eval result = FinanceFunction.NPER.evaluate(args, 0, (short)0); + + assertEquals(NumberEval.class, result.getClass()); + assertEquals(4.57353557, ((NumberEval)result).getNumberValue(), 0.00000001); + } + + public void testEvaluate_bug_45732() { + HSSFWorkbook wb = new HSSFWorkbook(); + HSSFSheet sheet = wb.createSheet("Sheet1"); + HSSFCell cell = sheet.createRow(0).createCell(0); + + cell.setCellFormula("NPER(12,4500,100000,100000)"); + cell.setCellValue(15.0); + assertEquals("NPER(12,4500,100000.0,100000.0)", cell.getCellFormula()); + assertEquals(HSSFCell.CELL_TYPE_NUMERIC, cell.getCachedFormulaResultType()); + assertEquals(15.0, cell.getNumericCellValue(), 0.0); + + HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb); + fe.evaluateFormulaCell(cell); + assertEquals(HSSFCell.CELL_TYPE_ERROR, cell.getCachedFormulaResultType()); + assertEquals(HSSFErrorConstants.ERROR_NUM, cell.getErrorCellValue()); + } + +} |