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

DecimalCotanTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A cotanProvider() 0 8 1
A testSimple() 0 9 1
A testCotanPiDiv() 0 5 1
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
}