|
Boost Users : |
Subject: Re: [Boost-users] [boost.test] floating point comparison with user defined type
From: Raffi Enficiaud (raffi.enficiaud_at_[hidden])
Date: 2018-03-22 08:27:41
Le 20/03/2018 à 23:46, Georgios Sermaidis via Boost-users a écrit :
> Hello,
>
> I have created a class to represent the euro currency and I am trying to
> use boost.test to check if two euro amounts are sufficiently close. I
> was expecting the following to pass the test given the tolerance level I
> have set, but instead it fails.
> What is the proper way to compare two user-defined decimals? Thank you
> for your time.
>
[snip]
You have to advertise boost.test that your type can be compared using
tolerance. This is explained here:
Also your type should implement the tolerancecompatible concept:
http://www.boost.org/doc/libs/1_66_0/libs/test/doc/html/boost_test/testing_tools/extended_comparison/floating_point/customizing_for_tolerance.html#boost_test.testing_tools.extended_comparison.floating_point.customizing_for_tolerance.concept_tolerance_based
Best,
Raffi
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net