2017-10-07 16:36:25 +00:00
|
|
|
module Tests exposing (..)
|
|
|
|
|
|
|
|
import Test exposing (..)
|
|
|
|
import Expect
|
|
|
|
import CollatzConjecture exposing (collatz)
|
|
|
|
|
|
|
|
|
|
|
|
tests : Test
|
|
|
|
tests =
|
|
|
|
describe "CollatzConjecture tests"
|
|
|
|
[ test "zero steps for one" <|
|
|
|
|
\() ->
|
|
|
|
Expect.equal (Ok 0) (collatz 1)
|
|
|
|
|
|
|
|
-- Once you get the first test passing, remove the
|
|
|
|
-- `skip <|` (just leave the comma) on the next
|
|
|
|
-- lines to continue!
|
|
|
|
, skip <|
|
|
|
|
test "divide if even" <|
|
2017-10-08 15:57:29 +00:00
|
|
|
\() ->
|
|
|
|
Expect.equal (Ok 4) (collatz 16)
|
2017-10-07 16:36:25 +00:00
|
|
|
, skip <|
|
|
|
|
test "even and odd step" <|
|
2017-10-08 15:57:29 +00:00
|
|
|
\() ->
|
|
|
|
Expect.equal (Ok 9) (collatz 12)
|
2017-10-07 16:36:25 +00:00
|
|
|
, skip <|
|
|
|
|
test "Large number of even and odd step" <|
|
2017-10-08 15:57:29 +00:00
|
|
|
\() ->
|
|
|
|
Expect.equal (Ok 152) (collatz 1000000)
|
2017-10-07 16:36:25 +00:00
|
|
|
, skip <|
|
|
|
|
test "zero is an error" <|
|
2017-10-08 15:57:29 +00:00
|
|
|
\() ->
|
|
|
|
Expect.equal (Err "Only positive numbers are allowed") (collatz 0)
|
2017-10-07 16:36:25 +00:00
|
|
|
, skip <|
|
|
|
|
test "negative values is an error" <|
|
2017-10-08 15:57:29 +00:00
|
|
|
\() ->
|
|
|
|
Expect.equal (Err "Only positive numbers are allowed") (collatz -15)
|
2017-10-07 16:36:25 +00:00
|
|
|
]
|