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