Re: Getting a handle on inf
Re: Getting a handle on inf
- Subject: Re: Getting a handle on inf
- From: Ken Thomases <email@hidden>
- Date: Mon, 26 Oct 2009 14:46:26 -0500
On Oct 26, 2009, at 2:11 PM, Ian Piper wrote:
On 26 Oct 2009, at 18:45, Greg Parker wrote:
On Oct 26, 2009, at 11:26 AM, Ian Piper wrote:
So I am guessing that when I get a float displayed as "inf" this
is not the string it seems to be. Also, it looks like the string
value of whatever is coming back is not something that I can use.
Can anyone suggest how I might handle a test case like this?
As Kyle noted, -stringValue returns an NSString, not a char*. You'd
need to compare to @"inf" and print with %@.
Kyle, Greg,
Thanks for that. I tried it out:
- (void)testVeryLargeNumberShouldReturnInf {
testConverter = Converter.new;
[testConverter setValue:[NSNumber numberWithFloat:
1000000000000000000000000000000000000000.0] forKey:@"originalTemp"];
NSNumber *newTemperatureInF = [NSNumber numberWithFloat:(float)
[testConverter convertCToF]];
STAssertEquals(@"inf", [newTemperatureInF stringValue], @"Expecting
inf; we got %@", [newTemperatureInF stringValue]);
You want STAssertEqualObjects, here. You want to compare for equal
value, not identity, which is what STAssertEquals does.
[testConverter release];
}
...and I still get a failed build with this message:
Expecting inf; we got inf
Which seems odd. When I look at the transcript for the test result
it looks like this:
TCTests.m:58: error: -[TCTests testVeryLargeNumberShouldReturnInf] :
'<28810c00 01000000>' should be equal to '<c08a1800 01000000>':
Expecting inf; we got inf
So I am still not comparing apples with apples...
Cheers,
Ken
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden