OpenTally/tests/tests_impl/wa.rs

44 lines
1.9 KiB
Rust

/* OpenTally: Open-source election vote counting
* Copyright © 2021–2023 Lee Yingtong Li (RunasSudo)
*
* 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/>.
*/
// Compare results under Western Australia STV with official results from WA Electoral Commission
// Using (partially) reconstructed ballot papers
use crate::utils;
use opentally::numbers::Rational;
use opentally::stv;
#[test]
fn wa_eastmetro08_rational() {
// Validates only up to stage 10 (Exclusion of PASSMORE, Theresa)
let stv_opts = stv::STVOptionsBuilder::default()
.round_votes(Some(0))
.round_quota(Some(0))
.round_subtransfers(stv::RoundSubtransfersMode::ByParcel)
.quota_criterion(stv::QuotaCriterion::GreaterOrEqual)
.exclusion(stv::ExclusionMethod::ParcelsByOrder)
.surplus_order(stv::SurplusOrder::ByOrder)
.surplus_assume_total(true)
.build().unwrap();
assert_eq!(stv_opts.describe::<Rational>(), "--round-votes 0 --round-quota 0 --round-subtransfers by_parcel --quota-criterion geq --ties backwards random --random-seed 20220322 --surplus-order by_order --surplus-assume-total --exclusion parcels_by_order");
utils::read_validate_election::<Rational>("tests/data/WA2008-EastMetro-PartialReconstruction.csv", "tests/data/WA2008-EastMetro-PartialReconstruction.blt", stv_opts, None, &["exhausted", "lbf"]);
}