testthat
testthat copied to clipboard
expect_equals sometimes reports incorrect values when values are not equal
The values reported by expect_equal for actual and expected in the case of a test failure are occasionally rounded in incorrect/inconsistent ways. It appears to be an edge case activated by 0.5 values. Example:
> expect_equal(c(8.5, 9.5), c(1.5, 2.5))
Error: c(8.5, 9.5) (`actual`) not equal to c(1.5, 2.5) (`expected`).
`actual`: 8 10
`expected`: 2 2
Note the reported values for actual and expected.
Unless there is a desire to keep the formatting as it is, I would be happy to try and address this by refactoring the sprintf formatting?
This is fixed in the dev version of waldo (which I plan to release to CRAN soon). Now you'll see:
`actual`: 8.5 9.5
`expected`: 1.5 2.5
I'll leave this issue open as a reminder to myself to bump the required waldo version in testthat.