]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_ruby/test/maasha/test_bits.rb
rewrite of FASTQ internals
[biopieces.git] / code_ruby / test / maasha / test_bits.rb
index 5a589f5c584964c096d9d783f7580ba764ac7550..37f0de1f6d4461e6769f97fca6c00b64e038a6d4 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/env ruby
-$:.unshift File.join(File.dirname(__FILE__),'..','lib')
+$:.unshift File.join(File.dirname(__FILE__), '..', '..')
 
 # Copyright (C) 2007-2010 Martin A. Hansen.
 
@@ -28,50 +28,31 @@ $:.unshift File.join(File.dirname(__FILE__),'..','lib')
 
 require 'maasha/bits'
 require 'test/unit'
-require 'pp'
+require 'test/helper'
 
 class TestBits < Test::Unit::TestCase 
-  def test_Bits_hamming_dist_with_uneven_lengths_raises
-    assert_raises(StringError) { String.hamming_dist("ATCG", "ATC") }
+  test "#hamming_distance with uneven lengths raises" do
+    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") }
+  test "#hamming_distance returns correctly" do
+    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
+  test "#& returns correctly" do
     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
+  test "#| returns correctly" do
     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
+  test "#^ returns correctly" do
     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