You are here

function ArrayWithinMarginExpectation::ArrayWithinMarginExpectation in Location 5.3

Sets the values to compare against and the fuzziness of the match. Used for comparing floating point values.

Parameters

mixed $arr Array of test values to match.: @param mixed $margin Fuzziness of match. @param string $message Customised message on failure. @access public

File

tests/location_test_case.php, line 23
Location specific assertions.

Class

ArrayWithinMarginExpectation
Test each element of an array for being within a range.

Code

function ArrayWithinMarginExpectation($arr, $margin = 0.01, $message = '%s') {
  $this
    ->SimpleExpectation($message);
  foreach ($arr as $k => $v) {
    $this->_upper[$k] = $v + $margin;
    $this->_lower[$k] = $v - $margin;
  }
  $this->_canonicalvalues = $arr;
  $this->_margin = $margin;
}