39 lines
1 KiB
Common Lisp
39 lines
1 KiB
Common Lisp
(defpackage flappy-ball-test
|
|
(:use :cl :fiveam :flappy-ball)
|
|
(:export #:flappy-ball-test))
|
|
|
|
(in-package :flappy-ball-test)
|
|
|
|
(def-suite all-tests)
|
|
|
|
(in-suite all-tests)
|
|
|
|
(test test-ball
|
|
(let ((ball (make-ball 100 300 5.0 10)))
|
|
(is (= (ball-x ball) 100))
|
|
(is (= (ball-y ball) 300))
|
|
(is (= (ball-size ball) 10))
|
|
(is (= (ball-velocity ball) 5.0))))
|
|
|
|
(test test-ball-move
|
|
(let ((ball (make-ball 100 300 5.0 10)))
|
|
(is (= (ball-x (ball-move ball 1 600)) 100))
|
|
(is (= (ball-y (ball-move ball 1 600)) 305))
|
|
(is (= (ball-size (ball-move ball 1 600)) 10))
|
|
(is (= (ball-velocity (ball-move ball 1 600)) 6.0))))
|
|
|
|
(test test-pipe
|
|
(let ((pipe (make-pipe 10 200 100 20)))
|
|
(is (= (pipe-x pipe) 10))
|
|
(is (= (pipe-height pipe) 200))
|
|
(is (= (pipe-gap pipe) 100))
|
|
(is (= (pipe-width pipe) 20))))
|
|
|
|
(test test-high-score
|
|
(let ((high-score (make-high-score 10 (get-universal-time))))
|
|
(is (= (high-score-value high-score) 10))
|
|
(is (< (- (get-universal-time) (high-score-time high-score)) 1))))
|
|
|
|
|
|
(run-all-tests)
|
|
|