on 16640f5 help sign in
elk/tests/libraries/Test/String.elm
37 lines 1.8 kB history raw
1module Test.String (tests) where
3import List
4import String (..)
6import ElmTest.Assertion (..)
7import ElmTest.Test (..)
9tests : Test
10tests =
11 let simpleTests = suite "Simple Stuff"
12 [ test "is empty" <| assert (isEmpty "")
13 , test "is not empty" <| assert (not (isEmpty ("the world")))
14 , test "length" <| assertEqual 11 (length "innumerable")
15 , test "endsWith" (assert <| endsWith "ship" "spaceship")
16 , test "reverse" <| assertEqual "desserts" (reverse "stressed")
17 , test "repeat" <| assertEqual "hahaha" (repeat 3 "ha")
18 ]
20 combiningTests = suite "Combining Strings"
21 [ test "uncons non-empty" <| assertEqual (Just ('a',"bc")) (uncons "abc")
22 , test "uncons empty" <| assertEqual Nothing (uncons "")
23 , test "append 1" <| assertEqual "butterfly" (append "butter" "fly")
24 , test "append 2" <| assertEqual "butter" (append "butter" "")
25 , test "append 3" <| assertEqual "butter" (append "" "butter")
26 , test "concat" <| assertEqual "nevertheless" (concat ["never","the","less"])
27 , test "split commas" <| assertEqual ["cat","dog","cow"] (split "," "cat,dog,cow")
28 , test "split slashes"<| assertEqual ["home","steve","Desktop", ""] (split "/" "home/steve/Desktop/")
29 , test "join spaces" <| assertEqual "cat dog cow" (join " " ["cat","dog","cow"])
30 , test "join slashes" <| assertEqual "home/steve/Desktop" (join "/" ["home","steve","Desktop"])
31 , test "slice 1" <| assertEqual "c" (slice 2 3 "abcd")
32 , test "slice 2" <| assertEqual "abc" (slice 0 3 "abcd")
33 , test "slice 3" <| assertEqual "abc" (slice 0 -1 "abcd")
34 , test "slice 4" <| assertEqual "cd" (slice -2 4 "abcd")
35 ]
36 in
37 suite "String" [ simpleTests, combiningTests ]