2022-07-30 03:26:43 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Dependencies
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(require 'ert)
|
|
|
|
(require 'bag)
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Tests
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(setq fixture (bag-from-list '(1 1 1 2 2 3)))
|
|
|
|
|
|
|
|
(ert-deftest bag-add ()
|
2022-07-30 16:09:40 +02:00
|
|
|
(should (not (bag-contains? 4 fixture)))
|
|
|
|
(should (bag-contains? 4 (bag-add 4 fixture))))
|
2022-07-30 03:26:43 +02:00
|
|
|
|
|
|
|
(ert-deftest bag-remove ()
|
2022-07-30 16:09:40 +02:00
|
|
|
(should (bag-contains? 1 fixture))
|
|
|
|
(should (not (bag-contains? 3 (bag-remove 3 fixture)))))
|
2022-07-30 03:26:43 +02:00
|
|
|
|
|
|
|
(ert-deftest bag-count ()
|
2022-07-30 16:09:40 +02:00
|
|
|
(should (= 3 (bag-count 1 fixture)))
|
|
|
|
(should (= 2 (bag-count 2 fixture)))
|
|
|
|
(should (= 1 (bag-count 3 fixture))))
|
2022-07-30 03:26:43 +02:00
|
|
|
|
|
|
|
(ert-deftest bag-total ()
|
2022-07-30 16:09:40 +02:00
|
|
|
(should (= 6 (bag-total fixture))))
|
2022-07-30 03:26:43 +02:00
|
|
|
|
|
|
|
(ert-deftest bag-contains? ()
|
2022-07-30 16:09:40 +02:00
|
|
|
(should (bag-contains? 1 fixture))
|
|
|
|
(should (not (bag-contains? 4 fixture))))
|