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

InfiniteDecimalAsFloatTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testAsFloat() 0 5 1
A testAsInteger() 0 18 3
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