martinmoene / lest

A modern, C++11-native, single-file header-only, tiny framework for unit-tests, TDD and BDD (includes C++98 variant)
Boost Software License 1.0
390 stars 45 forks source link

Regarding double precision #22

Closed MariusDe closed 8 years ago

MariusDe commented 8 years ago

Hi, this is rather a beginner's question :) (If there is a forum or something similar, let me know and I'll repost this.)

When using EVALUATE() on doubles like below:

double x = 0.1234567891;
double y = 0.9876543219;
EXPECT(x == y);

the precision seems to not be entirely displayed:

test.cpp:11: failed: 2 Module test: x == y for 0.123457 == 0.987654

Is there a way to configure the displayed precision for double values or display (by default) the relevant precision?

Cheers, Marius

martinmoene commented 8 years ago

Hi Marius,

I don't think there's a way to influence doubles display precision. You'd normally use lest::approx to compare floating point numbers.

cheers, Martin

MariusDe commented 8 years ago

Thanks, Martin! I see now that there is a way to report the user's type. So I can consider this in the future. Nonetheless, having default support for double (for lest::aprox and reporting) I consider to be useful. From my side, you may close this issue. Cheers, Marius