7 class TestBits < Test::Unit::TestCase
8 def test_Bits_hamming_dist_with_uneven_lengths_raises
9 assert_raises(StringError) { String.hamming_dist("ATCG", "ATC") }
12 def test_Bits_hamming_dist_with_even_lengths_dont_raise
13 assert_nothing_raised { String.hamming_dist("ATCG", "ATCG") }
16 def test_Bits_hamming_dist_returns_correctly
17 assert_equal(0, String.hamming_dist("ATCG", "ATCG"))
18 assert_equal(1, String.hamming_dist("ATCX", "ATCG"))
19 assert_equal(2, String.hamming_dist("ATXX", "ATCG"))
20 assert_equal(2, String.hamming_dist("ATcg", "ATCG"))
21 assert_equal(3, String.hamming_dist("AXXX", "ATCG"))
22 assert_equal(4, String.hamming_dist("XXXX", "ATCG"))
25 def test_Bits_AND_with_equal_length_returns_correctly
26 assert_equal("ABCD", "abcd" & "____")
29 def test_Bits_AND_with_unequal_length_returns_correctly
30 assert_equal("JAPH\n", "japh\nJunk" & '_____')
31 assert_equal("JAPH\n", '_____' & "japh\nJunk")
34 def test_Bits_OR_with_equal_length_returns_correctly
35 assert_equal("abcd", "ab " | " cd")
38 def test_Bits_OR_with_unequal_length_returns_correctly
39 assert_equal("japh\n", "JA" | " ph\n")
40 assert_equal("japh\n", " ph\n" | "JA")
43 def test_Bits_XOR_with_equal_length_returns_correctly
44 assert_equal("ABCD", "ab " ^ " cd")
47 def test_Bits_XOR_with_unequal_length_returns_correctly
48 assert_equal("JAPH", "j p \n" ^ " a h")
49 assert_equal("JAPH", " a h" ^ "j p \n")