elm/exercises/hamming/HammingTests.elm

61 lines
1.7 KiB
Elm
Raw Normal View History

2016-03-12 02:09:38 +00:00
module Main (..) where
import Task
import Console
import ElmTest exposing (..)
import Hamming exposing (distance)
tests : Test
tests =
suite
"Hamming"
[ test
"identical strands"
(assertEqual (Just 0) (distance "A" "A"))
2016-03-12 02:09:38 +00:00
, test
"long identical strands"
(assertEqual (Just 0) (distance "GGACTGA" "GGACTGA"))
2016-03-12 02:09:38 +00:00
, test
"complete distance in single nucleotide strands"
(assertEqual (Just 1) (distance "A" "G"))
2016-03-12 02:09:38 +00:00
, test
"complete distance in small strands"
(assertEqual (Just 2) (distance "AG" "CT"))
2016-03-12 02:09:38 +00:00
, test
"small distance in small strands"
(assertEqual (Just 1) (distance "AT" "CT"))
2016-03-12 02:09:38 +00:00
, test
"small distance"
(assertEqual (Just 1) (distance "GGACG" "GGTCG"))
2016-03-12 02:09:38 +00:00
, test
"small distance in long strands"
(assertEqual (Just 2) (distance "ACCAGGG" "ACTATGG"))
2016-03-12 02:09:38 +00:00
, test
"non-unique character in first strand"
(assertEqual (Just 1) (distance "AGA" "AGG"))
2016-03-12 02:09:38 +00:00
, test
"non-unique character in second strand"
(assertEqual (Just 1) (distance "AGG" "AGA"))
2016-03-12 02:09:38 +00:00
, test
"large distance"
(assertEqual (Just 4) (distance "GATACA" "GCATAA"))
2016-03-12 02:09:38 +00:00
, test
"large distance in off-by-one strand"
(assertEqual (Just 9) (distance "GGACGGATTCTG" "AGGACGGATTCT"))
2016-03-12 02:09:38 +00:00
, test
"empty strands"
(assertEqual (Just 0) (distance "" ""))
2016-03-12 02:09:38 +00:00
, test
"disallow first strand longer"
(assertEqual Nothing (distance "AATG" "AAA"))
2016-03-12 02:09:38 +00:00
, test
"disallow second strand longer"
(assertEqual Nothing (distance "ATA" "AGTG"))
2016-03-12 02:09:38 +00:00
]
port runner : Signal (Task.Task x ())
port runner =
Console.run (consoleRunner tests)