summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
ebb1c70)
TODO: IRV Logic has same bug
git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@34
1440c7f4-e209-0410-9a04-
881b5eb134a8
require 'rubyvote/condorcet'
class TestCondorcetVote < Test::Unit::TestCase
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
def test_condorcet
vote_array = Array.new
assert_equal [['6', '7'], ['8']], v.results
end
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("")}
def test_ssd
vote_array = Array.new
5.times {vote_array << "ACBED".split("")}
class TestElectionVote < Test::Unit::TestCase
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("")
def test_plurality
vote_array = "ABCABCABCCCBBAAABABABCCCCCCCCCCCCCA".split("")
assert_raise(InvalidVoteError) { PluralityVote.new(vote_array).result.winners[0] }
end
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("")}
def test_approval
vote_array = Array.new
10.times {vote_array << "AB".split("")}
class TestRunoffVote < Test::Unit::TestCase
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("")}
def test_irv
vote_array = Array.new
142.times {vote_array << "ABCD".split("")}
assert_equal( "C", InstantRunoffVote.new(vote_array).result.winners[0] )
end
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("")}
def test_irv_logic1
vote_array = Array.new
42.times {vote_array << "ABCD".split("")}
require 'rubyvote/positional'
class TestPositionalVote < Test::Unit::TestCase
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("")}
def test_borda
vote_array = Array.new
2.times {vote_array << "BAC".split("")}
class TestRangeVote < Test::Unit::TestCase
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}}
def test_range
vote_array = []
42.times {vote_array << {'A' => 10, 'B' => 5, 'C' => 2, 'D' => 1}}