ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilMathTest Class Reference
+ Inheritance diagram for ilMathTest:
+ Collaboration diagram for ilMathTest:

Public Member Functions

 testAdd ($a, $b, $result, $scale)
 @dataProvider addData More...
 
 testSub ($a, $b, $result, $scale)
 @dataProvider subData More...
 
 testMul ($a, $b, $result, $scale)
 @dataProvider mulData More...
 
 testDiv ($a, $b, $result, $scale)
 @dataProvider divData More...
 
 testSqrt ($a, $result, $scale)
 @dataProvider sqrtData More...
 
 testPow ($a, $b, $result, $scale)
 @dataProvider powData More...
 
 testMod ($a, $b, $result)
 @dataProvider modData More...
 
 testEquals ($a, $b, $result, $scale)
 @dataProvider equalsData More...
 
 testRound ($a, $result, $scale)
 @dataProvider roundData More...
 
 testGcd ($a, $b, $result)
 @dataProvider gcdData More...
 
 testCalculation ($formula, $result, $scale)
 @dataProvider calcData More...
 
 addData ()
 
 subData ()
 
 mulData ()
 
 divData ()
 
 modData ()
 
 sqrtData ()
 
 powData ()
 
 equalsData ()
 
 roundData ()
 
 gcdData ()
 
 calcData ()
 

Data Fields

const DEFAULT_SCALE = '50'
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $eval_math
 

Detailed Description

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 8 of file ilMathTest.php.

Member Function Documentation

◆ addData()

ilMathTest::addData ( )
Returns
array

Definition at line 121 of file ilMathTest.php.

122 {
123 return [
124 ['1', '2', '3', self::DEFAULT_SCALE]
125 ];
126 }
const DEFAULT_SCALE
Definition: ilMathTest.php:10

References DEFAULT_SCALE.

◆ calcData()

ilMathTest::calcData ( )

Definition at line 230 of file ilMathTest.php.

231 {
232 return [
233 ['3+5', '8', self::DEFAULT_SCALE],
234 ['-3+5', '2', self::DEFAULT_SCALE],
235 ['3*6+5', '23', self::DEFAULT_SCALE],
236 ['10/2', '5', self::DEFAULT_SCALE],
237 ['13/60', '0.2166666666667', '13'],
238 ['(-(-8)-sqrt((-8)^2-4*(7)))/(2)', '1', self::DEFAULT_SCALE],
239 ['(-(-8)+sqrt((-8)^2-4*(7)))/(2)', '7', self::DEFAULT_SCALE],
240 ['(-(-41)-sqrt((-41)^2-4*(1)*(5)))/(2*(1))', '0.122', '3'],
241 ['(-(-41)+sqrt((-41)^2-4*(1)*(5)))/(2*(1))', '40.878', '3'],
242 ['4^2-2*4+0.5*-16', '0', self::DEFAULT_SCALE],
243 ['-2^2-2*-2+0.5*-16', '-8', self::DEFAULT_SCALE]
244 ];
245 }

References DEFAULT_SCALE.

◆ divData()

ilMathTest::divData ( )
Returns
array

Definition at line 151 of file ilMathTest.php.

152 {
153 return [
154 ['1', '2', '0.5', self::DEFAULT_SCALE]
155 ];
156 }

References DEFAULT_SCALE.

◆ equalsData()

ilMathTest::equalsData ( )
Returns
array

Definition at line 198 of file ilMathTest.php.

199 {
200 return [
201 ['3', '3', true, self::DEFAULT_SCALE]
202 ];
203 }

References DEFAULT_SCALE.

◆ gcdData()

ilMathTest::gcdData ( )
Returns
array

Definition at line 219 of file ilMathTest.php.

220 {
221 return [
222 ['1254', '5298', '6'],
223 ['41414124', '41414124', '41414124']
224 ];
225 }

◆ modData()

ilMathTest::modData ( )
Returns
array

Definition at line 161 of file ilMathTest.php.

162 {
163 return [
164 ['1', '2', '1']
165 ];
166 }

◆ mulData()

ilMathTest::mulData ( )
Returns
array

Definition at line 141 of file ilMathTest.php.

142 {
143 return [
144 ['1', '2', '2', self::DEFAULT_SCALE]
145 ];
146 }

References DEFAULT_SCALE.

◆ powData()

ilMathTest::powData ( )
Returns
array

Definition at line 187 of file ilMathTest.php.

188 {
189 return [
190 ['3', '2', '9', self::DEFAULT_SCALE],
191 ['2', '64', '18446744073709551616', self::DEFAULT_SCALE]
192 ];
193 }

References DEFAULT_SCALE.

◆ roundData()

ilMathTest::roundData ( )
Returns
array

Definition at line 208 of file ilMathTest.php.

209 {
210 return [
211 ['2.4742', '2.47', '2'],
212 ['2.4762', '2.48', '2']
213 ];
214 }

◆ setUp()

ilMathTest::setUp ( )
protected

Definition at line 20 of file ilMathTest.php.

21 {
22 require_once 'Services/Math/classes/class.ilMath.php';
23 require_once 'Services/Math/classes/class.EvalMath.php';
24
25 $this->eval_math = new EvalMath();
26 }

◆ sqrtData()

ilMathTest::sqrtData ( )
Returns
array

Definition at line 171 of file ilMathTest.php.

172 {
173 $values = [
174 ['9', '3', self::DEFAULT_SCALE],
175 ['4294967296', '65536', self::DEFAULT_SCALE]
176 ];
177 if(extension_loaded('bcmath'))
178 {
179 array_push($values, ['4294967296', '65536', self::DEFAULT_SCALE]);
180 }
181 return $values;
182 }

References DEFAULT_SCALE.

◆ subData()

ilMathTest::subData ( )
Returns
array

Definition at line 131 of file ilMathTest.php.

132 {
133 return [
134 ['1', '2', '-1', self::DEFAULT_SCALE]
135 ];
136 }

References DEFAULT_SCALE.

◆ testAdd()

ilMathTest::testAdd (   $a,
  $b,
  $result,
  $scale 
)

@dataProvider addData

Definition at line 31 of file ilMathTest.php.

32 {
33 $this->assertEquals($result, ilMath::_add($a, $b, $scale));
34 }
$result
static _add($left_operand, $right_operand, $scale=50)

References $result, and ilMath\_add().

+ Here is the call graph for this function:

◆ testCalculation()

ilMathTest::testCalculation (   $formula,
  $result,
  $scale 
)

@dataProvider calcData

Definition at line 111 of file ilMathTest.php.

112 {
113 $this->assertEquals($result, ilMath::_round($this->eval_math->evaluate($formula), $scale));
114 }
static _round($value, $precision=0)

References $result, and ilMath\_round().

+ Here is the call graph for this function:

◆ testDiv()

ilMathTest::testDiv (   $a,
  $b,
  $result,
  $scale 
)

@dataProvider divData

Definition at line 55 of file ilMathTest.php.

56 {
57 $this->assertEquals($result, ilMath::_div($a, $b, $scale));
58 }
static _div($left_operand, $right_operand, $scale=50)

References $result, and ilMath\_div().

+ Here is the call graph for this function:

◆ testEquals()

ilMathTest::testEquals (   $a,
  $b,
  $result,
  $scale 
)

@dataProvider equalsData

Definition at line 87 of file ilMathTest.php.

88 {
89 $this->assertEquals($result, ilMath::_equals($a, $b, $scale));
90 }
static _equals($value1, $value2, $scale)

References $result, and ilMath\_equals().

+ Here is the call graph for this function:

◆ testGcd()

ilMathTest::testGcd (   $a,
  $b,
  $result 
)

@dataProvider gcdData

Definition at line 103 of file ilMathTest.php.

104 {
105 $this->assertEquals($result, ilMath::getGreatestCommonDivisor($a, $b));
106 }
static getGreatestCommonDivisor($a, $b)

References $result, and ilMath\getGreatestCommonDivisor().

+ Here is the call graph for this function:

◆ testMod()

ilMathTest::testMod (   $a,
  $b,
  $result 
)

@dataProvider modData

Definition at line 79 of file ilMathTest.php.

80 {
81 $this->assertEquals($result, ilMath::_mod($a, $b));
82 }
static _mod($left_operand, $modulus)

References $result, and ilMath\_mod().

+ Here is the call graph for this function:

◆ testMul()

ilMathTest::testMul (   $a,
  $b,
  $result,
  $scale 
)

@dataProvider mulData

Definition at line 47 of file ilMathTest.php.

48 {
49 $this->assertEquals($result, ilMath::_mul($a, $b, $scale));
50 }
static _mul($left_operand, $right_operand, $scale=50)

References $result, and ilMath\_mul().

+ Here is the call graph for this function:

◆ testPow()

ilMathTest::testPow (   $a,
  $b,
  $result,
  $scale 
)

@dataProvider powData

Definition at line 71 of file ilMathTest.php.

72 {
73 $this->assertEquals($result, ilMath::_pow($a, $b, $scale));
74 }
static _pow($left_operand, $right_operand, $scale=50)

References $result, and ilMath\_pow().

+ Here is the call graph for this function:

◆ testRound()

ilMathTest::testRound (   $a,
  $result,
  $scale 
)

@dataProvider roundData

Definition at line 95 of file ilMathTest.php.

96 {
97 $this->assertEquals($result, ilMath::_round($a, $scale));
98 }

References $result, and ilMath\_round().

+ Here is the call graph for this function:

◆ testSqrt()

ilMathTest::testSqrt (   $a,
  $result,
  $scale 
)

@dataProvider sqrtData

Definition at line 63 of file ilMathTest.php.

64 {
65 $this->assertEquals($result, ilMath::_sqrt($a, $scale));
66 }
static _sqrt($operand, $scale=50)

References $result, and ilMath\_sqrt().

+ Here is the call graph for this function:

◆ testSub()

ilMathTest::testSub (   $a,
  $b,
  $result,
  $scale 
)

@dataProvider subData

Definition at line 39 of file ilMathTest.php.

40 {
41 $this->assertEquals($result, ilMath::_sub($a, $b, $scale));
42 }
static _sub($left_operand, $right_operand, $scale=50)

References $result, and ilMath\_sub().

+ Here is the call graph for this function:

Field Documentation

◆ $eval_math

ilMathTest::$eval_math
protected

Definition at line 15 of file ilMathTest.php.

◆ DEFAULT_SCALE

const ilMathTest::DEFAULT_SCALE = '50'

Definition at line 10 of file ilMathTest.php.

Referenced by addData(), calcData(), divData(), equalsData(), mulData(), powData(), sqrtData(), and subData().


The documentation for this class was generated from the following file: