DecimalSecTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 25
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A SecProvider() 0 8 1
A testSimple() 0 10 1
1
<?php
2
3
use Litipk\BigNumbers\Decimal as Decimal;
4
use PHPUnit\Framework\TestCase;
5
6
/**
7
 * @group sec
8
 */
9
class DecimalSecTest extends TestCase
10
{
11
    public function SecProvider() {
12
        // Some values provided by Mathematica
13
        return [
14
            ['5', '3.52532008581609', 14],
15
            ['456.456', '-1.66172995090378344', 17],
16
            ['28000000000', '-1.11551381955633891873', 20],
17
        ];
18
    }
19
20
    /**
21
     * @dataProvider secProvider
22
     */
23
    public function testSimple($nr, $answer, $digits)
24
    {
25
        $x = Decimal::fromString($nr);
26
        $secX = $x->sec((int)$digits);
27
28
        $this->assertTrue(
29
            Decimal::fromString($answer)->equals($secX),
30
            "The answer must be " . $answer . ", but was " . $secX
31
        );
32
    }
33
}
34