Completed
Push — master ( b9f967...7a222d )
by Andreu
9s
created

DecimalCotanTest::cotanProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
use \Litipk\BigNumbers\Decimal as Decimal;
4
use \Litipk\BigNumbers\DecimalConstants as DecimalConstants;
5
6
/**
7
 * @group cotan
8
 */
9
class DecimalCotanTest extends PHPUnit_Framework_TestCase
10
{
11
    public function cotanProvider() {
12
        // Some values providede by mathematica
13
        return [
14
            ['1', '0.64209261593433', 14],
15
            ['123.123', '1.45891895739232371', 17],
16
            ['15000000000', '-1.04405948230055701685', 20]
17
        ];
18
    }
19
20
    /**
21
     * @dataProvider cotanProvider
22
     */
23
    public function testSimple($nr, $answer, $digits)
24
    {
25
        $x = Decimal::fromString($nr);
26
        $cotanX = $x->cotan($digits);
27
        $this->assertTrue(
28
            Decimal::fromString($answer)->equals($cotanX),
29
            'cotan('.$nr.') must be equal to '.$answer.', but was '.$cotanX
30
        );
31
    }
32
    
33
    /**
34
     * @expectedException \DomainException
35
     * @expectedExceptionMessage The cotangent of this 'angle' is undefined.
36
     */
37
    public function testCotanPiDiv()
38
    {    	
39
        $PI  = DecimalConstants::PI();
40
        $PI->cotan();
41
    }
42
    
43
}