Closed
Description
Some of my libraries use float math and errors add up when doing a lot of float math.
e.g https://github.com/RobTillaart/AverageAngle/runs/1543777648?check_suite_focus=true
To test for equality for a float output I typically use the following working construct
fprintf(stderr, "getTotalLength()\n");
float diff = abs(10 - aa.getTotalLength());
assertMoreOrEqual(0.2, diff);
however I would prefer a oneliner
AssertEqualFloat(10, aa.getTotalLength(), 0.2);
output should be something like one of the three
AssertEqualFloat 10 == aa.getTotalLength() +- 0.2
AssertEqualFloat 10 +- 0.2 == aa.getTotalLength()
AssertEqualFloat 10- 0.2 < aa.getTotalLength() < 10 + 0.2
Maybe it should be called AssertAlmostEqual(...)
Thanks,