4 require 'rubyvote/election'
7 class TestRunoffVote < Test::Unit::TestCase
10 vote_array = Array.new
11 142.times {vote_array << "ABCD".split("")}
12 26.times {vote_array << "BCDA".split("")}
13 15.times {vote_array << "CDBA".split("")}
14 17.times {vote_array << "DCBA".split("")}
16 assert_equal( "A", InstantRunoffVote.new(vote_array).result.winners[0] )
20 vote_array = Array.new
21 42.times {vote_array << "ABCD".split("")}
22 26.times {vote_array << "BCDA".split("")}
23 15.times {vote_array << "CDBA".split("")}
24 17.times {vote_array << "DCBA".split("")}
26 assert_equal( "D", InstantRunoffVote.new(vote_array).result.winners[0] )
30 vote_array = Array.new
31 42.times {vote_array << "ABCD".split("")}
32 26.times {vote_array << "ACBD".split("")}
33 15.times {vote_array << "BACD".split("")}
34 32.times {vote_array << "BCAD".split("")}
35 14.times {vote_array << "CABD".split("")}
36 49.times {vote_array << "CBAD".split("")}
37 17.times {vote_array << "ABDC".split("")}
38 23.times {vote_array << "BADC".split("")}
39 37.times {vote_array << "BCDA".split("")}
40 11.times {vote_array << "CADB".split("")}
41 16.times {vote_array << "CBDA".split("")}
42 54.times {vote_array << "ADBC".split("")}
43 36.times {vote_array << "BDCA".split("")}
44 42.times {vote_array << "CDAB".split("")}
45 13.times {vote_array << "CDBA".split("")}
46 51.times {vote_array << "DABC".split("")}
47 33.times {vote_array << "DBCA".split("")}
48 39.times {vote_array << "DCAB".split("")}
49 12.times {vote_array << "DCBA".split("")}
51 assert_equal( "C", InstantRunoffVote.new(vote_array).result.winners[0] )
55 vote_array = Array.new
56 42.times {vote_array << "ABCD".split("")}
57 26.times {vote_array << "BCDA".split("")}
58 15.times {vote_array << "CDBA".split("")}
59 15.times {vote_array << "DCBA".split("")}
61 assert_equal( "B", InstantRunoffLogicVote.new(vote_array).result.winners[0] )
63 ###TODO: test all the other variants