19use PHPUnit\Framework\TestCase;
31 protected function setUp(): void
37 #[\PHPUnit\Framework\Attributes\DataProvider('gcdData')]
38 public function testGcd(
string $a,
string $b,
string $result): void
49 [
'1254',
'5298',
'6'],
50 [
'41414124',
'41414124',
'41414124']
56 $this->assertEqualsWithDelta(100.0, (
float) $this->eval_math->evaluate(
'1E+2'), 0.000001);
57 $this->assertEqualsWithDelta(5400000.0, (
float) $this->eval_math->evaluate(
'5.4E+6'), 0.001);
58 $this->assertEqualsWithDelta(5400000.0, (
float) $this->eval_math->evaluate(
'54E5'), 0.001);
59 $this->assertEqualsWithDelta(0.0054, (
float) $this->eval_math->evaluate(
'5.4E-3'), 0.0000001);
61 $lower = (float) $this->eval_math->evaluate(
'5.4E+24');
62 $upper = (float) $this->eval_math->evaluate(
'5.6E+24');
63 $this->assertGreaterThan(38000.0, $lower);
64 $this->assertGreaterThan($lower, $upper);
66 if (extension_loaded(
'bcmath')) {
67 $lower_text = (string) $this->eval_math->evaluate(
'5.4E+24');
68 $upper_text = (string) $this->eval_math->evaluate(
'5.6E+24');
69 $this->assertSame(0, bccomp($lower_text,
'5400000000000000000000000', 0), $lower_text);
70 $this->assertSame(0, bccomp($upper_text,
'5600000000000000000000000', 0), $upper_text);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
testGcd(string $a, string $b, string $result)
testPlusScientificNotationIsPowerOfTen()
static getFirstValidAdapter()
static setDefaultAdapter(ilMathAdapter $adapter)
static getGreatestCommonDivisor($a, $b)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples