Add testcase for non-string plurality vote candidates
[rubyvote] / test / election_test.rb
index b182e2d7619d63b46c277990b4f02694de151a67..5b5664e7eaabf55c9dc9e0ed63da5c7e211be7aa 100644 (file)
@@ -1,15 +1,19 @@
-#!/usr/bin/ruby
+#!/usr/bin/ruby -Ilib
 
 require 'test/unit'
-require 'election_test_helper'
+require 'rubyvote/election'
 
 class TestElectionVote < Test::Unit::TestCase
-  include ElectionTestHelper
 
   def test_plurality
     vote_array = "ABCABCABCCCBBAAABABABCCCCCCCCCCCCCA".split("")
 
-    test_winner( "C", PluralityVote.new(vote_array).result )
+    assert_equal( "C", PluralityVote.new(vote_array).result.winners[0] )
+  end
+
+  def test_plurality_nonstring
+    vote_array = [1,2,3,1,1,1,2,3]
+    assert_equal( 1, PluralityVote.new(vote_array).result.winners[0] )
   end
 
 
@@ -20,7 +24,7 @@ class TestElectionVote < Test::Unit::TestCase
     11.times {vote_array << "AC".split("")}
     5.times {vote_array << "A".split("")}
 
-    test_winner( "A", ApprovalVote.new(vote_array).result )
+    assert_equal( "A", ApprovalVote.new(vote_array).result.winners[0] )
   end
 end
 

Benjamin Mako Hill || Want to submit a patch?