forked from ericclack/racket-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
thrust-tests.rkt
47 lines (40 loc) · 1.49 KB
/
thrust-tests.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#lang racket
(require rackunit)
(require/expose "thrust1.rkt" (pos pos-x pos-y move-pos add-direction-speeds
inside-circle? inside-rect? between?))
(define (check-equal-pos? pos1 pos2)
(check-= (pos-x pos1) (pos-x pos2) 0.01)
(check-= (pos-y pos1) (pos-y pos2) 0.01))
(test-case
"move-pos tests"
(check-equal-pos? (move-pos (pos 0 0) 90 5)
(pos 0.0 5.0))
(check-equal-pos? (move-pos (pos 0 0) 180 5)
(pos -5.0 0.0))
(check-equal-pos? (move-pos (pos 0 0) 270 5)
(pos -0.0 -5.0))
(check-equal-pos? (move-pos (pos 0 0) 0 5)
(pos 5 0))
)
(define (check-equal-list? list1 list2)
(check-= (first list1) (first list2) 0.01)
(check-= (second list1) (second list2) 0.01))
(test-case
"tests for add-direction-speeds"
(check-equal-list? (add-direction-speeds 0 0 90 5)
(list 90.0 5.0))
(check-equal-list? (add-direction-speeds 0 0 180 5)
(list 180.0 5.0))
(check-equal-list? (add-direction-speeds 0 0 270 5)
(list -90.0 5.0))
(check-equal-list? (add-direction-speeds 0 0 0 5)
(list 0 5))
(check-equal-list? (add-direction-speeds 0 0 45 5)
(list 45.0 5.0))
(check-equal-list? (add-direction-speeds 0 0 135 5)
(list 135.0 5.0))
(check-equal-list? (add-direction-speeds 0 0 225 5)
(list -135 5.0))
(check-equal-list? (add-direction-speeds 0 0 295 5)
(list -65 5.0))
)