void assert_within(uint16_t expected, uint16_t actual, uint16_t tolerance, const char* text)
{
char buf[64];
if(abs(expected-actual) > tolerance) {
snprintf(buf, ARRAY_SIZE(buf), "%s outside tolerance, expected within %d of %d, got %d", text, tolerance, expected, actual);
FAIL_TEXT_C(buf);
}
}
It would be nice for within, or less/greater than to be native cpputest assertions
On a few occasions I've written functions like:
It would be nice for within, or less/greater than to be native cpputest assertions