elm/exercises/hamming/HammingTests.elm

59 lines
1.6 KiB
Elm
Raw Normal View History

module Main exposing (..)
2016-03-12 02:09:38 +00:00
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
]
main : Program Never
main =
runSuite tests