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)
 addData More...
 
 testSub ($a, $b, $result, $scale)
 subData More...
 
 testMul ($a, $b, $result, $scale)
 mulData More...
 
 testDiv ($a, $b, $result, $scale)
 divData More...
 
 testSqrt ($a, $result, $scale)
 sqrtData More...
 
 testPow ($a, $b, $result, $scale)
 powData More...
 
 testMod ($a, $b, $result)
 modData More...
 
 testEquals ($a, $b, $result, $scale)
 equalsData More...
 
 testRound ($a, $result, $scale)
 roundData More...
 
 testGcd ($a, $b, $result)
 gcdData More...
 
 testCalculation ($formula, $result, $scale)
 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  }

◆ 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  }

◆ 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  }

◆ 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  }

◆ 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  }

◆ 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  }

◆ 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  }

◆ 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  }

◆ testAdd()

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

addData

Definition at line 31 of file ilMathTest.php.

References $result, and ilMath\_add().

32  {
33  $this->assertEquals($result, ilMath::_add($a, $b, $scale));
34  }
$result
static _add($left_operand, $right_operand, $scale=50)
+ Here is the call graph for this function:

◆ testCalculation()

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

calcData

Definition at line 111 of file ilMathTest.php.

References $result, and ilMath\_round().

112  {
113  $this->assertEquals($result, ilMath::_round($this->eval_math->evaluate($formula), $scale));
114  }
$result
static _round($value, $precision=0)
+ Here is the call graph for this function:

◆ testDiv()

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

divData

Definition at line 55 of file ilMathTest.php.

References $result, and ilMath\_div().

56  {
57  $this->assertEquals($result, ilMath::_div($a, $b, $scale));
58  }
$result
static _div($left_operand, $right_operand, $scale=50)
+ Here is the call graph for this function:

◆ testEquals()

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

equalsData

Definition at line 87 of file ilMathTest.php.

References $result, and ilMath\_equals().

88  {
89  $this->assertEquals($result, ilMath::_equals($a, $b, $scale));
90  }
$result
static _equals($value1, $value2, $scale)
+ Here is the call graph for this function:

◆ testGcd()

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

gcdData

Definition at line 103 of file ilMathTest.php.

References $result, and ilMath\getGreatestCommonDivisor().

104  {
105  $this->assertEquals($result, ilMath::getGreatestCommonDivisor($a, $b));
106  }
$result
static getGreatestCommonDivisor($a, $b)
+ Here is the call graph for this function:

◆ testMod()

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

modData

Definition at line 79 of file ilMathTest.php.

References $result, and ilMath\_mod().

80  {
81  $this->assertEquals($result, ilMath::_mod($a, $b));
82  }
$result
static _mod($left_operand, $modulus)
+ Here is the call graph for this function:

◆ testMul()

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

mulData

Definition at line 47 of file ilMathTest.php.

References $result, and ilMath\_mul().

48  {
49  $this->assertEquals($result, ilMath::_mul($a, $b, $scale));
50  }
$result
static _mul($left_operand, $right_operand, $scale=50)
+ Here is the call graph for this function:

◆ testPow()

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

powData

Definition at line 71 of file ilMathTest.php.

References $result, and ilMath\_pow().

72  {
73  $this->assertEquals($result, ilMath::_pow($a, $b, $scale));
74  }
$result
static _pow($left_operand, $right_operand, $scale=50)
+ Here is the call graph for this function:

◆ testRound()

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

roundData

Definition at line 95 of file ilMathTest.php.

References $result, and ilMath\_round().

96  {
97  $this->assertEquals($result, ilMath::_round($a, $scale));
98  }
$result
static _round($value, $precision=0)
+ Here is the call graph for this function:

◆ testSqrt()

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

sqrtData

Definition at line 63 of file ilMathTest.php.

References $result, and ilMath\_sqrt().

64  {
65  $this->assertEquals($result, ilMath::_sqrt($a, $scale));
66  }
$result
static _sqrt($operand, $scale=50)
+ Here is the call graph for this function:

◆ testSub()

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

subData

Definition at line 39 of file ilMathTest.php.

References $result, and ilMath\_sub().

40  {
41  $this->assertEquals($result, ilMath::_sub($a, $b, $scale));
42  }
$result
static _sub($left_operand, $right_operand, $scale=50)
+ 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.


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