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

DecimalSinTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A sinProvider() 0 8 1
A testSimple() 0 10 1
1
<?php
2
3
use Litipk\BigNumbers\Decimal as Decimal;
4
5
/**
6
 * @group sin
7
 */
8
class DecimalSinTest extends PHPUnit_Framework_TestCase
9
{
10
    public function sinProvider() {
11
        // Some values providede by mathematica
12
        return [
13
            ['1', '0.84147098480790', 14],
14
            ['123.123', '-0.56537391969733569', 17],
15
            ['15000000000', '0.69170450164193502844', 20]
16
        ];
17
    }
18
19
    /**
20
     * @dataProvider sinProvider
21
     */
22
    public function testSimple($nr, $answer, $digits)
23
    {
24
        $x = Decimal::fromString($nr);
25
        $sinX = $x->sin($digits);
26
27
        $this->assertTrue(
28
            Decimal::fromString($answer)->equals($sinX),
29
            "The answer must be " . $answer . ", but was " . $sinX
30
        );
31
    }
32
}
33