You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Noticed this by chance in my own testing. While trivial to work around I figured I'd report it. I haven't checked if other methods have similar issues.
Here is a failing test:
#[test]
fn schulze_single_canidate() -> Result<(), TallyError> {
let candidates = vec!["A".to_string()];
let votes_raw = "A";
let votes = Cursor::new(votes_raw);
let votes = util::read_votes(votes).unwrap();
// Margin
let mut tally = DefaultSchulzeTally::with_candidates(1, Variant::Margin, candidates.clone());
for (vote, weight) in votes.iter() {
match vote {
util::ParsedVote::Ranked(v) => tally.ranked_add_weighted(v, *weight)?,
util::ParsedVote::Unranked(v) => tally.add_weighted(v, *weight)?,
}
}
assert_eq!(tally.winners().into_unranked()[0], "A".to_string());
// Winning
let mut tally = DefaultSchulzeTally::with_candidates(1, Variant::Winning, candidates.clone());
for (vote, weight) in votes.iter() {
match vote {
util::ParsedVote::Ranked(v) => tally.ranked_add_weighted(v, *weight)?,
util::ParsedVote::Unranked(v) => tally.add_weighted(v, *weight)?,
}
}
assert_eq!(tally.winners().into_unranked()[0], "A".to_string());
// Ratio
let votes = Cursor::new(votes_raw);
let votes = util::read_votes(votes).unwrap(); // reparse votes as f64
let mut tally = SchulzeTally::<_, f64>::with_candidates(1, Variant::Ratio, candidates.clone());
for (vote, weight) in votes.iter() {
match vote {
util::ParsedVote::Ranked(v) => tally.ranked_add_weighted(v, *weight)?,
util::ParsedVote::Unranked(v) => tally.add_weighted(v, *weight)?,
}
}
assert_eq!(tally.winners().into_unranked()[0], "A".to_string());
Ok(())
}
The text was updated successfully, but these errors were encountered:
Noticed this by chance in my own testing. While trivial to work around I figured I'd report it. I haven't checked if other methods have similar issues.
Here is a failing test:
The text was updated successfully, but these errors were encountered: