DecimalAdditiveInverseTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
c 0
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
use PHPUnit\Framework\TestCase;
5
6
date_default_timezone_set('UTC');
7
8
class DecimalAdditiveInverseTest extends TestCase
9
{
10
    public function testZeroAdditiveInverse()
11
    {
12
        $this->assertTrue(Decimal::fromInteger(0)->additiveInverse()->equals(Decimal::fromInteger(0)));
13
    }
14
15
    public function testNegativeAdditiveInverse()
16
    {
17
        $this->assertTrue(Decimal::fromInteger(-1)->additiveInverse()->equals(Decimal::fromInteger(1)));
18
        $this->assertTrue(Decimal::fromString('-1.768')->additiveInverse()->equals(Decimal::fromString('1.768')));
19
    }
20
21
    public function testPositiveAdditiveInverse()
22
    {
23
        $this->assertTrue(Decimal::fromInteger(1)->additiveInverse()->equals(Decimal::fromInteger(-1)));
24
        $this->assertTrue(Decimal::fromString('1.768')->additiveInverse()->equals(Decimal::fromString('-1.768')));
25
    }
26
}
27