summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEl-BG-1970 <elouangros@hotmail.com>2022-07-29 19:48:44 +0200
committerEl-BG-1970 <elouangros@hotmail.com>2022-07-29 19:48:44 +0200
commitbf5a092fb649dd503b0265f9c2a67f2f45978ffb (patch)
treefacee72e19fcdeef874bebd6fd2408f5b9c17abd
parent1077a12a0156f2c24083067f760a1afda91f99e9 (diff)
downloadtransacc-bf5a092fb649dd503b0265f9c2a67f2f45978ffb.tar.gz
added more tests for inventory
-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