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.FloatingPointFixture | eer | |
given | result | notes |
3.14 | 3.14 | Uses character form to set precision |
3.143 | 3.14 | Should accept anything between 3.135 and 1.145 |
3.136 | 3.14 | |
3.13 | Fail[3.14] | Outside of range |
3.14 | 3.13 <= _ <= 3.15 | range expression |
3.14 | 3.13 ≤ _ ≤ 3.15 | math symbol for <= |
3.14 | 3.13 .. | numeric range cell handler does this one |
3.14 | 3.13 ≤ _ | open range |
3.14 | 3.13 < _ | |
3.14 | _ ≤ 3.15 | |
3.14 | _ < 3.15 | |
3.14 | 3.15 >= _ >= 3.13 | reversed range expression |
3.14 | 3.15 ≥ _ ≥ 3.13 | math symbol for >= |
3.12 | Fail[3.13 <= _ <= 3.15] | out of range |
3.14 | 3.13 +/- .02 | explicit epsilon |
3.14 | 3.13 ± .02 | math symbol for +/- |
3.14 | Fail[3.12 +/- .01] | out of range |
3.14 | Fail[3.12 ± .01] | |
exception[ValueError,,"fubar"] | 3.14 | invalid 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.FloatingPointFixture | fff | |
given | result | notes |
3.14 | exception[,"Check of single floating value prohibited by standards or application exit. See documentation for alternatives", "3.14"] | Implied epsilon |
3.12 | exception[,"Check of float with range expression prohibited by standards or application exit. See documentation for alternatives", "3.13 <= _ <= 3.15"] | range expression |
3.14 | exception[,"Check of float with epsilon expression prohibited by standards or application exit. See documentation for alternatives", "3.12 +/- .01"] | explicit epsilon |
3.14 | 3.13 .. | cell handler |