summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test.lisp18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test.lisp b/tests/test.lisp
index 6e6fb9b..405b6aa 100644
--- a/tests/test.lisp
+++ b/tests/test.lisp
@@ -55,3 +55,21 @@
(game:sell-item g "pear" 10)
(is (= (player:get-cash (game::player g))
2050))))
+
+;; testing get profit
+(test get-profit
+ (let* ((p (player:init-player "Joze"))
+ (c (list (commodities:new-commodity "apple" 5)
+ (commodities:new-commodity "pear" 7)))
+ (c2 (list (commodities:new-commodity "apple" 6)
+ (commodities:new-commodity "pear" 2)))
+ (z (zone:new-zone "Bronx" c))
+ (z2 (zone:new-zone "Manhattan" c2))
+ (g (game:new-game p z2 (list z z2))))
+ (is (= 0 (game:get-profit g "pear")))
+ (game:buy-item g "pear" 10)
+ (is (= 0 (game:get-profit g "pear")))
+ (is (= 5 (game:get-profit-in-zone g "pear" z)))
+ (game:change-zone g "Bronx")
+ (is (= 5 (game:get-profit g "pear")))
+ (is (= 0 (game:get-profit-in-zone g "pear" z2)))))