Completed
Push — master ( 7a222d...ef221c )
by Andreu
06:00
created

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