Hi
I'm writing a simple converter between Celcius and Farhenheit as an
example to start programming.
Converter >> convertFarhenheit: anInteger
^ ((anInteger - 32) / 1.8)
ConverterTest >> testFToC
| converter |
converter := TemperatureConverter new.
self assert: ((converter convertFarhenheit: 86) = 30.0).
self assert: ((converter convertFarhenheit: 50) = 10).
self assert: ((converter convertFarhenheit: 52) = 11.11111111111111)
My problem is with ((converter convertFarhenheit: 52) = 11.11111111111111)
I do not want to have such ugly test.
I tried either to control the output
Converter >> convertFarhenheit: anInteger
^ ((anInteger - 32) / 1.8) roundDownTo: 0.1
Not a good idea
Or to compare with closeTo:
self assert: ((converter convertFarhenheit: 52) closeTo: 11.11)
does not work because we cannot set the precision.
So at ESUG I briefly discuss that with Nicolas Cellier and I need help.
Should I introduce in pharo closeTo:interval:
Any suggestions that a newby can understand is welcome.
Stef