1
exercism fetch crystal hamming

spec/hamming_spec.cr

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require "spec"
require "../src/*"

describe "Hamming" do
  describe "#compute" do
    it "computes no difference for identical single nucleotide strands" do
      Hamming.compute("A", "A").should eq 0
    end

    pending "computes a distance for single nucleotide strands" do
      Hamming.compute("A", "G").should eq 1
    end

    pending "computes a distance for small strands" do
      Hamming.compute("AG", "CT").should eq 2
    end

    pending "computes a distance for medium strands" do
      Hamming.compute("GGACG", "GGTCG").should eq 1
    end

    pending "computes a distance for large strands" do
      Hamming.compute("GGACGGATTCTG", "AGGACGGATTCT").should eq 9
    end

    pending "raises an exception when strands aren't of equal length" do
      expect_raises(ArgumentError) { Hamming.compute("GCC", "A") }
    end
  end
end