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

53 lines
1.3 KiB
Common Lisp
Raw Normal View History

(load "unit-test.lisp")
(load "compound-interest.lisp")
(unit
(list
(defun many-years-with-no-interest-rate ()
2017-02-15 09:29:57 -05:00
(assert= 100000 (compound-interest 100000 0 10))
)
(defun no-years-with-positive-interest-rate ()
2017-02-15 09:29:57 -05:00
(assert= 100000 (compound-interest 100000 10 0))
)
(defun one-year-with-positive-interest-rate ()
2017-02-15 09:29:57 -05:00
(assert= 105000 (compound-interest 100000 5 1))
)
(defun two-years-with-positive-interest-rate ()
2017-02-15 09:29:57 -05:00
(assert= 110250 (compound-interest 100000 5 2))
)
(defun three-years-with-positive-interest-rate ()
2017-02-15 09:29:57 -05:00
(assert= 115763 (compound-interest 100000 5 3))
)
(defun four-years-with-positive-interest-rate ()
2017-02-15 09:29:57 -05:00
(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))
)
2017-03-04 16:33:05 -05:00
(defun negative-number-of-years ()
(assert= 100000 (compound-interest 100000 5 -4))
)
)
)