Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
JUnit and float values
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mat Gessel  
View profile  
 More options Aug 14 2006, 3:54 pm
From: "Mat Gessel" <mat.ges...@gmail.com>
Date: Mon, 14 Aug 2006 12:54:28 -0700
Local: Mon, Aug 14 2006 3:54 pm
Subject: JUnit and float values
This bug still exists in 1.1:
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/threa...

Consider passing the following values to assertEquals:
0.0, 0.0, 0.0 (false failure)
1.0, 2.0, 0.1 (false pass)
-1.0, -2.0, 0.1 (false pass)

Assert super-source:

  static public void assertEquals(String str, float obj1, float obj2,
float delta) {
    if (obj1 - obj2 < delta || obj2 - obj1 < delta) {
      return;
    } else {
      fail(str + " expected=" + obj1 + " actual=" + obj2 + " delta=" + delta);
    }
  }

I suggested a better implementation in the linked post.

--
Mat Gessel
http://www.asquare.net


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Scott Blum  
View profile  
 More options Aug 14 2006, 7:07 pm
From: "Scott Blum" <sco...@google.com>
Date: Mon, 14 Aug 2006 16:07:36 -0700
Local: Mon, Aug 14 2006 7:07 pm
Subject: Re: JUnit and float values
Wish I hadn't missed the thread you linked!  Good catch.

--Scott


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mat Gessel  
View profile  
 More options Aug 15 2006, 3:15 pm
From: "Mat Gessel" <mat.ges...@gmail.com>
Date: Tue, 15 Aug 2006 12:15:58 -0700
Local: Tues, Aug 15 2006 3:15 pm
Subject: Re: JUnit and float values

The fix I previously suggested was flawed as well. A corrected version
is attached, along with a test case.

-= Mat

--
Mat Gessel
http://www.asquare.net

On 8/14/06, Scott Blum <sco...@google.com> wrote:

  JUnitTC.java
2K Download

  Assert.java
6K Download

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Konstantin Scheglov  
View profile  
 More options Aug 15 2006, 3:20 pm
From: "Konstantin Scheglov" <Konstantin.Scheg...@gmail.com>
Date: Tue, 15 Aug 2006 19:20:38 -0000
Local: Tues, Aug 15 2006 3:20 pm
Subject: Re: JUnit and float values

Scott Blum wrote:
> Wish I hadn't missed the thread you linked!  Good catch.

  Setup public Bugzilla and you will not lost bug reports from users.

  In Eclipse newsgroups developers always tell us, users - don't post
bug reports in newsgroup, we can just forget about them, post them in
bugzilla and we will find them.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Scott Blum  
View profile  
 More options Aug 15 2006, 3:32 pm
From: "Scott Blum" <sco...@google.com>
Date: Tue, 15 Aug 2006 12:32:49 -0700
Local: Tues, Aug 15 2006 3:32 pm
Subject: Re: JUnit and float values
Nice work, Mat.

I'm incorporating your test case into an existing on.  Your fix looks
good except I think that should be a "<= delta" instead of a "< delta".

This is the code I think I'm going to commit:

  static public void assertEquals(String str, double obj1, double obj2,
      double delta) {
    if (obj1 == obj2) {
      return;
    } else if (Math.abs(obj1 - obj2) <= delta) {
      return;
    } else {
      fail(str + " expected=" + obj1 + " actual=" + obj2 + " delta=" +
delta);
    }
  }

  static public void assertEquals(String str, float obj1, float obj2,
      float delta) {
    if (obj1 == obj2) {
      return;
    } else if (Math.abs(obj1 - obj2) <= delta) {
      return;
    } else {
      fail(str + " expected=" + obj1 + " actual=" + obj2 + " delta=" +
delta);
    }
  }

--Scott


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google