]> projects.mako.cc - rubyvote/blobdiff - test/election_test.rb
Add similar hackish "fix" for IRVL deadlocking on empty vote
[rubyvote] / test / election_test.rb
index 5b5664e7eaabf55c9dc9e0ed63da5c7e211be7aa..2afab27475f6c38b1a7d1c01ed8ad2bb02d2f1ed 100644 (file)
@@ -5,6 +5,11 @@ require 'rubyvote/election'
 
 class TestElectionVote < Test::Unit::TestCase
 
+  def test_plurality_empty
+    vote_array = []
+    assert_nil PluralityVote.new(vote_array).result.winners[0]
+  end
+  
   def test_plurality
     vote_array = "ABCABCABCCCBBAAABABABCCCCCCCCCCCCCA".split("")
 
@@ -16,7 +21,16 @@ class TestElectionVote < Test::Unit::TestCase
     assert_equal( 1, PluralityVote.new(vote_array).result.winners[0] )
   end
 
-
+  def test_invalid_voteobj
+    vote_array = [1,2,nil,1]
+    assert_raise(InvalidVoteError) { PluralityVote.new(vote_array).result.winners[0] }
+  end
+  
+  def test_approval_empty
+    vote_array = []
+    assert_nil ApprovalVote.new(vote_array).result.winners[0]
+  end
+  
   def test_approval
     vote_array = Array.new
     10.times {vote_array << "AB".split("")}

Benjamin Mako Hill || Want to submit a patch?