Completed
Pull Request — master (#51)
by
unknown
08:53
created

DecimalArctanTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
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 26
rs 10

2 Methods

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