-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathiris-data-test.rkt
69 lines (52 loc) · 1.63 KB
/
iris-data-test.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#lang racket/base
(require rackunit
rackunit/text-ui
racket/pretty
"iris-data.rkt")
(define iris-data-tests
(test-suite
"Tests for iris-data.rkt"
(test-pred
"is-blank? is true for an empty list"
is-blank? '())
(test-pred
"is-blank? is true for a list with an empty string"
is-blank? '(""))
(test-pred
"string-or-number->number converts number to number"
number?
(string-or-number->number 1.1))
(test-pred
"string-or-number->number converts string to number"
number?
(string-or-number->number "1.1"))
(test-equal?
"get-string-list provides a 150 element list"
(length (get-string-list "data/iris.data"))
150)
(test-true
"get-string-list provides a list of lists"
(andmap list? (get-string-list "data/iris.data")))
(test-pred
"iris struct for integer values"
iris?
(iris 5.5 3.3 2.1 1.1 "Iris Setosa"))
(test-case
"iris struct for string values"
(let
([iris-string (iris "5.5" "3.3" "2.1" "1.1" "Iris setosa")])
(check-pred iris? iris-string)
(check-pred number? (iris-sepal-length iris-string))
(check-pred number? (iris-sepal-width iris-string))
(check-pred number? (iris-petal-length iris-string))
(check-pred number? (iris-petal-width iris-string))))
(test-equal?
"get-data returns a list of size 150s"
(length (get-data "data/iris.data"))
150)
(test-true
"get-data returns a list of structs"
(andmap iris? (get-data "data/iris.data")))
)
)
(run-tests iris-data-tests)