From cfe7a87bfabb3c2a3aafdcf89a964ef50c5bd811 Mon Sep 17 00:00:00 2001 From: kimory Date: Sun, 16 Oct 2022 23:17:29 +0200 Subject: [PATCH] Scenario. --- src/scenario.cl | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/scenario.cl diff --git a/src/scenario.cl b/src/scenario.cl new file mode 100644 index 0000000..ebd0c7c --- /dev/null +++ b/src/scenario.cl @@ -0,0 +1,33 @@ +(load "./dodb.cl") + +; +; TEST SCENARIO +; + +(defstruct vehicle name color) + +;(defparameter cars (db/new "vehicle" "./storage/cars/")) +; to launch the tests in RAM +(defparameter cars (db/new "vehicle" "/tmp/storage/cars/")) + +(db/add cars (make-vehicle :name "Corvet" :color "Red")) +(db/add cars (make-vehicle :name "Ferrari" :color "Red")) +(db/add cars (make-vehicle :name "Deudeuch" :color "Beige")) +(db/add cars (make-vehicle :name "BMW" :color "Blue")) +(db/add cars (make-vehicle :name "Suzuki Wagon" :color "Blue")) + +(db/new-index cars "name") +(db/new-partition cars "color") + + +(format t "~&~S~&" cars) + +(format t "db/get-by-index ~S~&" (db/get-by-index cars "name" "Corvet")) +(format t "db/get-by-partition red cars:~&") + +(loop for car in (db/get-by-partition cars "color" "Red") + do (format t "- ~S~&" car)) + +(let ((suzuki (db/get-by-index cars "name" "Suzuki Wagon"))) + (setf (vehicle-color (gethash suzuki (db-data cars))) "White") + (db/update cars suzuki))