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

InfiniteDecimalAsFloatTest::testAsFloat()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 2
Metric Value
c 2
b 1
f 2
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
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