X-Git-Url: https://projects.mako.cc/source/rubyvote/blobdiff_plain/1da0a60f448820070d47333a7316364e009f203e..9953cb5cdef82f0e44f07dd089fde77ede170712:/test/election_test.rb?ds=inline diff --git a/test/election_test.rb b/test/election_test.rb index e8a9c45..2afab27 100644 --- a/test/election_test.rb +++ b/test/election_test.rb @@ -5,13 +5,32 @@ require 'rubyvote/election' 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_equal( "C", PluralityVote.new(vote_array).result.winners[0] ) end + def test_plurality_nonstring + vote_array = [1,2,3,1,1,1,2,3] + assert_equal( 1, PluralityVote.new(vote_array).result.winners[0] ) + end + def test_invalid_voteobj + vote_array = [1,2,nil,1] + 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("")}