-
Notifications
You must be signed in to change notification settings - Fork 446
/
Copy pathGmpCalculatorTest.php
71 lines (61 loc) · 1.51 KB
/
GmpCalculatorTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
declare(strict_types=1);
namespace Tests\Money\Calculator;
use Money\Calculator\GmpCalculator;
use function array_merge;
/**
* @requires extension gmp
* @covers \Money\Calculator\GmpCalculator
*/
class GmpCalculatorTest extends CalculatorTestCase
{
/**
* @return GmpCalculator
* @psalm-return class-string<GmpCalculator>
*/
protected function getCalculator(): string
{
return GmpCalculator::class;
}
/**
* @test
*/
public function itMultipliesZero(): void
{
self::assertSame('0', $this->getCalculator()::multiply('0', '0.8'));
}
/**
* @test
*/
public function itFloorsZero(): void
{
self::assertSame('0', $this->getCalculator()::floor('0'));
}
/**
* @test
*/
public function itComparesZeroWithFraction(): void
{
self::assertSame(1, $this->getCalculator()::compare('0.5', '0'));
}
/**
* @test
*/
public function it_divides_bug538(): void
{
self::assertSame('-4.54545454545455', $this->getCalculator()::divide('-500', '110'));
}
/**
* @psalm-return array<int,array<int|numeric-string>>
*/
public static function compareLessExamples(): array
{
return array_merge(
parent::compareLessExamples(),
[
// Slightly below PHP_INT_MIN on 64 bit systems (does not work with the PhpCalculator)
['-9223372036854775810', '-9223372036854775809', -1],
]
);
}
}