1<?php
2/**
3 * OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
4 * all the essential functionalities required for any enterprise.
5 * Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
6 *
7 * OrangeHRM is free software; you can redistribute it and/or modify it under the terms of
8 * the GNU General Public License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along with this program;
16 * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA
18 */
19
20class NumberUtilityTest extends PHPUnit\Framework\TestCase
21{
22    /**
23     * @dataProvider dataProviderGetPositiveDecimal
24     * @param $value
25     * @param $decimals
26     * @param $expected
27     */
28    public function testGetPositiveDecimal($value, $decimals, $expected)
29    {
30        $result = NumberUtility::getPositiveDecimal($value, $decimals);
31        $this->assertEquals($expected, $result);
32    }
33
34    /**
35     * @return Generator
36     */
37    public function dataProviderGetPositiveDecimal()
38    {
39        yield [1.3671, 3, 1.367];
40        yield [1.3671, 1, 1.4];
41        yield [0.00000000001, 14, 0.00000000001];
42        yield [-0.00000000001, 14, 0];
43    }
44}
45