4 require 'rubyvote/election'
6 class TestElectionVote < Test::Unit::TestCase
9 vote_array = "ABCABCABCCCBBAAABABABCCCCCCCCCCCCCA".split("")
11 assert_equal( "C", PluralityVote.new(vote_array).result.winners[0] )
14 def test_plurality_nonstring
15 vote_array = [1,2,3,1,1,1,2,3]
16 assert_equal( 1, PluralityVote.new(vote_array).result.winners[0] )
19 def test_invalid_voteobj
20 vote_array = [1,2,nil,1]
21 assert_raise(InvalidVoteError) { PluralityVote.new(vote_array).result.winners[0] }
25 vote_array = Array.new
26 10.times {vote_array << "AB".split("")}
27 10.times {vote_array << "CB".split("")}
28 11.times {vote_array << "AC".split("")}
29 5.times {vote_array << "A".split("")}
31 assert_equal( "A", ApprovalVote.new(vote_array).result.winners[0] )