2021-08-05 21:37:06 +10:00
|
|
|
/* OpenTally: Open-source election vote counting
|
2022-11-20 18:59:02 +11:00
|
|
|
* Copyright © 2021–2022 Lee Yingtong Li (RunasSudo)
|
2021-08-05 21:37:06 +10:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2021-09-10 00:02:52 +10:00
|
|
|
use crate::utils;
|
2021-08-05 21:37:06 +10:00
|
|
|
|
|
|
|
use opentally::numbers::Rational;
|
|
|
|
use opentally::stv;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn minneapolis_boe09_rational() {
|
|
|
|
let stv_opts = stv::STVOptionsBuilder::default()
|
|
|
|
.round_surplus_fractions(Some(4))
|
2022-11-20 18:59:02 +11:00
|
|
|
.round_values(Some(4))
|
2021-08-05 21:37:06 +10:00
|
|
|
.round_quota(Some(0))
|
2022-11-20 18:59:02 +11:00
|
|
|
.round_subtransfers(stv::RoundSubtransfersMode::PerBallot)
|
2021-08-05 21:37:06 +10:00
|
|
|
.quota_criterion(stv::QuotaCriterion::GreaterOrEqual)
|
2021-09-14 02:23:51 +10:00
|
|
|
//.early_bulk_elect(true)
|
2021-08-05 21:37:06 +10:00
|
|
|
.bulk_exclude(true)
|
2021-08-07 18:51:48 +10:00
|
|
|
.defer_surpluses(true)
|
|
|
|
.immediate_elect(false)
|
2021-08-05 21:37:06 +10:00
|
|
|
.build().unwrap();
|
|
|
|
|
2022-11-20 18:59:02 +11:00
|
|
|
assert_eq!(stv_opts.describe::<Rational>(), "--round-surplus-fractions 4 --round-values 4 --round-quota 0 --round-subtransfers per_ballot --quota-criterion geq --bulk-exclude --defer-surpluses --no-immediate-elect");
|
2021-09-14 02:23:51 +10:00
|
|
|
|
2021-08-05 21:37:06 +10:00
|
|
|
utils::read_validate_election::<Rational>("tests/data/Mppls-2009-BOE-full.csv", "tests/data/Mppls-2009-BOE-full.blt", stv_opts, Some(4), &[]);
|
|
|
|
}
|
2021-08-07 18:51:48 +10:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn minneapolis_pal13_rational() {
|
|
|
|
let stv_opts = stv::STVOptionsBuilder::default()
|
|
|
|
.round_surplus_fractions(Some(4))
|
2022-11-20 18:59:02 +11:00
|
|
|
.round_values(Some(4))
|
2021-08-07 18:51:48 +10:00
|
|
|
.round_quota(Some(0))
|
2022-11-20 18:59:02 +11:00
|
|
|
.round_subtransfers(stv::RoundSubtransfersMode::PerBallot)
|
2021-08-07 18:51:48 +10:00
|
|
|
.quota_criterion(stv::QuotaCriterion::GreaterOrEqual)
|
2021-09-14 02:23:51 +10:00
|
|
|
//.early_bulk_elect(true)
|
2021-08-07 18:51:48 +10:00
|
|
|
.bulk_exclude(true)
|
|
|
|
.defer_surpluses(true)
|
|
|
|
.immediate_elect(false)
|
|
|
|
.build().unwrap();
|
|
|
|
|
2022-11-20 18:59:02 +11:00
|
|
|
assert_eq!(stv_opts.describe::<Rational>(), "--round-surplus-fractions 4 --round-values 4 --round-quota 0 --round-subtransfers per_ballot --quota-criterion geq --bulk-exclude --defer-surpluses --no-immediate-elect");
|
2021-09-14 02:23:51 +10:00
|
|
|
|
2021-08-07 18:51:48 +10:00
|
|
|
utils::read_validate_election::<Rational>("tests/data/2013-Park-At-Large-CVR.csv", "tests/data/2013-Park-At-Large-CVR.blt", stv_opts, Some(4), &[]);
|
|
|
|
}
|
2022-11-20 18:59:21 +11:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn minneapolis_boe21_rational() {
|
|
|
|
let stv_opts = stv::STVOptionsBuilder::default()
|
|
|
|
.round_surplus_fractions(Some(4))
|
|
|
|
.round_values(Some(4))
|
|
|
|
.round_quota(Some(0))
|
|
|
|
.round_subtransfers(stv::RoundSubtransfersMode::PerBallot)
|
|
|
|
.quota_criterion(stv::QuotaCriterion::GreaterOrEqual)
|
|
|
|
//.early_bulk_elect(true)
|
|
|
|
.bulk_exclude(true)
|
|
|
|
.defer_surpluses(true)
|
|
|
|
.immediate_elect(false)
|
|
|
|
.build().unwrap();
|
|
|
|
|
|
|
|
assert_eq!(stv_opts.describe::<Rational>(), "--round-surplus-fractions 4 --round-values 4 --round-quota 0 --round-subtransfers per_ballot --quota-criterion geq --bulk-exclude --defer-surpluses --no-immediate-elect");
|
|
|
|
|
|
|
|
utils::read_validate_election::<Rational>("tests/data/2021-BET-Cast-Vote-Record.csv", "tests/data/2021-BET-Cast-Vote-Record.blt", stv_opts, Some(2), &["exhausted", "lbf"]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn minneapolis_pal21_rational() {
|
|
|
|
let stv_opts = stv::STVOptionsBuilder::default()
|
|
|
|
.round_surplus_fractions(Some(4))
|
|
|
|
.round_values(Some(4))
|
|
|
|
.round_quota(Some(0))
|
|
|
|
.round_subtransfers(stv::RoundSubtransfersMode::PerBallot)
|
|
|
|
.quota_criterion(stv::QuotaCriterion::GreaterOrEqual)
|
|
|
|
//.early_bulk_elect(true)
|
|
|
|
.bulk_exclude(true)
|
|
|
|
.defer_surpluses(true)
|
|
|
|
.immediate_elect(false)
|
|
|
|
.build().unwrap();
|
|
|
|
|
|
|
|
assert_eq!(stv_opts.describe::<Rational>(), "--round-surplus-fractions 4 --round-values 4 --round-quota 0 --round-subtransfers per_ballot --quota-criterion geq --bulk-exclude --defer-surpluses --no-immediate-elect");
|
|
|
|
|
|
|
|
utils::read_validate_election::<Rational>("tests/data/2021-Park-AL-Cast-Vote-Record.csv", "tests/data/2021-Park-AL-Cast-Vote-Record.blt", stv_opts, Some(3), &["exhausted", "lbf"]);
|
|
|
|
}
|