Floating Point Extensions

Python FIT has a number of extensions to the comparison function of the basic floating point type adapter. These include a feature that uses the actual character representation to set the precision, a range comparison and an epsilon (+/-) comparison.

fit.AccTestFixtures.FloatingPointFixtureeer
givenresultnotes
3.143.14Uses character form to set precision
3.1433.14Should accept anything between 3.135 and 1.145
3.1363.14 
3.13Fail[3.14]Outside of range
3.143.13 <= _ <= 3.15range expression
3.143.13 ≤ _ ≤ 3.15math symbol for <=
3.143.13 ..numeric range cell handler does this one
3.143.13 ≤ _ open range
3.143.13 < _  
3.14_ ≤ 3.15 
3.14_ < 3.15 
3.143.15 >= _ >= 3.13reversed range expression
3.143.15 ≥ _ ≥ 3.13math symbol for >=
3.12Fail[3.13 <= _ <= 3.15]out of range
3.143.13 +/- .02explicit epsilon
3.143.13 ± .02math symbol for +/-
3.14Fail[3.12 +/- .01]out of range
3.14Fail[3.12 ± .01] 
exception[ValueError,,"fubar"]3.14invalid input

It is also possible to completely disable the use of the standard floating point type adapter for a calculated result, which puts the responsibility on either the fixture or on an application value object. The latter approach is strongly recommended in any case.

fit.AccTestFixtures.FloatingPointFixturefff
givenresultnotes
3.14exception[,"Check of single floating value prohibited by standards or application exit. See documentation for alternatives", "3.14"]Implied epsilon
3.12exception[,"Check of float with range expression prohibited by standards or application exit. See documentation for alternatives", "3.13 <= _ <= 3.15"]range expression
3.14exception[,"Check of float with epsilon expression prohibited by standards or application exit. See documentation for alternatives", "3.12 +/- .01"]explicit epsilon
3.143.13 ..cell handler