Home > Net >  Setting a test-wide tolerance with BOOST_DATA_TEST_CASE_F
Setting a test-wide tolerance with BOOST_DATA_TEST_CASE_F

Time:09-20

Within a BOOST_FIXTURE_TEST_CASE, you can set a tolerance for all BOOST_TEST calls like so:

BOOST_FIXTURE_TEST_CASE(Testname, SomeFixture, *utf::tolerance(.01))

However, I cannot find a way to make this work with BOOST_DATA_TEST_CASE_F.

From Boost:

BOOST_DATA_TEST_CASE_F(my_fixture, test_case_name, dataset, var1, var2..., varN)

I've tried the obvious

BOOST_DATA_TEST_CASE_F(my_fixture, test_case_name, dataset, var1, var2..., varN, *utf::tolerance(.01))

but to no avail. It seems to me like it's just not supported.

Does anyone have any ideas on how to replicate similar behavior without having to specify a tolerance within every single BOOST_TEST call within a BOOST_DATA_TEST_CASE_F?

I am using version 1.72.

CodePudding user response:

I don't see a way to do that, but you can set the tolerance in a BOOST_AUTO_TEST_SUITE(), and you can have as many of those suites as you want. So:

BOOST_AUTO_TEST_SUITE(suite1, *utf::tolerance(.01))
    BOOST_DATA_TEST_CASE_F(my_fixture, test_case_name, dataset, var1, var2..., varN)
BOOST_AUTO_TEST_SUITE_END()

Repeat as necessary.

  • Related