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

Public Member Functions

 assertComplexEquals ($expected, $actual, $delta=0)
 
 getErrorMessage ()
 

Private Attributes

 $_errorMessage = ''
 

Detailed Description

Definition at line 6 of file complexAssert.php.

Member Function Documentation

◆ assertComplexEquals()

complexAssert::assertComplexEquals (   $expected,
  $actual,
  $delta = 0 
)

Definition at line 10 of file complexAssert.php.

11  {
12  if ($expected{0} === '#') {
13  // Expecting an error, so we do a straight string comparison
14  if ($expected === $actual) {
15  return TRUE;
16  }
17  $this->_errorMessage = 'Expected Error: ' .
18  $actual . ' !== ' . $expected;
19  return FALSE;
20  }
21 
22  $expectedComplex = new Complex($expected);
23  $actualComplex = new Complex($actual);
24 
25  if (!is_numeric($actualComplex->getReal()) || !is_numeric($expectedComplex->getReal())) {
26  if ($actualComplex->getReal() !== $expectedComplex->getReal()) {
27  $this->_errorMessage = 'Mismatched String: ' .
28  $actualComplex->getReal() . ' !== ' . $expectedComplex->getReal();
29  return FALSE;
30  }
31  return TRUE;
32  }
33 
34  if ($actualComplex->getReal() < ($expectedComplex->getReal() - $delta) ||
35  $actualComplex->getReal() > ($expectedComplex->getReal() + $delta)) {
36  $this->_errorMessage = 'Mismatched Real part: ' .
37  $actualComplex->getReal() . ' != ' . $expectedComplex->getReal();
38  return FALSE;
39  }
40 
41  if ($actualComplex->getImaginary() < ($expectedComplex->getImaginary() - $delta) ||
42  $actualComplex->getImaginary() > ($expectedComplex->getImaginary() + $delta)) {
43  $this->_errorMessage = 'Mismatched Imaginary part: ' .
44  $actualComplex->getImaginary() . ' != ' . $expectedComplex->getImaginary();
45  return FALSE;
46  }
47 
48  if ($actualComplex->getSuffix() !== $actualComplex->getSuffix()) {
49  $this->_errorMessage = 'Mismatched Suffix: ' .
50  $actualComplex->getSuffix() . ' != ' . $expectedComplex->getSuffix();
51  return FALSE;
52  }
53 
54  return TRUE;
55  }

◆ getErrorMessage()

complexAssert::getErrorMessage ( )

Definition at line 58 of file complexAssert.php.

References $_errorMessage.

58  {
59  return $this->_errorMessage;
60  }

Field Documentation

◆ $_errorMessage

complexAssert::$_errorMessage = ''
private

Definition at line 8 of file complexAssert.php.

Referenced by getErrorMessage().


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