require 'rubyvote/condorcet'
class TestCondorcetVote < Test::Unit::TestCase
+ def test_condorcet_empty
+ vote_array = [[]]
+ assert_nil PureCondorcetVote.new(vote_array).result.winners[0]
+ end
def test_condorcet
vote_array = Array.new
assert_equal [['6', '7'], ['8']], v.results
end
+ def test_ssd_empty
+ vote_array = [[]]
+ assert_nil CloneproofSSDVote.new(vote_array).result.winners[0]
+ end
+
def test_ssd
vote_array = Array.new
5.times {vote_array << "ACBED".split("")}
class TestElectionVote < Test::Unit::TestCase
+ def test_plurality_empty
+ vote_array = []
+ assert_nil PluralityVote.new(vote_array).result.winners[0]
+ end
+
def test_plurality
vote_array = "ABCABCABCCCBBAAABABABCCCCCCCCCCCCCA".split("")
assert_raise(InvalidVoteError) { PluralityVote.new(vote_array).result.winners[0] }
end
+ def test_approval_empty
+ vote_array = []
+ assert_nil ApprovalVote.new(vote_array).result.winners[0]
+ end
+
def test_approval
vote_array = Array.new
10.times {vote_array << "AB".split("")}
class TestRunoffVote < Test::Unit::TestCase
+ def test_irv_empty
+ vote_array = Array.new
+ assert_nil InstantRunoffVote.new(vote_array).result.winners[0]
+ end
+
def test_irv
vote_array = Array.new
142.times {vote_array << "ABCD".split("")}
assert_equal( "C", InstantRunoffVote.new(vote_array).result.winners[0] )
end
-
+
+ def test_irv_logic_empty
+ vote_array = Array.new
+ assert_nil InstantRunoffLogicVote.new(vote_array).result.winners[0]
+ end
+
def test_irv_logic1
vote_array = Array.new
42.times {vote_array << "ABCD".split("")}
require 'rubyvote/positional'
class TestPositionalVote < Test::Unit::TestCase
-
+
+ def test_borda_empty
+ vote_array = Array.new
+ assert_nil BordaVote.new(vote_array).result.winners[0]
+ end
+
def test_borda
vote_array = Array.new
2.times {vote_array << "BAC".split("")}
class TestRangeVote < Test::Unit::TestCase
+ def test_range_empty
+ vote_array = []
+ assert_nil RangeVote.new(vote_array).result.winners[0]
+ end
+
def test_range
vote_array = []
42.times {vote_array << {'A' => 10, 'B' => 5, 'C' => 2, 'D' => 1}}