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

DecimalArccosTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
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
5
/**
6
 * @group arcsin
7
 */
8
class DecimalArccosTest extends PHPUnit_Framework_TestCase
9
{
10
    public function arccosProvider() {
11
        // Some values provided by wolframalpha
12
        return [
13
            ['0.154', '1.41618102663394', 14],
14
            ['1', '0', 17],
15
            ['-1', '3.14159265358979324', 17],
16
        ];
17
    }
18
19
    /**
20
     * @dataProvider arccosProvider
21
     */
22
    public function testSimple($nr, $answer, $digits)
23
    {
24
        $x = Decimal::fromString($nr);
25
        $arccosX = $x->arccos($digits);
26
27
        $this->assertTrue(
28
            Decimal::fromString($answer)->equals($arccosX),
29
            "The answer must be " . $answer . ", but was " . $arccosX
30
        );
31
    }
32
33
    /**
34
     * @expectedException \DomainException
35
     * @expectedExceptionMessage The arccos of this number is undefined.
36
     */
37
    public function testArcosGreaterThanOne()
38
    {
39
        Decimal::fromString('25.546')->arccos();
40
    }
41
42
    /**
43
     * @expectedException \DomainException
44
     * @expectedExceptionMessage The arccos of this number is undefined.
45
     */
46
    public function testArccosFewerThanNegativeOne()
47
    {
48
        Decimal::fromString('-304.75')->arccos();
49
    }
50
}
51