updated test cases to consider the case that rate=0

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353727 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Amol S. Deshmukh 2005-06-22 20:49:14 +00:00
parent b943810bfb
commit eb7f1ce7e5

View File

@ -16,6 +16,11 @@ public class TestFinanceLib extends AbstractNumericTestCase {
int n; int n;
boolean t = false; boolean t = false;
r = 0; n = 3; y = 2; p = 7; t = true;
f = FinanceLib.fv(r, n, y, p, t);
x = -13;
assertEquals("fv ", x, f);
r = 1; n = 10; y = 100; p = 10000; t = false; r = 1; n = 10; y = 100; p = 10000; t = false;
f = FinanceLib.fv(r, n, y, p, t); f = FinanceLib.fv(r, n, y, p, t);
x = -10342300; x = -10342300;
@ -76,6 +81,11 @@ public class TestFinanceLib extends AbstractNumericTestCase {
int n; int n;
boolean t = false; boolean t = false;
r = 0; n = 3; p = 2; f = 7; t = true;
y = FinanceLib.pmt(r, n, p, f, t);
x = -3;
assertEquals("pmt ", x, y);
// cross check with pv // cross check with pv
r = 1; n = 10; p = -109.66796875; f = 10000; t = false; r = 1; n = 10; p = -109.66796875; f = 10000; t = false;
y = FinanceLib.pmt(r, n, p, f, t); y = FinanceLib.pmt(r, n, p, f, t);
@ -104,6 +114,11 @@ public class TestFinanceLib extends AbstractNumericTestCase {
int n; int n;
boolean t = false; boolean t = false;
r = 0; n = 3; y = 2; f = 7; t = true;
f = FinanceLib.pv(r, n, y, f, t);
x = -13;
assertEquals("pv ", x, f);
r = 1; n = 10; y = 100; f = 10000; t = false; r = 1; n = 10; y = 100; f = 10000; t = false;
p = FinanceLib.pv(r, n, y, f, t); p = FinanceLib.pv(r, n, y, f, t);
x = -109.66796875; x = -109.66796875;
@ -138,10 +153,14 @@ public class TestFinanceLib extends AbstractNumericTestCase {
} }
public void testNper() { public void testNper() {
double f, r, y, p, x; double f, r, y, p, x, n;
int n;
boolean t = false; boolean t = false;
r = 0; y = 7; p = 2; f = 3; t = false;
n = FinanceLib.nper(r, y, p, f, t);
x = -0.71428571429; // can you believe it? excel returns nper as a fraction!??
assertEquals("nper ", x, n);
// cross check with pv // cross check with pv
r = 1; y = 100; p = -109.66796875; f = 10000; t = false; r = 1; y = 100; p = -109.66796875; f = 10000; t = false;
n = FinanceLib.nper(r, y, p, f, t); n = FinanceLib.nper(r, y, p, f, t);