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

DecimalAdditiveInverseTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testZeroAdditiveInverse() 0 4 1
A testNegativeAdditiveInverse() 0 5 1
A testPositiveAdditiveInverse() 0 5 1
1
<?php
2
3
use Litipk\BigNumbers\Decimal as Decimal;
4
5
6
date_default_timezone_set('UTC');
7
8
9
class DecimalAdditiveInverseTest extends PHPUnit_Framework_TestCase
10
{
11
    public function testZeroAdditiveInverse()
12
    {
13
        $this->assertTrue(Decimal::fromInteger(0)->additiveInverse()->equals(Decimal::fromInteger(0)));
14
    }
15
16
    public function testNegativeAdditiveInverse()
17
    {
18
        $this->assertTrue(Decimal::fromInteger(-1)->additiveInverse()->equals(Decimal::fromInteger(1)));
19
        $this->assertTrue(Decimal::fromString('-1.768')->additiveInverse()->equals(Decimal::fromString('1.768')));
20
    }
21
22
    public function testPositiveAdditiveInverse()
23
    {
24
        $this->assertTrue(Decimal::fromInteger(1)->additiveInverse()->equals(Decimal::fromInteger(-1)));
25
        $this->assertTrue(Decimal::fromString('1.768')->additiveInverse()->equals(Decimal::fromString('-1.768')));
26
    }
27
}
28