testArcsecBetweenOneAndNegativeOne()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
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
use PHPUnit\Framework\TestCase;
5
6
/**
7
 * @group arcsec
8
 */
9
class DecimalArcsecTest extends TestCase
10
{
11
    public function arcsecProvider() {
12
        // Some values provided by wolframalpha
13
        return [
14
            ['25.546', '1.53164125102163', 14],
15
            ['1.5', '0.841068', 6],
16
            ['1', '0', 17],
17
            ['-1', '3.14159265358979324', 17],
18
        ];
19
    }
20
21
    /**
22
     * @dataProvider arcsecProvider
23
     */
24
    public function testSimple($nr, $answer, $digits)
25
    {
26
        $x = Decimal::fromString($nr);
27
        $arcsecX = $x->arcsec($digits);
28
29
        $this->assertTrue(
30
            Decimal::fromString($answer)->equals($arcsecX),
31
            "The answer must be " . $answer . ", but was " . $arcsecX
32
        );
33
    }
34
35
    /**
36
     * @expectedException \DomainException
37
     * @expectedExceptionMessage The arcsecant of this number is undefined.
38
     */
39
    public function testArcsecBetweenOneAndNegativeOne()
40
    {
41
        Decimal::fromString('0.546')->arcsec();
42
    }
43
}
44