summaryrefslogtreecommitdiffstats
path: root/tests/test.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test.lisp')
-rw-r--r--tests/test.lisp20
1 files changed, 17 insertions, 3 deletions
diff --git a/tests/test.lisp b/tests/test.lisp
index 9884990..a040852 100644
--- a/tests/test.lisp
+++ b/tests/test.lisp
@@ -58,7 +58,8 @@
;; test add and substract
(test inventory-add-and-substract
(let ((i (inventory:new-inventory 100))
- (c (commodities:new-commodity "apple" 2)))
+ (c (commodities:new-commodity "apple" 1))
+ (c2 (commodities:new-commodity "apple" 99)))
;; add 10
(is (= (inventory:add-item i c 10) 10))
(is (= (inventory:filled i) 10))
@@ -73,7 +74,20 @@
;; adding one too many
(is (not (inventory:add-item i c 5)))
(is (= (inventory::filled i) 96))
- (is (equal (inventory::find-item i "apple")
- (cons c 96)))))
+ (is (and
+ (commodities:commodity-eq
+ c
+ (car (inventory::find-item i "apple")))
+ (= 96 (cdr (inventory::find-item i "apple")))))
+ ;; test for adding differently priced same item
+ (is (= 1
+ (commodities:price
+ (car (inventory::find-item i "apple")))))
+ (inventory:remove-item i "apple" 46)
+ (is (= 100
+ (inventory:add-item i c2 50)))
+ (is (= 50
+ (commodities:price
+ (car (inventory::find-item i "apple")))))))
;; creating inventory adding