Hi all,
Following up on my query about unit tests yesterday... I am writing another test checking boundary conditions for a calculation. In the normal running program I am feeding a very large number (1000000000000000000000000000000000000000) into one text field and the result displayed in the other text field is "inf". I want to write a test to explore this, so I did this:
- (void)testVeryLargeNumberShouldReturnInf { testConverter = Converter.new; [testConverter setValue:[NSNumber numberWithFloat:1000000000000000000000000000000000000000.0] forKey:@"originalTemp"]; NSNumber *newTemperatureInC = [NSNumber numberWithFloat:(float)[testConverter convertFToC]]; STAssertEquals("inf", [newTemperatureInC floatValue], @"Expecting inf; we got %f", [newTemperatureInC floatValue]); [testTempConverter release]; }
When I run this test I see this message: Expecting inf; we got inf
I tried this:
STAssertEquals("inf", [newTemperatureInC stringValue], @"Expecting inf; we got %s", [newTemperatureInC stringValue]);
and saw this message: Expecting inf; we got ¿√Ωpˇ
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?
Thanks,
Ian. -- |