DecimalCotanTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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