]> git.donarmstrong.com Git - biopieces.git/commitdiff
speedup of bits.rb
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Mon, 5 Sep 2011 13:23:30 +0000 (13:23 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Mon, 5 Sep 2011 13:23:30 +0000 (13:23 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1514 74ccb610-7750-0410-82ae-013aeee3265d

code_ruby/test/maasha/test_bits.rb

index 5a589f5c584964c096d9d783f7580ba764ac7550..9e2d3692793703f325c9c264dbde9bb3f34df2a2 100755 (executable)
@@ -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