This commit is contained in:
2024-06-26 23:52:34 -04:00
parent 10cfc2215b
commit eb76c60826
10 changed files with 280 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
defmodule HammingTest do
use ExUnit.Case
test "empty strands" do
assert Hamming.hamming_distance(~c"", ~c"") == {:ok, 0}
end
test "single letter identical strands" do
assert Hamming.hamming_distance(~c"A", ~c"A") == {:ok, 0}
end
test "single letter different strands" do
assert Hamming.hamming_distance(~c"G", ~c"T") == {:ok, 1}
end
test "long identical strands" do
assert Hamming.hamming_distance(~c"GGACTGAAATCTG", ~c"GGACTGAAATCTG") == {:ok, 0}
end
test "long different strands" do
assert Hamming.hamming_distance(~c"GGACGGATTCTG", ~c"AGGACGGATTCT") == {:ok, 9}
end
test "disallow first strand longer" do
assert {:error, "strands must be of equal length"} =
Hamming.hamming_distance(~c"AATG", ~c"AAA")
end
test "disallow second strand longer" do
assert {:error, "strands must be of equal length"} =
Hamming.hamming_distance(~c"ATA", ~c"AGTG")
end
test "disallow empty first strand" do
assert {:error, "strands must be of equal length"} = Hamming.hamming_distance(~c"", ~c"G")
end
test "disallow empty second strand" do
assert {:error, "strands must be of equal length"} = Hamming.hamming_distance(~c"G", ~c"")
end
end

View File

@@ -0,0 +1,2 @@
ExUnit.start()
ExUnit.configure(exclude: :pending, trace: true)