DecimalArcsecTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 35
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A arcsecProvider() 0 9 1
A testSimple() 0 10 1
A testArcsecBetweenOneAndNegativeOne() 0 4 1
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