From b17af1816fcc0b5803fcba813350ce6eb1381c79 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 22 May 2020 00:38:52 +0200 Subject: Tests for consistent rounding when "stretching" points to the last place instaead of 50% --- test/DoublePointsTest.php | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 test/DoublePointsTest.php diff --git a/test/DoublePointsTest.php b/test/DoublePointsTest.php new file mode 100644 index 0000000..a98a5b4 --- /dev/null +++ b/test/DoublePointsTest.php @@ -0,0 +1,45 @@ + 2, + 'contestants' => $players, + 'manual' => [ + 'min_points' => $points + ] + ]; + $doubleContestants = $params; + $doubleContestants['contestants'] *= 2; + $doubleContestantsResults = run($doubleContestants); + $doubleContestantsResults['points'] = array_slice( + $doubleContestantsResults['points'], 0, $players, TRUE); + $doubleContestantsResults['sum'] = array_sum($doubleContestantsResults['points']) * 2; + $stretchFunction = $params; + $stretchFunction['manual']['points_cutoffs'] = [ + [0.04, 0.9], [0.4, 0.2], [1.0, 0.0] + ]; + $stretchFunctionResults = run($stretchFunction); + $this->assertEquals($stretchFunctionResults, $doubleContestantsResults); + } + + public function dataGenerator() { + for ($maxPoints = 10; $maxPoints <= 250; $maxPoints += 5) { + for ($players = 10; $players < $maxPoints; $players += 1) { + yield [$maxPoints, $players]; + } + } + } + +} + +?> -- cgit v1.2.3