? unitsapi_add_assetswithin_0.patch Index: tests/unitsapi.test =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/unitsapi/tests/unitsapi.test,v retrieving revision 1.1 diff -u -p -r1.1 unitsapi.test --- tests/unitsapi.test 5 Jan 2009 21:02:00 -0000 1.1 +++ tests/unitsapi.test 6 Jan 2009 01:41:37 -0000 @@ -24,6 +24,21 @@ class UnitsAPIUnitTest extends DrupalWeb } /** + * Checks whether a certain value is within a custom range. + * + * @param $value + * The absolute value. + * @param $expected_value + * The expected value. + * @param $range + * The range of the expected value. + */ + function assertWithin($value, $expected_value, $range, $message = '', $group = t('other')) { + $within = ($expected - $range) <= $value <= ($expected_value + $range); + return $this->assert((bool) $within, $message ? $message : t('Value is TRUE'), $group); + } + + /** * Check to see if an unit conversion equals an expected value. * * @param $value @@ -127,4 +142,4 @@ class UnitsAPIUnitTest extends DrupalWeb $this->assertUnitConversion(3.5, 'day', 'minute', 5040, $group); $this->assertUnitConversion(20, 'year', 'hour', 175200, $group); } -} \ No newline at end of file +}