Added a test for 4 vs 4.

This commit is contained in:
2018-10-25 21:49:40 +02:00
parent 2367a8e47f
commit 7a378c26b0

View File

@@ -411,4 +411,47 @@ mod tests {
assert_relative_eq!(rating, expected, epsilon = EPSILON); assert_relative_eq!(rating, expected, epsilon = EPSILON);
} }
} }
#[test]
fn test_rate_4vs4() {
let _ = env_logger::try_init();
let alice = Rating::new(MU, SIGMA);
let bob = Rating::new(MU, SIGMA);
let chris = Rating::new(MU, SIGMA);
let darren = Rating::new(MU, SIGMA);
let eric = Rating::new(MU, SIGMA);
let fred = Rating::new(MU, SIGMA);
let grace = Rating::new(MU, SIGMA);
let laura = Rating::new(MU, SIGMA);
let expected_ratings = vec![
Rating::new(27.19791584649575, 8.058911711843994),
Rating::new(27.19791584649575, 8.058911711843994),
Rating::new(27.19791584649575, 8.058911711843994),
Rating::new(27.19791584649575, 8.058911711843994),
Rating::new(22.802084153504236, 8.058911711843994),
Rating::new(22.802084153504236, 8.058911711843994),
Rating::new(22.802084153504236, 8.058911711843994),
Rating::new(22.802084153504236, 8.058911711843994),
];
let ratings = rate(
&[
(alice, 0),
(bob, 0),
(chris, 0),
(darren, 0),
(eric, 1),
(fred, 1),
(grace, 1),
(laura, 1),
],
&[0, 1],
);
for (rating, expected) in ratings.iter().zip(expected_ratings.iter()) {
assert_relative_eq!(rating, expected, epsilon = EPSILON);
}
}
} }