summaryrefslogtreecommitdiff
path: root/calc_test.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2021-11-22 00:39:39 +0800
committerxuri <xuri.me@gmail.com>2021-11-22 00:39:39 +0800
commit9561976074eb3f8260845735bf6028a5d5f3bd71 (patch)
tree7bb99c35d0154a2506013bebc0cebbf3f4971119 /calc_test.go
parenta6c8803e91018898f8e6f960340709e970a99560 (diff)
ref #65: new formula function VDB
Diffstat (limited to 'calc_test.go')
-rw-r--r--calc_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/calc_test.go b/calc_test.go
index 77c6e30..c9896c7 100644
--- a/calc_test.go
+++ b/calc_test.go
@@ -1537,6 +1537,17 @@ func TestCalcCellValue(t *testing.T) {
"=TBILLPRICE(\"02/01/2017\",\"06/30/2017\",2.75%)": "98.86180555555556",
// TBILLYIELD
"=TBILLYIELD(\"02/01/2017\",\"06/30/2017\",99)": "0.024405125076266",
+ // VDB
+ "=VDB(10000,1000,5,0,1)": "4000",
+ "=VDB(10000,1000,5,1,3)": "3840",
+ "=VDB(10000,1000,5,3,5)": "1160",
+ "=VDB(10000,1000,5,3,5,0.2,FALSE)": "3600",
+ "=VDB(10000,1000,5,3,5,0.2,TRUE)": "693.633024",
+ "=VDB(24000,3000,10,0,0.875,2)": "4200",
+ "=VDB(24000,3000,10,0.1,1)": "4233.599999999999",
+ "=VDB(24000,3000,10,0.1,1,1)": "2138.3999999999996",
+ "=VDB(24000,3000,100,50,100,1)": "10377.294418465235",
+ "=VDB(24000,3000,100,50,100,2)": "5740.072322090805",
// YIELDDISC
"=YIELDDISC(\"01/01/2017\",\"06/30/2017\",97,100)": "0.0622012325059031",
"=YIELDDISC(\"01/01/2017\",\"06/30/2017\",97,100,0)": "0.0622012325059031",
@@ -3075,6 +3086,22 @@ func TestCalcCellValue(t *testing.T) {
"=TBILLYIELD(\"01/01/2017\",\"06/30/2017\",0)": "#NUM!",
"=TBILLYIELD(\"01/01/2017\",\"06/30/2018\",2.5%)": "#NUM!",
"=TBILLYIELD(\"06/30/2017\",\"01/01/2017\",2.5%)": "#NUM!",
+ // VDB
+ "=VDB()": "VDB requires 5 or 7 arguments",
+ "=VDB(-1,1000,5,0,1)": "VDB requires cost >= 0",
+ "=VDB(10000,-1,5,0,1)": "VDB requires salvage >= 0",
+ "=VDB(10000,1000,0,0,1)": "VDB requires life > 0",
+ "=VDB(10000,1000,5,-1,1)": "VDB requires start_period > 0",
+ "=VDB(10000,1000,5,2,1)": "VDB requires start_period <= end_period",
+ "=VDB(10000,1000,5,0,6)": "VDB requires end_period <= life",
+ "=VDB(10000,1000,5,0,1,-0.2)": "VDB requires factor >= 0",
+ "=VDB(\"\",1000,5,0,1)": "strconv.ParseFloat: parsing \"\": invalid syntax",
+ "=VDB(10000,\"\",5,0,1)": "strconv.ParseFloat: parsing \"\": invalid syntax",
+ "=VDB(10000,1000,\"\",0,1)": "strconv.ParseFloat: parsing \"\": invalid syntax",
+ "=VDB(10000,1000,5,\"\",1)": "strconv.ParseFloat: parsing \"\": invalid syntax",
+ "=VDB(10000,1000,5,0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
+ "=VDB(10000,1000,5,0,1,\"\")": "#NUM!",
+ "=VDB(10000,1000,5,0,1,0.2,\"\")": "#NUM!",
// YIELDDISC
"=YIELDDISC()": "YIELDDISC requires 4 or 5 arguments",
"=YIELDDISC(\"\",\"06/30/2017\",97,100,0)": "#VALUE!",