mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-27 07:46:04 +03:00
7429a98174
git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@85691 2327b42d-5241-43d6-9e2a-de5ac946f064
53 lines
1.7 KiB
PHP
53 lines
1.7 KiB
PHP
<?php
|
|
|
|
include_once __DIR__.'/Complex.php';
|
|
|
|
|
|
class complexAssert {
|
|
|
|
private $_errorMessage = '';
|
|
|
|
public function assertComplexEquals($expected, $actual, $delta = 0)
|
|
{
|
|
$expectedComplex = new Complex($expected);
|
|
$actualComplex = new Complex($actual);
|
|
|
|
if (!is_numeric($actualComplex->getReal()) || !is_numeric($expectedComplex->getReal())) {
|
|
if ($actualComplex->getReal() !== $expectedComplex->getReal()) {
|
|
$this->_errorMessage = 'Mismatched String: ' .
|
|
$actualComplex->getReal() . ' !== ' . $expectedComplex->getReal();
|
|
return FALSE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
if ($actualComplex->getReal() < ($expectedComplex->getReal() - $delta) ||
|
|
$actualComplex->getReal() > ($expectedComplex->getReal() + $delta)) {
|
|
$this->_errorMessage = 'Mismatched Real part: ' .
|
|
$actualComplex->getReal() . ' != ' . $expectedComplex->getReal();
|
|
return FALSE;
|
|
}
|
|
|
|
if ($actualComplex->getImaginary() < ($expectedComplex->getImaginary() - $delta) ||
|
|
$actualComplex->getImaginary() > ($expectedComplex->getImaginary() + $delta)) {
|
|
$this->_errorMessage = 'Mismatched Imaginary part: ' .
|
|
$actualComplex->getImaginary() . ' != ' . $expectedComplex->getImaginary();
|
|
return FALSE;
|
|
}
|
|
|
|
if ($actualComplex->getSuffix() !== $actualComplex->getSuffix()) {
|
|
$this->_errorMessage = 'Mismatched Suffix: ' .
|
|
$actualComplex->getSuffix() . ' != ' . $expectedComplex->getSuffix();
|
|
return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
public function getErrorMessage() {
|
|
return $this->_errorMessage;
|
|
}
|
|
|
|
}
|