61 lines
2.4 KiB
Rust
61 lines
2.4 KiB
Rust
/* OpenTally: Open-source election vote counting
|
|
* Copyright © 2021 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/>.
|
|
*/
|
|
|
|
use assert_cmd::Command;
|
|
use predicates::prelude::*;
|
|
|
|
#[test]
|
|
fn cli_ers97old() {
|
|
Command::cargo_bin("opentally").expect("Cargo Error")
|
|
.args(&["stv", "tests/data/ers97old.blt", "--numbers", "fixed", "--decimals", "5", "--round-tvs", "2", "--round-weights", "2", "--round-votes", "2", "--round-quota", "2", "--quota", "droop_exact", "--quota-mode", "ers97", "--surplus", "eg", "--transferable-only", "--exclusion", "by_value"])
|
|
.assert().success();
|
|
}
|
|
|
|
#[test]
|
|
fn cli_meekm_wigm_ties_prompt() {
|
|
Command::cargo_bin("opentally").expect("Cargo Error")
|
|
.args(&["stv", "tests/data/meekm.blt", "--ties", "prompt"])
|
|
.write_stdin("1")
|
|
.assert().stdout(predicate::str::contains("Charlotte is excluded"));
|
|
|
|
Command::cargo_bin("opentally").expect("Cargo Error")
|
|
.args(&["stv", "tests/data/meekm.blt", "--ties", "prompt"])
|
|
.write_stdin("2")
|
|
.assert().stdout(predicate::str::contains("Donald is excluded"));
|
|
}
|
|
|
|
#[test]
|
|
fn cli_meekm_wigm_ties_forwards() {
|
|
Command::cargo_bin("opentally").expect("Cargo Error")
|
|
.args(&["stv", "tests/data/meekm.blt", "--ties", "forwards", "prompt"])
|
|
.assert().stdout(predicate::str::contains("Charlotte is excluded"));
|
|
}
|
|
|
|
#[test]
|
|
fn cli_meekm_wigm_ties_backwards() {
|
|
Command::cargo_bin("opentally").expect("Cargo Error")
|
|
.args(&["stv", "tests/data/meekm.blt", "--ties", "backwards", "prompt"])
|
|
.assert().stdout(predicate::str::contains("Charlotte is excluded"));
|
|
}
|
|
|
|
#[test]
|
|
fn cli_meekm_wigm_ties_random() {
|
|
Command::cargo_bin("opentally").expect("Cargo Error")
|
|
.args(&["stv", "tests/data/meekm.blt", "--ties", "random", "--random-seed", "foo"])
|
|
.assert().stdout(predicate::str::contains("Donald is excluded"));
|
|
}
|