-
Notifications
You must be signed in to change notification settings - Fork 1
/
Example.elm
68 lines (65 loc) · 2.16 KB
/
Example.elm
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
68
module Example exposing (..)
import Test exposing (..)
import Expect
import Fuzz exposing (list, int, string)
suite : Test
suite =
describe "varous tests"
[ describe "String tests"
[ test "reverses a string" <|
\_ ->
"Hello World"
|> String.reverse
|> Expect.equal "dlroW olleH"
, test "empty string" <|
\_ ->
""
|> String.isEmpty
|> Expect.true "Expected empty string"
, test "toInt success" <|
\_ ->
"24"
|> String.toInt
|> Expect.equal (Ok 24)
, test "toInt failure" <|
\_ ->
"24X"
|> String.toInt
|> Expect.equal (Err "could not convert string '24X' to an Int")
]
, describe "List tests"
[ test "length" <|
\_ ->
[ 1, 2, 3, 4 ]
|> List.length
|> Expect.equal 4
, test "isEmpty" <|
\_ ->
[]
|> List.isEmpty
|> Expect.true "Exepcted empty string"
, test "head" <|
\_ ->
[ 1, 2, 3 ]
|> List.head
|> Expect.equal (Just 1)
, test "tail" <|
\_ ->
[ 1, 2, 3 ]
|> List.tail
|> Expect.equal (Just [ 2, 3 ])
, test "reverse" <|
\_ ->
[ 1, 2, 3 ]
|> List.reverse
|> Expect.equal [ 3, 2, 1 ]
]
, describe "fuzzy tests"
[ fuzz string "double reverse string" <|
\randomString ->
randomString
|> String.reverse
|> String.reverse
|> Expect.equal randomString
]
]