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
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]
+ assert_equal(false, InstantRunoffLogicVote.new(vote_array).result.winner?)
end
def test_irv_logic1