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

DecimalSecTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
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
5
/**
6
 * @group sec
7
 */
8
class DecimalSecTest extends PHPUnit_Framework_TestCase
9
{
10
    public function SecProvider() {
11
        // Some values provided by Mathematica
12
        return [
13
            ['5', '3.52532008581609', 14],
14
            ['456.456', '-1.66172995090378344', 17],
15
            ['28000000000', '-1.11551381955633891873', 20],
16
        ];
17
    }
18
19
    /**
20
     * @dataProvider secProvider
21
     */
22
    public function testSimple($nr, $answer, $digits)
23
    {
24
        $x = Decimal::fromString($nr);
25
        $secX = $x->sec((int)$digits);
26
27
        $this->assertTrue(
28
            Decimal::fromString($answer)->equals($secX),
29
            "The answer must be " . $answer . ", but was " . $secX
30
        );
31
    }
32
}
33