1
exercism fetch elm run-length-encoding

tests/Tests.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 Tests exposing (..)

import Expect
import RunLengthEncoding exposing (decode, encode, version)
import Test exposing (..)


tests : Test
tests =
    describe "RunLengthEncoding"
        [ test "the solution is for the correct version of the test" <|
            \() -> Expect.equal 2 version
        , describe "run-length encode a string"
            [ test "empty string" <|
                \() -> Expect.equal "" (encode "")
            , skip <|
                test "single characters only are encoded without count" <|
                    \() -> Expect.equal "XYZ" (encode "XYZ")
            , skip <|
                test "string with no single characters" <|
                    \() -> Expect.equal "2A3B4C" (encode "AABBBCCCC")
            , skip <|
                test "single characters mixed with repeated characters" <|
                    \() ->
                        Expect.equal "12WB12W3B24WB"
                            (encode "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB")
            , skip <|
                test "multiple whitespace mixed in string" <|
                    \() -> Expect.equal "2 hs2q q2w2 " (encode "  hsqq qww  ")
            , skip <|
                test "lowercase characters" <|
                    \() -> Expect.equal "2a3b4c" (encode "aabbbcccc")
            ]
        , describe "run-length decode a string"
            [ skip <|
                test "empty string" <|
                    \() -> Expect.equal "" (decode "")
            , skip <|
                test "single characters only" <|
                    \() -> Expect.equal "XYZ" (decode "XYZ")
            , skip <|
                test "string with no single characters" <|
                    \() -> Expect.equal "AABBBCCCC" (decode "2A3B4C")
            , skip <|
                test "single characters with repeated characters" <|
                    \() ->
                        Expect.equal "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB"
                            (decode "12WB12W3B24WB")
            , skip <|
                test "multiple whitespace mixed in string" <|
                    \() -> Expect.equal "  hsqq qww  " (decode "2 hs2q q2w2 ")
            , skip <|
                test "lower case string" <|
                    \() -> Expect.equal "" (decode "")
            , skip <|
                test "with a x10 value" <|
                    \() ->
                        Expect.equal "WWWWWWWWWW"
                            (decode "10W")
            ]
        , describe "encode and then decode"
            [ skip <|
                test "encode followed by decode gives original string" <|
                    \() ->
                        Expect.equal "zzz ZZ  zZ"
                            (decode (encode "zzz ZZ  zZ"))
            ]
        ]

tests/elm-package.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
    "version": "3.0.0",
    "summary": "Exercism problems in Elm.",
    "repository": "https://github.com/exercism/elm.git",
    "license": "BSD3",
    "source-directories": [
        ".",
        ".."
    ],
    "exposed-modules": [],
    "dependencies": {
        "elm-lang/core": "5.0.0 <= v < 6.0.0",
        "elm-community/elm-test": "4.0.0 <= v < 5.0.0"
    },
    "elm-version": "0.18.0 <= v < 0.19.0"
}