X-Git-Url: https://projects.mako.cc/source/rubyvote/blobdiff_plain/11d22a5307695910493266b16718e1ffa201676d..refs/heads/master:/test/irv_test.rb?ds=inline diff --git a/test/irv_test.rb b/test/irv_test.rb index d3a57a7..2974296 100644 --- a/test/irv_test.rb +++ b/test/irv_test.rb @@ -56,7 +56,68 @@ class TestRunoffVote < Test::Unit::TestCase assert_equal( "C", InstantRunoffVote.new(vote_array).result.winners[0] ) end - + + def test_irv4 + # this was causing selectricity to crash + + raw_vote_array = ["GFECADBIH", "ABCDEFGHI", "IGHBADFCE", + "FABCDEGHI", "ABCDEFGHI", "ABCDEFGHI", + "ABCDEFGHI", "ABCDEFGHI", "ABCDEFGHI", + "EHBICDAGF", "ECGDFBIAH", "BDHIGFECA", + "ECDBFIHAG", "FEDBCAHIG", "CDABHIEFG", + "FCBDIHAEG", "AIHFBECGD", "BACHDEFIG", + "CDEFIBHAG", "BDICAFEGH", "ABCDEFGHI", + "CBIHDFAEG", "ABCDEFGHI", "CDFIBAGEH", + "ECDBIFHGA", "BDACEHFIG", "CFDIHABEG", + "ADCFGBIHE", "CDHIBEAGF", "ABCFDHIEG", + "ABCDEFGHI", "DCFHIBAGE", "CDFEABHIG", + "DFHIBEAGC", "EDCBFIGAH", "BAECDFHGI", + "BAHCEDFGI", "HBCDIAFEG", "ABCDEFGHI", + "ABCDEFGHI", "EDCBIGAHF", "EIBDCGAFH", + "HIACGDFBE", "DEACBIFGH", "CIDEFABGH", + "ABHDIECGF", "ECIDBFGHA", "CEDFBHIGA", + "ABHCEIDFG", "CFDBEIHGA", "ICEDBGFAH", + "EDCIFBAGH", "ECFDBAHGI", "EBCADFIGH", + "EFBHAGICD", "CDBIEFAHG", "ABCDEFGHI", + "FCDBEIHGA", "AIEBDCFHG", "CDFEBIGAH", + "CABDEFGHI", "DCEIBFGHA", "EADCIBHFG", + "DBCAHIGEF", "EDFBCIAHG", "EDCBIHAGF", + "CFIAEDGHB", "CDEIHABGF", "CEBHIDAFG", + "BCFEDIHAG", "CDIHBFGEA", "CFEDIGBAH", + "IHFEADCBG", "EBDCIGAHF", "BCEDFIAGH", + "ABHEGICDF", "CABFHDIEG", "HEABDCFGI", + "CDEBFAIHG", "CDBFIHAGE", "ABGFEDHCI", + "IBHDCAEFG", "EBDICHAFG", "ABCDEFGHI", + "EFBHAICGD", "CBDFHAIEG", "CDBAEIHGF", + "ABCDEFGHI", "BECDHIFGA", "DAGCIHFBE", + "BIECDGAHF", "ABCDEFGHI", "ACDEBHIFG", + "AEBCIDHFG", "ABCDEFGHI", "ABCDEFGHI", + "ABCDEFGHI", "ABCDEFGHI", "ABCDEFGHI", + "ABCDEFGHI", "ECFDIHBAG", "BIDCHEAGF", + "BCEDFIGHA", "CBDAFEGHI", "ABCDEFGHI", + "FACEGDHBI", "ABCDEFGHI", "FDIBCGHAE", + "EBIHADCFG", "EDBIHAGCF", "AHDICBFEG", + "DCBIHAGFE", "CABFIDEHG", "IFCBHADEG", + "EDCFHIBAG", "DCABEFGHI", "FCBDIGHEA", + "ABCDEFGHI", "HBACIDEFG", "ABCDEFGHI", + "ABCDEFGHI", "EADCBIHGF", "BDCIHAGFE", + "ABCDEFGHI", "ABCDEFGHI", "ABCDEFGHI", + "ABCDEFGHI", "ABCDEFGHI", "ICDGAHBEF", + "EGBCFIHDA", "DFGACHIEB", "BCAGDFHIE", + "DBGHCEAFI", "IGHEBCADF", "FEDIHBCAG", + "HAICBGEFD", "EBFDAICGH", "ECGAHFIBD", + "GEFICAHDB", "ACEHGIBDF", "EGIFBHCAD", + "GHFEDCIBA", "DGAEHFICB", "HGDICBAFE", + "HEACGDBFI", "IAGDFHCEB", "EGIACHBDF", + "CBFGDIEAH", "CGAIBDEFH", "AHEDIGCBF", + "BAEFHIDCG", "BIDGAFCHE", "CHBAEDFIG", + "IBGCFADEH", "GHACDEFIB", "CFDBEAHIG", + "GDEFAICHB"] + vote_array = raw_vote_array.collect {|v| v.split("")} + print InstantRunoffVote.new(vote_array).result.winners, "\n" + assert_equal(true, InstantRunoffVote.new(vote_array).result.winner?) + end + def test_irv_logic_empty vote_array = Array.new assert_nil InstantRunoffLogicVote.new(vote_array).result.winners[0]