Completed
Push — master ( b9f967...7a222d )
by Andreu
9s
created

InfiniteDecimalCompTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 1 Features 1
Metric Value
wmc 2
c 1
b 1
f 1
lcom 0
cbo 2
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testFiniteInfiniteComp() 0 12 1
A testInfiniteInfiniteComp() 0 11 1
1
<?php
2
3
use Litipk\BigNumbers\Decimal as Decimal;
4
5
6
date_default_timezone_set('UTC');
7
8
9
class InfiniteDecimalCompTest extends PHPUnit_Framework_TestCase
10
{
11
    public function testFiniteInfiniteComp()
12
    {
13
        $ten  = Decimal::fromInteger(10);
14
        $pInf = Decimal::getPositiveInfinite();
15
        $nInf = Decimal::getNegativeInfinite();
16
17
        $this->assertTrue($ten->comp($pInf) === -1);
18
        $this->assertTrue($ten->comp($nInf) === 1);
19
20
        $this->assertTrue($pInf->comp($ten) === 1);
21
        $this->assertTrue($nInf->comp($ten) === -1);
22
    }
23
24
    public function testInfiniteInfiniteComp()
25
    {
26
        $pInf = Decimal::getPositiveInfinite();
27
        $nInf = Decimal::getNegativeInfinite();
28
29
        $this->assertTrue($pInf->comp($pInf) === 0);
30
        $this->assertTrue($nInf->comp($nInf) === 0);
31
32
        $this->assertTrue($pInf->comp($nInf) === 1);
33
        $this->assertTrue($nInf->comp($pInf) === -1);
34
    }
35
}
36