mirror of
https://github.com/correl/elm.git
synced 2024-11-16 11:09:29 +00:00
59 lines
1.5 KiB
Elm
59 lines
1.5 KiB
Elm
module Main (..) where
|
|
|
|
import Task
|
|
import Console
|
|
import ElmTest exposing (..)
|
|
import RunLengthEncoding exposing (version, decode, encode)
|
|
import RunLengthEncodingPropertyChecks exposing (propertyTests)
|
|
|
|
|
|
tests : Test
|
|
tests =
|
|
suite
|
|
"RunLengthEncoding"
|
|
[ test
|
|
"the solution is for the correct version of the test"
|
|
(assertEqual 2 version)
|
|
, test
|
|
"encode simple"
|
|
(assertEqual "2A3B4C" (encode "AABBBCCCC"))
|
|
, test
|
|
"decode simple"
|
|
(assertEqual "AABBBCCCC" (decode "2A3B4C"))
|
|
, test
|
|
"encode with single values"
|
|
(assertEqual
|
|
"12WB12W3B24WB"
|
|
(encode "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB")
|
|
)
|
|
, test
|
|
"decode with single values"
|
|
(assertEqual
|
|
"WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB"
|
|
(decode "12WB12W3B24WB")
|
|
)
|
|
, test
|
|
"(decode (encode (...)) combination"
|
|
(assertEqual
|
|
"zzz ZZ zZ"
|
|
(decode (encode "zzz ZZ zZ"))
|
|
)
|
|
, test
|
|
"decode with a x10 value"
|
|
(assertEqual
|
|
"WWWWWWWWWW"
|
|
(decode "10W")
|
|
)
|
|
, test
|
|
"encode unicode"
|
|
(assertEqual "⏰3⚽2⭐⏰" (encode "⏰⚽⚽⚽⭐⭐⏰"))
|
|
, test
|
|
"decode unicode"
|
|
(assertEqual "⏰⚽⚽⚽⭐⭐⏰" (decode "⏰3⚽2⭐⏰"))
|
|
, propertyTests
|
|
]
|
|
|
|
|
|
port runner : Signal (Task.Task x ())
|
|
port runner =
|
|
Console.run (consoleRunner tests)
|