projects
/
rubyvote
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add testcases for calling results to empty votes.
[rubyvote]
/
test
/
election_test.rb
diff --git
a/test/election_test.rb
b/test/election_test.rb
index 7675e58a01c8eb1fe4a254d57f6204062dc27619..2afab27475f6c38b1a7d1c01ed8ad2bb02d2f1ed 100644
(file)
--- a/
test/election_test.rb
+++ b/
test/election_test.rb
@@
-5,6
+5,11
@@
require 'rubyvote/election'
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("")
@@
-21,6
+26,11
@@
class TestElectionVote < Test::Unit::TestCase
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("")}
Benjamin Mako Hill
||
Want to submit a patch?