Formatting for crash exit BOOST_CHECK_CLOSE?

I am adding tests to legacy code using the boost test environment.

One such test might be

double expectedPrice = /*...local computation*/
BOOST_CHECK_CLOSE(expectedPrice, object->price, ACCURACY_THRESHOLD);

Where expectedPrice is double computed locally and the object is retrieved from the system under test.

error in "MyTest": difference{0.21097%} between expectedPrice{4.7300000000000004} and object->price{4.7400000000000002} exceeds 1.0000000000000001e-05%

Of course, it's a little hard to read, given all the decimal numbers. Is there any way to get the test result formatted better / in different ways, given that I use bare doubles and not some other type?

+3
source share
2 answers

This is a known issue. With a famous solution. It is just a little difficult to implement, although I still hope to do it at some point. Meanwhile, you are stuck with what your iostream library produces.

0

:

cout < setprecision (2)

0

Source: https://habr.com/ru/post/1778383/


All Articles