, opts: &stv::STVOptions) -> String {
let mut result = String::from("Count complete. The winning candidates are, in order of election:
");
let mut winners = Vec::new();
for (candidate, count_card) in state.candidates.iter() {
if count_card.state == CandidateState::Elected {
- winners.push((candidate, count_card.order_elected));
+ winners.push((candidate, count_card.order_elected, &count_card.keep_value));
}
}
winners.sort_unstable_by(|a, b| a.1.partial_cmp(&b.1).unwrap());
- for (winner, _) in winners.into_iter() {
- result.push_str(&format!("- {}
", winner.name));
+ for (winner, _, kv_opt) in winners.into_iter() {
+ if let Some(kv) = kv_opt {
+ result.push_str(&format!("- {} (kv = {:.dps2$})
", winner.name, kv, dps2=max(opts.pp_decimals, 2)));
+ } else {
+ result.push_str(&format!("- {}
", winner.name));
+ }
}
result.push_str("
");
diff --git a/tests/utils/mod.rs b/tests/utils/mod.rs
index df76276..5f86777 100644
--- a/tests/utils/mod.rs
+++ b/tests/utils/mod.rs
@@ -55,6 +55,7 @@ pub fn read_validate_election(csv_file: &str, blt_file: &str, stv_opt
pub fn validate_election(stages: Vec, records: Vec, election: Election, stv_opts: stv::STVOptions)
where
for<'r> &'r N: ops::Sub<&'r N, Output=N>,
+ for<'r> &'r N: ops::Mul<&'r N, Output=N>,
for<'r> &'r N: ops::Div<&'r N, Output=N>,
for<'r> &'r N: ops::Neg