From 7a378c26b02e3173ebd40a39c3afb7805d3b2c6c Mon Sep 17 00:00:00 2001 From: Anders Olsson Date: Thu, 25 Oct 2018 21:49:40 +0200 Subject: [PATCH] Added a test for 4 vs 4. --- src/lib.rs | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index ef9b47b..9bc80e3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -411,4 +411,47 @@ mod tests { 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); + } + } }