Added tie-breaking rules and multicandidate elimination of weak candidates
[rubyvote] / test / election_test.rb
1 #!/usr/bin/ruby
2
3 require 'test/unit'
4 require 'election_test_helper'
5
6 class TestElectionVote < Test::Unit::TestCase
7   include ElectionTestHelper
8
9   def test_plurality
10     vote_array = "ABCABCABCCCBBAAABABABCCCCCCCCCCCCCA".split("")
11
12     test_winner( "C", PluralityVote.new(vote_array).result )
13   end
14
15
16   def test_approval
17     vote_array = Array.new
18     10.times {vote_array << "AB".split("")}
19     10.times {vote_array << "CB".split("")}
20     11.times {vote_array << "AC".split("")}
21     5.times {vote_array << "A".split("")}
22
23     test_winner( "A", ApprovalVote.new(vote_array).result )
24   end
25 end
26

Benjamin Mako Hill || Want to submit a patch?