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

InfiniteDecimalAsFloatTest::testAsInteger()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 18
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 18
rs 9.4285
cc 3
eloc 13
nc 4
nop 0
1
<?php
2
3
use Litipk\BigNumbers\InfiniteDecimal as InfiniteDecimal;
4
use Litipk\Exceptions\InvalidCastException as InvalidCastException;
5
6
7
date_default_timezone_set('UTC');
8
9
10
class InfiniteDecimalAsFloatTest extends PHPUnit_Framework_TestCase
11
{
12
    public function testAsFloat()
13
    {
14
        $this->assertEquals(INF, InfiniteDecimal::getPositiveInfinite()->asFloat());
15
        $this->assertEquals(-INF, InfiniteDecimal::getNegativeInfinite()->asFloat());
16
    }
17
18
    public function testAsInteger()
19
    {
20
        $catched = false;
21
        try {
22
            InfiniteDecimal::getPositiveInfinite()->asInteger();
23
        } catch (InvalidCastException $e) {
24
            $catched = true;
25
        }
26
        $this->assertTrue($catched);
27
28
        $catched = false;
29
        try {
30
            InfiniteDecimal::getNegativeInfinite()->asInteger();
31
        } catch (InvalidCastException $e) {
32
            $catched = true;
33
        }
34
        $this->assertTrue($catched);
35
    }
36
}
37