kekkonen/test-database.scm

49 lines
1.7 KiB
Scheme
Raw Normal View History

2021-11-29 10:04:23 -05:00
(module test-database ()
(import scheme)
(import (chicken base))
(import (chicken syntax))
(import test)
(import database)
(test-group "database"
2021-12-09 11:17:11 -05:00
(test '((test . ((test-key . 3)))) (begin (database-null)
2021-11-29 10:04:23 -05:00
(database-set 'test 'test-key 3)
*database*))
2021-12-09 11:17:11 -05:00
(test 3 (begin (database-null)
2021-11-29 10:04:23 -05:00
(database-set 'test 'test-key 3)
(database-get 'test 'test-key #f)))
2021-12-09 11:17:11 -05:00
(test '((test . ((test-key . 3)))) (begin (database-null)
2021-11-29 10:04:23 -05:00
(database-set 'test 'test-key 3)
(database-save "test.sav")
2021-12-09 11:17:11 -05:00
(database-null)
2021-11-29 10:04:23 -05:00
(database-load "test.sav")))
2021-12-09 11:17:11 -05:00
(test '() (begin (database-null)
2021-11-29 10:04:23 -05:00
(database-set 'test 'test-key 3)
(database-remove 'test)
*database*))
2021-12-09 11:17:11 -05:00
(test '(test) (begin (database-null)
2021-11-29 10:04:23 -05:00
(database-set 'test 'test-key 3)
(get-all-objects)))
(test-group "object-exists?"
2021-12-09 11:17:11 -05:00
(test #t (begin (database-null)
2021-11-29 10:04:23 -05:00
(database-set 'test 'test-key 3)
(object-exists? 'test)))
2021-12-09 11:17:11 -05:00
(test #f (begin (database-null)
2021-11-29 10:04:23 -05:00
(object-exists? 'test))))
(test-group "has-property?"
2021-12-09 11:17:11 -05:00
(test #t (begin (database-null)
2021-11-29 10:04:23 -05:00
(database-set 'test 'test-key 3)
(has-property? 'test 'test-key)))
2021-12-09 11:17:11 -05:00
(test #f (begin (database-null)
2021-11-29 10:04:23 -05:00
(database-set 'test 'test-key 3)
(has-property? 'test 'nosuch-key))))
(test-group "toggle-flag"
2021-12-09 11:17:11 -05:00
(test #t (begin (database-null)
2021-11-29 10:04:23 -05:00
(database-set 'test 'test-key #f)
(toggle-flag 'test 'test-key)
(database-get 'test 'test-key #f)))
2021-12-09 11:17:11 -05:00
(test #f (begin (database-null)
2021-11-29 10:04:23 -05:00
(database-set 'test 'test-key #t)
(toggle-flag 'test 'test-key)
(database-get 'test 'test-key #t))))))