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

DecimalCosTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A cosProvider() 0 8 1
A testSimple() 0 10 1
1
<?php
2
3
use Litipk\BigNumbers\Decimal as Decimal;
4
5
/**
6
 * @group cos
7
 */
8
class DecimalCosTest extends PHPUnit_Framework_TestCase
9
{
10
    public function cosProvider() {
11
        // Some values provided by Mathematica
12
        return [
13
            ['1', '0.54030230586814', 14],
14
            ['123.123', '-0.82483472946164834', 17],
15
            ['15000000000', '-0.72218064388924347683', 20]
16
        ];
17
    }
18
19
    /**
20
     * @dataProvider cosProvider
21
     */
22
    public function testSimple($nr, $answer, $digits)
23
    {
24
        $x = Decimal::fromString($nr);
25
        $cosX = $x->cos((int)$digits);
26
27
        $this->assertTrue(
28
            Decimal::fromString($answer)->equals($cosX),
29
            "The answer must be " . $answer . ", but was " . $cosX
30
        );
31
    }
32
}
33