votes = @election.votes
candidates = @election.candidates
unless votes.length>0 and candidates.length>0
- @winners=[nil]
+ @winners=[]
return @winners
end
victors = Hash.new
def cpssd
votes = @election.votes
candidates = *@election.candidates
-
+
def in_schwartz_set?(candidate, candidates, transitive_defeats)
candidates.each do |challenger|
next if candidate == challenger
end
def winner?
- @winners.length > 0
+ @winners.length > 0 and not @winners[0].nil?
end
end
end
unless votes.length > 0
- @winners=[nil]
+ @winners=[]
return
end
def test_condorcet_empty
vote_array = [[]]
assert_nil PureCondorcetVote.new(vote_array).result.winners[0]
+ assert_equal(false, PureCondorcetVote.new(vote_array).result.winner?)
end
def test_condorcet
def test_ssd_empty
vote_array = [[]]
assert_nil CloneproofSSDVote.new(vote_array).result.winners[0]
+ assert_equal(false, CloneproofSSDVote.new(vote_array).result.winner?)
end
def test_ssd
def test_plurality_empty
vote_array = []
assert_nil PluralityVote.new(vote_array).result.winners[0]
+ assert_equal(false, PluralityVote.new(vote_array).result.winner?)
end
def test_plurality
def test_approval_empty
vote_array = []
assert_nil ApprovalVote.new(vote_array).result.winners[0]
+ assert_equal(false, ApprovalVote.new(vote_array).result.winner?)
end
def test_approval
def test_irv_empty
vote_array = Array.new
assert_nil InstantRunoffVote.new(vote_array).result.winners[0]
+ assert_equal(false, InstantRunoffVote.new(vote_array).result.winner?)
end
def test_irv
def test_irv_logic_empty
vote_array = Array.new
assert_nil InstantRunoffLogicVote.new(vote_array).result.winners[0]
+ assert_equal(false, InstantRunoffLogicVote.new(vote_array).result.winner?)
end
def test_irv_logic1
def test_borda_empty
vote_array = Array.new
assert_nil BordaVote.new(vote_array).result.winners[0]
+ assert_equal(false, BordaVote.new(vote_array).result.winner?)
end
def test_borda
def test_range_empty
vote_array = []
assert_nil RangeVote.new(vote_array).result.winners[0]
+ assert_equal(false, RangeVote.new(vote_array).result.winner?)
end
def test_range