From 1ae7feb2cfa6f3d1fd468bd1e39d8989b733a9fe Mon Sep 17 00:00:00 2001 From: Anders Olsson Date: Fri, 26 Oct 2018 13:34:51 +0200 Subject: [PATCH] Added another test. --- src/lib.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index d9132ba..46f2e6d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -395,6 +395,30 @@ mod tests { } } + #[test] + fn test_rate_8_free_for_all() { + // Example from http://research.microsoft.com/en-us/projects/trueskill/details.aspx + + let (ratings, ranks) = generate_free_for_all(8); + + let expected_ratings = vec![ + Rating::new(36.77209218345724, 5.74919889706158), + Rating::new(32.24259218000257, 5.13287020009844), + Rating::new(29.07403314155725, 4.94269079502333), + Rating::new(26.32218621002892, 4.87453695296329), + Rating::new(23.67782451664047, 4.87454338643793), + Rating::new(20.92602299394360, 4.94271209665760), + Rating::new(17.75766311093125, 5.13291097072849), + Rating::new(13.22891063797913, 5.74928289201801), + ]; + + let ratings = rate(ratings.as_ref(), ranks.as_ref(), DELTA); + + for (rating, expected) in ratings.iter().zip(expected_ratings.iter()) { + assert_relative_eq!(rating, expected, epsilon = EPSILON); + } + } + #[test] fn test_rate_8_free_for_all_draw() { let (ratings, ranks) = generate_free_for_all_draw(8);