Completed
Pull Request — master (#51)
by
unknown
08:53
created

DecimalConstantsTest::testE()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 14
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
use Litipk\BigNumbers\DecimalConstants as DecimalConstants;
4
use Litipk\BigNumbers\Decimal as Decimal;
5
6
7
date_default_timezone_set('UTC');
8
9
10
class DecimalConstantsTest extends PHPUnit_Framework_TestCase
11
{
12
    public function testFiniteAbs()
13
    {
14
        $this->assertTrue(DecimalConstants::pi()->equals(
15
            Decimal::fromString("3.14159265358979323846264338327950")
16
        ));
17
18
        $this->assertTrue(DecimalConstants::eulerMascheroni()->equals(
19
            Decimal::fromString("0.57721566490153286060651209008240")
20
        ));
21
22
        $this->assertTrue(DecimalConstants::goldenRatio()->equals(
23
            Decimal::fromString("1.61803398874989484820458683436564")
24
        ));
25
26
        $this->assertTrue(DecimalConstants::lightSpeed()->equals(
27
            Decimal::fromInteger(299792458)
28
        ));
29
    }
30
31
    public function testE()
32
    {
33
        $this->assertTrue(DecimalConstants::e()->equals(
34
            Decimal::fromString("2.71828182845904523536028747135266")
35
        ));
36
37
        $this->assertTrue(DecimalConstants::e(32)->equals(
38
            Decimal::fromString("2.71828182845904523536028747135266")
39
        ));
40
41
        $this->assertTrue(DecimalConstants::e(16)->equals(
42
            Decimal::fromString("2.7182818284590452")
43
        ));
44
    }
45
46
    /**
47
     * @expectedException Litipk\Exceptions\InvalidArgumentTypeException
48
     */
49
    public function testIncorrectTypedParamsOnE()
50
    {
51
        DecimalConstants::e("hello");
52
    }
53
54
    /**
55
     * @expectedException \InvalidArgumentException
56
     * @expectedExceptionMessage $scale must be positive.
57
     */
58
    public function testNegativeParamsOnE()
59
    {
60
        DecimalConstants::e(-3);
61
    }
62
}
63