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

DecimalArccosTest::testArcosGreaterThanOne()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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