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

DecimalArcsecTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
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
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