From: martinahansen Date: Mon, 5 Sep 2011 13:23:30 +0000 (+0000) Subject: speedup of bits.rb X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=d455fad1c1fb5d3f66736604a043932259f21830;p=biopieces.git speedup of bits.rb git-svn-id: http://biopieces.googlecode.com/svn/trunk@1514 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/code_ruby/test/maasha/test_bits.rb b/code_ruby/test/maasha/test_bits.rb index 5a589f5..9e2d369 100755 --- a/code_ruby/test/maasha/test_bits.rb +++ b/code_ruby/test/maasha/test_bits.rb @@ -31,47 +31,28 @@ require 'test/unit' require 'pp' class TestBits < Test::Unit::TestCase - def test_Bits_hamming_dist_with_uneven_lengths_raises - assert_raises(StringError) { String.hamming_dist("ATCG", "ATC") } + def test_Bits_hamming_distance_with_uneven_lengths_raises + assert_raise(StringError) { "ATCG".hamming_distance("A") } end - def test_Bits_hamming_dist_with_even_lengths_dont_raise - assert_nothing_raised { String.hamming_dist("ATCG", "ATCG") } + def test_Bits_hamming_distance_returns_correctly + assert_equal(0, "ATCG".hamming_distance("ATCG")) + assert_equal(1, "ATCX".hamming_distance("ATCG")) + assert_equal(2, "ATXX".hamming_distance("ATCG")) + assert_equal(2, "ATcg".hamming_distance("ATCG")) + assert_equal(3, "AXXX".hamming_distance("ATCG")) + assert_equal(4, "XXXX".hamming_distance("ATCG")) end - def test_Bits_hamming_dist_returns_correctly - assert_equal(0, String.hamming_dist("ATCG", "ATCG")) - assert_equal(1, String.hamming_dist("ATCX", "ATCG")) - assert_equal(2, String.hamming_dist("ATXX", "ATCG")) - assert_equal(2, String.hamming_dist("ATcg", "ATCG")) - assert_equal(3, String.hamming_dist("AXXX", "ATCG")) - assert_equal(4, String.hamming_dist("XXXX", "ATCG")) - end - - def test_Bits_AND_with_equal_length_returns_correctly + def test_Bits_AND_returns_correctly assert_equal("ABCD", "abcd" & "____") end - def test_Bits_AND_with_unequal_length_returns_correctly - assert_equal("JAPH\n", "japh\nJunk" & '_____') - assert_equal("JAPH\n", '_____' & "japh\nJunk") - end - - def test_Bits_OR_with_equal_length_returns_correctly + def test_Bits_OR_returns_correctly assert_equal("abcd", "ab " | " cd") end - def test_Bits_OR_with_unequal_length_returns_correctly - assert_equal("japh\n", "JA" | " ph\n") - assert_equal("japh\n", " ph\n" | "JA") - end - - def test_Bits_XOR_with_equal_length_returns_correctly + def test_Bits_XOR_returns_correctly assert_equal("ABCD", "ab " ^ " cd") end - - def test_Bits_XOR_with_unequal_length_returns_correctly - assert_equal("JAPH", "j p \n" ^ " a h") - assert_equal("JAPH", " a h" ^ "j p \n") - end end