ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilMathBaseAdapterTest Class Reference
+ Inheritance diagram for ilMathBaseAdapterTest:
+ Collaboration diagram for ilMathBaseAdapterTest:

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...
 
 testCalculation ($formula, $result, $scale)
 calcData More...
 
 testDivisionsByZero ()
 
 testModuloByZero ()
 
 addData ()
 
 subData ()
 
 mulData ()
 
 divData ()
 
 modData ()
 
 sqrtData ()
 
 powData ()
 
 equalsData ()
 
 calcData ()
 

Data Fields

const DEFAULT_SCALE = 50
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $mathAdapter
 
 $evalMath
 

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 ilMathBaseAdapterTest.php.

Member Function Documentation

◆ addData()

ilMathBaseAdapterTest::addData ( )
Returns
array

Definition at line 130 of file ilMathBaseAdapterTest.php.

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

◆ calcData()

ilMathBaseAdapterTest::calcData ( )

Definition at line 216 of file ilMathBaseAdapterTest.php.

217  {
218  return [
219  ['3+5', '8', self::DEFAULT_SCALE],
220  ['-3+5', '2', self::DEFAULT_SCALE],
221  ['3*6+5', '23', self::DEFAULT_SCALE],
222  ['10/2', '5', self::DEFAULT_SCALE],
223  ['13/60', '0.2166666666666', 13],
224  ['(-(-8)-sqrt((-8)^2-4*(7)))/(2)', '1', self::DEFAULT_SCALE],
225  ['(-(-8)+sqrt((-8)^2-4*(7)))/(2)', '7', self::DEFAULT_SCALE],
226  ['(-(-41)-sqrt((-41)^2-4*(1)*(5)))/(2*(1))', '0.122', 3],
227  ['(-(-41)+sqrt((-41)^2-4*(1)*(5)))/(2*(1))', '40.877', 3],
228  ['4^2-2*4+0.5*-16', '0', self::DEFAULT_SCALE],
229  ['-2^2-2*-2+0.5*-16', '-8', self::DEFAULT_SCALE]
230  ];
231  }

◆ divData()

ilMathBaseAdapterTest::divData ( )
Returns
array

Definition at line 161 of file ilMathBaseAdapterTest.php.

162  {
163  return [
164  ['1', '2', '0.5', self::DEFAULT_SCALE],
165  ['', '2', '0', self::DEFAULT_SCALE],
166  ];
167  }

◆ equalsData()

ilMathBaseAdapterTest::equalsData ( )
Returns
array

Definition at line 205 of file ilMathBaseAdapterTest.php.

206  {
207  return [
208  ['3', '3', true, null],
209  ['27.424', '27.424', true, 5]
210  ];
211  }

◆ modData()

ilMathBaseAdapterTest::modData ( )
Returns
array

Definition at line 172 of file ilMathBaseAdapterTest.php.

173  {
174  return [
175  ['1', '2', '1']
176  ];
177  }

◆ mulData()

ilMathBaseAdapterTest::mulData ( )
Returns
array

Definition at line 150 of file ilMathBaseAdapterTest.php.

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

◆ powData()

ilMathBaseAdapterTest::powData ( )
Returns
array

Definition at line 195 of file ilMathBaseAdapterTest.php.

196  {
197  return [
198  ['3', '2', '9', self::DEFAULT_SCALE]
199  ];
200  }

◆ setUp()

ilMathBaseAdapterTest::setUp ( )
protected

Definition at line 25 of file ilMathBaseAdapterTest.php.

References ilMath\setDefaultAdapter().

26  {
27  require_once 'Services/Math/classes/class.ilMath.php';
28  require_once 'Services/Math/classes/class.EvalMath.php';
29 
30  ilMath::setDefaultAdapter($this->mathAdapter);
31  $this->evalMath = new EvalMath();
32  parent::setUp();
33  }
static setDefaultAdapter(ilMathAdapter $adapter)
+ Here is the call graph for this function:

◆ sqrtData()

ilMathBaseAdapterTest::sqrtData ( )
Returns
array

Definition at line 182 of file ilMathBaseAdapterTest.php.

183  {
184  return [
185  ['9', '3', self::DEFAULT_SCALE],
186  ['4294967296', '65536', self::DEFAULT_SCALE],
187  ['12345678901234567890', '3513641828', null],
188  ['12345678901234567890', '3513641828.82', 2]
189  ];
190  }

◆ subData()

ilMathBaseAdapterTest::subData ( )
Returns
array

Definition at line 140 of file ilMathBaseAdapterTest.php.

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

◆ testAdd()

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

addData

Definition at line 38 of file ilMathBaseAdapterTest.php.

References $result.

39  {
40  $this->assertEquals($result, $this->mathAdapter->add($a, $b, $scale));
41  }
$result

◆ testCalculation()

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

calcData

Definition at line 102 of file ilMathBaseAdapterTest.php.

References $result.

103  {
104  $this->assertEquals($result, ilMath::_applyScale($this->evalMath->evaluate($formula), $scale));
105  }
$result

◆ testDiv()

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

divData

Definition at line 62 of file ilMathBaseAdapterTest.php.

References $result.

63  {
64  $this->assertEquals($result, $this->mathAdapter->div($a, $b, $scale));
65  }
$result

◆ testDivisionsByZero()

ilMathBaseAdapterTest::testDivisionsByZero ( )

Definition at line 110 of file ilMathBaseAdapterTest.php.

111  {
112  $this->setExpectedException(ilMathDivisionByZeroException::class);
113 
114  $this->mathAdapter->div(1, 0);
115  }

◆ testEquals()

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

equalsData

Definition at line 94 of file ilMathBaseAdapterTest.php.

References $result.

95  {
96  $this->assertEquals($result, $this->mathAdapter->equals($a, $b, $scale));
97  }
$result

◆ testMod()

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

modData

Definition at line 86 of file ilMathBaseAdapterTest.php.

References $result.

87  {
88  $this->assertEquals($result, $this->mathAdapter->mod($a, $b));
89  }
$result

◆ testModuloByZero()

ilMathBaseAdapterTest::testModuloByZero ( )

Definition at line 120 of file ilMathBaseAdapterTest.php.

121  {
122  $this->setExpectedException(ilMathDivisionByZeroException::class);
123 
124  $this->mathAdapter->mod(1, 0);
125  }

◆ testMul()

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

mulData

Definition at line 54 of file ilMathBaseAdapterTest.php.

References $result.

55  {
56  $this->assertEquals($result, $this->mathAdapter->mul($a, $b, $scale));
57  }
$result

◆ testPow()

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

powData

Definition at line 78 of file ilMathBaseAdapterTest.php.

References $result.

79  {
80  $this->assertEquals($result, $this->mathAdapter->pow($a, $b, $scale));
81  }
$result

◆ testSqrt()

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

sqrtData

Definition at line 70 of file ilMathBaseAdapterTest.php.

References $result.

71  {
72  $this->assertEquals($result, $this->mathAdapter->sqrt($a, $scale));
73  }
$result

◆ testSub()

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

subData

Definition at line 46 of file ilMathBaseAdapterTest.php.

References $result.

47  {
48  $this->assertEquals($result, $this->mathAdapter->sub($a, $b, $scale));
49  }
$result

Field Documentation

◆ $evalMath

ilMathBaseAdapterTest::$evalMath
protected

Definition at line 20 of file ilMathBaseAdapterTest.php.

◆ $mathAdapter

ilMathBaseAdapterTest::$mathAdapter
protected

Definition at line 15 of file ilMathBaseAdapterTest.php.

◆ DEFAULT_SCALE

const ilMathBaseAdapterTest::DEFAULT_SCALE = 50

Definition at line 10 of file ilMathBaseAdapterTest.php.


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