Hello Gavin, thanks for your response. On Mon, May 8, 2017 at 4:17 AM, Gavin Lambert via Boost-users < boost-users@lists.boost.org> wrote:
I don't know if there is a better way to do this within the confines of Boost.Test itself (perhaps making a custom macro, or extending what the macro already does in some way),
I was suspecting this, just wanted to clarify. I guess I will create my own wrappers then.
but there *is* a better way to get basic values out of unit quantities rather than using .value().
Instead of:
BOOST_CHECK_CLOSE(X(v).value(), 42.0, 0.001);
Try:
BOOST_CHECK_CLOSE(X(v) / meters, 42.0, 0.001);
(You might also need an explicit static_cast<double>. If so, you might want to wrap this whole thing in a helper method to reduce typing.)
OK, this is a bit of surprise. This "X(v) / meters" obviously means "I want the value in meters"? Actually I spent quite some time trying to figure that exact thing out and I just couldn't find it in the docs. I have just tried it and it works. Great, that's at least a way to make things explicit and helps. Thanks, Stephan