DecimalIsZeroTest::testZeros()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
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 DecimalIsZeroTest extends TestCase
9
{
10
    public function testZeros()
11
    {
12
        $this->assertTrue(Decimal::fromInteger(0)->isZero());
13
        $this->assertTrue(Decimal::fromFloat(0.0)->isZero());
14
        $this->assertTrue(Decimal::fromString('0')->isZero());
15
    }
16
17
    public function testPositiveNumbers()
18
    {
19
        $this->assertFalse(Decimal::fromInteger(1)->isZero());
20
        $this->assertFalse(Decimal::fromFloat(1.0)->isZero());
21
        $this->assertFalse(Decimal::fromFloat(0.1)->isZero());
22
        $this->assertFalse(Decimal::fromString('1')->isZero());
23
    }
24
25
    public function testNegativeNumbers()
26
    {
27
        $this->assertFalse(Decimal::fromInteger(-1)->isZero());
28
        $this->assertFalse(Decimal::fromFloat(-1.0)->isZero());
29
        $this->assertFalse(Decimal::fromFloat(-0.1)->isZero());
30
        $this->assertFalse(Decimal::fromString('-1')->isZero());
31
    }
32
}
33