summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEl-BG-1970 <elouangros@hotmail.com>2022-07-28 21:57:10 +0200
committerEl-BG-1970 <elouangros@hotmail.com>2022-07-28 21:57:10 +0200
commit201bdac932778ccf420df492acb7eecaa209b0dd (patch)
tree3d7c9afb07a90f5b7114f1dccd446a6dbb72f907 /tests
parent0ca49f895163d7fc77fd49a0c8ffaf042661d283 (diff)
downloadtransacc-201bdac932778ccf420df492acb7eecaa209b0dd.tar.gz
Added testing capabilites and some tests
added testing system to transacc.asd added some tests for commodities added some tests for inventory -> need to add more tests
Diffstat (limited to 'tests')
-rw-r--r--tests/test.lisp67
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/test.lisp b/tests/test.lisp
new file mode 100644
index 0000000..f2136d6
--- /dev/null
+++ b/tests/test.lisp
@@ -0,0 +1,67 @@
+(in-package :cl-user)
+(defpackage transacc-tests
+ (:use :cl
+ :fiveam))
+(in-package :transacc-tests)
+
+(def-suite transacc-suite
+ :description "Test transacc")
+
+
+;;; TESTING COMMODITIES
+(def-suite* commodities-suite
+ :description "Test object and methods for commodities"
+ :in transacc-suite)
+
+;; we make sure creating a commodity returns one
+(test commodity-creation
+ (let ((c1 (commodities:new-commodity "apple" 1))
+ (c2 (commodities:new-commodity "pear" 4))
+ (c3 (commodities:new-commodity "petrol" -3))
+ (c4 (commodities:new-commodity "void" 0)))
+ (is (equal (type-of c1) 'commodities::commodity))
+ (is (equal (type-of c2) 'commodities::commodity))
+ (is (eq c3 nil))
+ (is (eq c4 nil))))
+
+;; we make sure a commodity created with given values
+;; in fact contains said values
+(test commodity-values
+ (let ((c (commodities:new-commodity "car" 10000)))
+ (is (equal (commodities:name c) "car"))
+ (is (= (commodities:price c) 10000))))
+
+
+;;; TESTING INVENTORY
+(def-suite* inventory-suite
+ :description "Test object and methods for inventory"
+ :in transacc-suite)
+
+;; test for creation of inventories
+(test inventory-creation
+ (let ((i1 (inventory:new-inventory 100))
+ (i2 (inventory:new-inventory 25))
+ (i3 (inventory:new-inventory -100))
+ (i4 (inventory:new-inventory 0)))
+ (is (eq (type-of i1) 'inventory::inventory))
+ (is (eq (type-of i2) 'inventory::inventory))
+ (is (eq i3 nil))
+ (is (eq i4 nil))))
+
+;; test for init values
+(test inventory-init-values
+ (let ((i (inventory:new-inventory 100)))
+ (is (= (inventory::size i) 100))
+ (is (= (inventory:filled i) 0))
+ (is (eq (inventory::items i) nil))))
+
+;; test add and substract
+(test inventory-add-and-substract
+ (let ((i (inventory:new-inventory 100))
+ (c (commodities:new-commodity "apple" 2)))
+ (inventory:add-item i c 10)
+ (is (= (inventory:filled i) 10))
+ (is (equal (inventory:remove-item i "apple" 4)
+ (cons c 4)))))
+
+;; creating inventory adding