89 lines
2.3 KiB
Ruby
89 lines
2.3 KiB
Ruby
require 'minitest/autorun'
|
|
require_relative 'hamming'
|
|
|
|
# Common test data version: 2.0.1 f79dfd7
|
|
class HammingTest < Minitest::Test
|
|
def test_empty_strands
|
|
# skip
|
|
assert_equal 0, Hamming.compute('', '')
|
|
end
|
|
|
|
def test_identical_strands
|
|
assert_equal 0, Hamming.compute('A', 'A')
|
|
end
|
|
|
|
def test_long_identical_strands
|
|
assert_equal 0, Hamming.compute('GGACTGA', 'GGACTGA')
|
|
end
|
|
|
|
def test_complete_distance_in_single_nucleotide_strands
|
|
assert_equal 1, Hamming.compute('A', 'G')
|
|
end
|
|
|
|
def test_complete_distance_in_small_strands
|
|
assert_equal 2, Hamming.compute('AG', 'CT')
|
|
end
|
|
|
|
def test_small_distance_in_small_strands
|
|
assert_equal 1, Hamming.compute('AT', 'CT')
|
|
end
|
|
|
|
def test_small_distance
|
|
assert_equal 1, Hamming.compute('GGACG', 'GGTCG')
|
|
end
|
|
|
|
def test_small_distance_in_long_strands
|
|
assert_equal 2, Hamming.compute('ACCAGGG', 'ACTATGG')
|
|
end
|
|
|
|
def test_non_unique_character_in_first_strand
|
|
assert_equal 1, Hamming.compute('AAG', 'AAA')
|
|
end
|
|
|
|
def test_non_unique_character_in_second_strand
|
|
assert_equal 1, Hamming.compute('AAA', 'AAG')
|
|
end
|
|
|
|
def test_same_nucleotides_in_different_positions
|
|
assert_equal 2, Hamming.compute('TAG', 'GAT')
|
|
end
|
|
|
|
def test_large_distance
|
|
assert_equal 4, Hamming.compute('GATACA', 'GCATAA')
|
|
end
|
|
|
|
def test_large_distance_in_off_by_one_strand
|
|
assert_equal 9, Hamming.compute('GGACGGATTCTG', 'AGGACGGATTCT')
|
|
end
|
|
|
|
def test_disallow_first_strand_longer
|
|
assert_raises(ArgumentError) { Hamming.compute('AATG', 'AAA') }
|
|
end
|
|
|
|
def test_disallow_second_strand_longer
|
|
assert_raises(ArgumentError) { Hamming.compute('ATA', 'AGTG') }
|
|
end
|
|
|
|
# Problems in exercism evolve over time, as we find better ways to ask
|
|
# questions.
|
|
# The version number refers to the version of the problem you solved,
|
|
# not your solution.
|
|
#
|
|
# Define a constant named VERSION inside of the top level BookKeeping
|
|
# module, which may be placed near the end of your file.
|
|
#
|
|
# In your file, it will look like this:
|
|
#
|
|
# module BookKeeping
|
|
# VERSION = 1 # Where the version number matches the one in the test.
|
|
# end
|
|
#
|
|
# If you are curious, read more about constants on RubyDoc:
|
|
# http://ruby-doc.org/docs/ruby-doc-bundle/UsersGuide/rg/constants.html
|
|
|
|
def test_bookkeeping
|
|
skip
|
|
assert_equal 3, BookKeeping::VERSION
|
|
end
|
|
end
|