transcendental-lisp/lisp/finance/compound-interest-test.lisp

39 lines
1.2 KiB
Common Lisp
Raw Normal View History

2017-03-06 11:00:18 -05:00
(load "../unit/unit-test.lisp")
(load "compound-interest.lisp")
(unit
(list
(defun many-years-with-no-interest-rate ()
(assert= 100000 (compound-interest 100000 0 10)))
(defun no-years-with-positive-interest-rate ()
(assert= 100000 (compound-interest 100000 10 0)))
(defun one-year-with-positive-interest-rate ()
(assert= 105000 (compound-interest 100000 5 1)))
(defun two-years-with-positive-interest-rate ()
(assert= 110250 (compound-interest 100000 5 2)))
(defun three-years-with-positive-interest-rate ()
(assert= 115763 (compound-interest 100000 5 3)))
(defun four-years-with-positive-interest-rate ()
(assert= 121551 (compound-interest 100000 5 4)))
(defun one-year-with-negative-interest-rate ()
(assert= 95000 (compound-interest 100000 -5 1)))
(defun two-years-with-negative-interest-rate ()
(assert= 90250 (compound-interest 100000 -5 2)))
(defun three-years-with-negative-interest-rate ()
(assert= 85737 (compound-interest 100000 -5 3)))
(defun four-years-with-negative-interest-rate ()
(assert= 81450 (compound-interest 100000 -5 4)))
(defun negative-number-of-years ()
(assert= 100000 (compound-interest 100000 5 -4)))))