How to validate number is within range of a number : General Questions

How to validate number is within range of a number

Ask general questions here.

How to validate number is within range of a number

Postby Gunner1980 » Sat May 29, 2010 9:42 pm

So I already have code working to validate an int but the problem is that the number is going to be slightly different than what is entered everytime. When I validate I need to validate the value within a range not the exact value. For example when I enter a value of 15750 I may receive it as 15759 on the validation side. This is due to various rounding methods that happen in our system and is correct so I don't want this to show up as a failure in my tests. I would like to validate that the altitude equals 15750 plus or minus 25. So basically if 15750 was entered everything from 15725 to 15775 would pass the test.

Can anyone help me out please?
User avatar
Gunner1980
 
Posts: 89
Joined: Mon Apr 05, 2010 9:44 pm
Location: Austin, Texas

Re: How to validate number is within range of a number

Postby Support Team » Mon May 31, 2010 12:40 pm

Hi,
Gunner1980 wrote:I would like to validate that the altitude equals 15750 plus or minus 25. So basically if 15750 was entered everything from 15725 to 15775 would pass the test.

Use the Validate.IsTrue() method to check if the value is inside your range.
Validate.IsTrue( (value > x - 25) && (value < x + 25) );

Regards,
Peter
Ranorex Support Team
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: How to validate number is within range of a number

Postby Gunner1980 » Tue Jun 01, 2010 8:27 pm

Thanks that worked like a champ!
User avatar
Gunner1980
 
Posts: 89
Joined: Mon Apr 05, 2010 9:44 pm
Location: Austin, Texas


Return to General Questions

Who is online

Users browsing this forum: No registered users and 0 guests