Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.98
diff -u -r1.98 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	25 Apr 2009 22:35:49 -0000	1.98
+++ modules/simpletest/drupal_web_test_case.php	28 Apr 2009 03:35:49 -0000
@@ -353,6 +353,70 @@
   }
 
   /**
+   * Check to see if the positive difference is less than $margin.
+   *
+   * More specifically:
+   * @code
+   *   abs($first - $second) < $margin
+   * @endcode
+   *
+   * This function is especially useful when you want to test a floating point
+   * value, since exact floating point comparison seldom works.
+   *
+   * @param $first
+   *   The first value.
+   * @param $second
+   *   The second value.
+   * @param $margin
+   *   The maximum allowed absolute difference between $first and $second.
+   * @param $message
+   *   The message to display along with the assertion.
+   * @param $group
+   *   The type of assertion - examples are "Browser", "PHP".
+   * @return
+   *   The status passed in.
+   */
+  protected function assertWithinMargin($first, $second, $margin, $message = '', $group = 'Other') {
+    return $this->assert(
+      abs($first - $second) < $margin,
+      $message ? $message : t('The positive difference between @first and @second value is less than the @margin', array('@first' => $first, '@second' => $second, '@margin' => $margin)),
+      $group
+    );
+  }
+
+  /**
+   * Check to see if the positive difference is more than $margin.
+   *
+   * More specifically:
+   * @code
+   *   abs($first - $second) > $margin
+   * @endcode
+   *
+   * This function is especially useful when you want to test a floating point
+   * value, since exact floating point comparison seldom works.
+   *
+   * @param $first
+   *   The first value.
+   * @param $second
+   *   The second value.
+   * @param $margin
+   *   The minimum allowed absolute difference between $first and $second.
+   * @param $message
+   *   The message to display along with the assertion.
+   * @param $group
+   *   The type of assertion - examples are "Browser", "PHP".
+   * @return
+   *   The status passed in.
+   */
+  protected function assertOutsideMargin($first, $second, $margin, $message = '', $group = 'Other') {
+    return $this->assert(
+      abs($first - $second) > $margin,
+      $message ? $message : t('The positive difference between @first and @second value is greater than the @margin', array('@first' => $first, '@second' => $second, '@margin' => $margin)),
+      $group
+    );
+  }
+
+  /**
    * Fire an assertion that is always positive.
    *
    * @param $message
Index: modules/simpletest/simpletest.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.test,v
retrieving revision 1.18
diff -u -r1.18 simpletest.test
--- modules/simpletest/simpletest.test	27 Apr 2009 07:44:09 -0000	1.18
+++ modules/simpletest/simpletest.test	28 Apr 2009 03:35:49 -0000
@@ -108,6 +108,12 @@
     $this->pass($this->pass);
     $this->fail($this->fail);
 
+    $this->assertWithinMargin(5, 10, 6);
+    $this->assertWithinMargin(5, 10, 4);
+
+    $this->assertOutsideMargin(5, 10, 6);
+    $this->assertOutsideMargin(5, 10, 4);
+
     $this->drupalCreateUser(array($this->valid_permission));
     $this->drupalCreateUser(array($this->invalid_permission));
 
@@ -137,6 +143,24 @@
     $this->assertAssertion($this->pass, 'Other', 'Pass', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()');
     $this->assertAssertion($this->fail, 'Other', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()');
 
+    $this->assertAssertion(
+      t('The positive difference between @first and @second value is less than the @margin', array('@first' => 5, '@second' => 10, '@margin' => 6)),
+      'Other', 'Pass', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()'
+    );
+    $this->assertAssertion(
+      t('The positive difference between @first and @second value is less than the @margin', array('@first' => 5, '@second' => 10, '@margin' => 4)),
+      'Other', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()'
+    );
+
+    $this->assertAssertion(
+      t('The positive difference between @first and @second value is greater than the @margin', array('@first' => 5, '@second' => 10, '@margin' => 6)),
+      'Other', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()'
+    );
+    $this->assertAssertion(
+      t('The positive difference between @first and @second value is greater than the @margin', array('@first' => 5, '@second' => 10, '@margin' => 4)),
+      'Other', 'Pass', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()'
+    );
+
     $this->assertAssertion(t('Created permissions: @perms', array('@perms' => $this->valid_permission)), 'Role', 'Pass', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()');
     $this->assertAssertion(t('Invalid permission %permission.', array('%permission' => $this->invalid_permission)), 'Role', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()');
 
