assertSame(CMathHelper::safeSum($values), $expected); } public function testSafeMulProvider() { return [ [[1E+308, 1E-308], 1], [[1E+308, 1E+308], INF], [[1E+308, 1E+308, 1E-308, 1E-308, 5], 5], [[1E+308, -1E+308, 1E-308, -1E-308, 5], 5], [[-1E+308, 1E+308, -1E-308, 1E-308, 5], 5], [[1E+308, 1E+308, 5, 1E-308, 1E-308], 5], [[1E+308, -1E+308, 5, 1E-308, -1E-308], 5], [[-1E+308, 1E+308, 5, -1E-308, 1E-308], 5], [[5, 1E+308, 1E+308, 1E-308, 1E-308], 5], [[5, 1E+308, -1E+308, 1E-308, -1E-308], 5], [[5, -1E+308, 1E+308, -1E-308, 1E-308], 5] ]; } /** * @dataProvider testSafeMulProvider * * @param array $values * @param float $expected */ public function testSafeMul(array $values, float $expected) { $this->assertSame(CMathHelper::safeMul($values), $expected); } public function testSafeAvgProvider() { return [ [[1E+308, 1E+308, -1E+308, -1E+308], 0], [[-1E+308, -1E+308, 1E+308, 1E+308], 0], [[-1E+308, -1E+308, 5, 1E+308, 1E+308], 1], [[1E-308, 1E-308, -1E-308, -1E-308], 0], [[-1E-308, -1E-308, 1E-308, 1E-308], 0], [[-1E-308, -1E-308, 5, 1E-308, 1E-308], 1] ]; } /** * @dataProvider testSafeAvgProvider * * @param array $values * @param float $expected */ public function testSafeAvg(array $values, float $expected) { $this->assertSame(CMathHelper::safeAvg($values), $expected); } }