DecimalArccosTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A arccosProvider() 0 8 1
A testSimple() 0 10 1
A testArcosGreaterThanOne() 0 4 1
A testArccosFewerThanNegativeOne() 0 4 1
1
<?php
2
3
use Litipk\BigNumbers\Decimal as Decimal;
4
use PHPUnit\Framework\TestCase;
5
6
/**
7
 * @group arccos
8
 */
9
class DecimalArccosTest extends TestCase
10
{
11
    public function arccosProvider() {
12
        // Some values provided by wolframalpha
13
        return [
14
            ['0.154', '1.41618102663394', 14],
15
            ['1', '0', 17],
16
            ['-1', '3.14159265358979324', 17],
17
        ];
18
    }
19
20
    /**
21
     * @dataProvider arccosProvider
22
     */
23
    public function testSimple($nr, $answer, $digits)
24
    {
25
        $x = Decimal::fromString($nr);
26
        $arccosX = $x->arccos($digits);
27
28
        $this->assertTrue(
29
            Decimal::fromString($answer)->equals($arccosX),
30
            "The answer must be " . $answer . ", but was " . $arccosX
31
        );
32
    }
33
34
    /**
35
     * @expectedException \DomainException
36
     * @expectedExceptionMessage The arccos of this number is undefined.
37
     */
38
    public function testArcosGreaterThanOne()
39
    {
40
        Decimal::fromString('25.546')->arccos();
41
    }
42
43
    /**
44
     * @expectedException \DomainException
45
     * @expectedExceptionMessage The arccos of this number is undefined.
46
     */
47
    public function testArccosFewerThanNegativeOne()
48
    {
49
        Decimal::fromString('-304.75')->arccos();
50
    }
51
}
52