From bf5a092fb649dd503b0265f9c2a67f2f45978ffb Mon Sep 17 00:00:00 2001 From: El-BG-1970 Date: Fri, 29 Jul 2022 19:48:44 +0200 Subject: added more tests for inventory --- tests/test.lisp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'tests') 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 -- cgit v1.2.3