2022-03-22 15:51:38 +01:00
|
|
|
|
/* OpenTally: Open-source election vote counting
|
|
|
|
|
* Copyright © 2021–2022 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 NSW Local Government STV with official results from NSW Electoral Commission
|
|
|
|
|
|
|
|
|
|
use crate::utils;
|
|
|
|
|
|
|
|
|
|
use opentally::numbers::Rational;
|
|
|
|
|
use opentally::stv;
|
|
|
|
|
use opentally::ties::TieStrategy;
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn nswlg_albury21_rational() {
|
|
|
|
|
let stv_opts = stv::STVOptionsBuilder::default()
|
|
|
|
|
.round_votes(Some(0))
|
|
|
|
|
.round_quota(Some(0))
|
2022-03-24 17:04:00 +01:00
|
|
|
|
.round_subtransfers(stv::RoundSubtransfersMode::ByParcel)
|
2022-03-22 15:51:38 +01:00
|
|
|
|
.quota_criterion(stv::QuotaCriterion::GreaterOrEqual)
|
|
|
|
|
.ties(vec![TieStrategy::Backwards, TieStrategy::Random(String::from("20220322"))])
|
|
|
|
|
.surplus_order(stv::SurplusOrder::ByOrder)
|
|
|
|
|
.transferable_only(true)
|
2022-03-24 16:46:30 +01:00
|
|
|
|
.subtract_nontransferable(true)
|
2022-03-22 15:51:38 +01:00
|
|
|
|
.build().unwrap();
|
|
|
|
|
|
2022-03-24 17:04:00 +01:00
|
|
|
|
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 --transferable-only --subtract-nontransferable");
|
2022-03-22 15:51:38 +01:00
|
|
|
|
|
|
|
|
|
utils::read_validate_election::<Rational>("tests/data/City_of_Albury-finalpreferencedatafile.csv", "tests/data/City_of_Albury-finalpreferencedatafile.blt", stv_opts, None, &[]);
|
|
|
|
|
}
|