You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The (temporary) tests_catch/ directory contains the converted tests from boost to catch. This is currently a work in progress.
I've converted about a third of the tests and came up with the following conversion rules. I'm not sure whether these are completely correct, so it would be useful to check these.
BOOST_AUTO_TEST_SUITE(blah) -> delete, but "blah" is used as the second argument to all instances of TEST_CASE() within a given file
BOOST_AUTO_TEST_SUITE_END() -> delete
BOOST_AUTO_TEST_CASE(testname) -> TEST_CASE("testname", "[blah]")
following the examples given in the Catch2 tutorial
BOOST_REQUIRE_SMALL(x, 0.015) -> REQUIRE(x == Approx(0.0).margin(0.015))
as per the docs for Catch2 assertion macros; not sure whether this is the best or even the correct approach
BOOST_REQUIRE_CLOSE(x, 1.23, 0.15) -> REQUIRE(result == Approx(1.23).epsilon(0.0015))
Boost uses the "0.15" to express 0.15%. I'm not certain on the Catch2 equivalent expression. I've followed the example in the docs for assertion macros, which uses .epsilon(0.01) to express a 1% difference. The Catch2 docs appear unclear on the exact meaning of .epsilon(val): "epsilon serves to set the coefficient by which a result can differ from Approx's value before it is rejected." Coefficient of what?
I guess you could also write REQUIRE(std::abs(x) <= 0.015), but I think it makes sense to check against the plain output (x ).
The rest looks reasonable to me, as I understand the doc REQUIRE(result == Approx(1.23).epsilon(0.0015)) is the equivalent of BOOST_REQUIRE_CLOSE(x, 1.23, 0.15), worked on a couple of examples.
The REQUIRE(std::abs(x) <= 0.015) form is certainly more compact. However, std::abs() only works for signed types. Using size_t or arma::uword wouldn't work. From what I have seen in the current tests, not all of the values that are checked are floats. Probably a minor issue, but it would be easier not to worry about these special cases by simply being consistent with the use of the REQUIRE(x == Approx(0.0).margin(0.015)) form.
The (temporary)
tests_catch/
directory contains the converted tests from boost to catch. This is currently a work in progress.I've converted about a third of the tests and came up with the following conversion rules. I'm not sure whether these are completely correct, so it would be useful to check these.
BOOST_AUTO_TEST_SUITE(blah)
-> delete, but "blah" is used as the second argument to all instances ofTEST_CASE()
within a given fileBOOST_AUTO_TEST_SUITE_END()
-> deleteBOOST_AUTO_TEST_CASE(testname)
->TEST_CASE("testname", "[blah]")
following the examples given in the Catch2 tutorial
BOOST_REQUIRE_SMALL(x, 0.015)
->REQUIRE(x == Approx(0.0).margin(0.015))
as per the docs for Catch2 assertion macros; not sure whether this is the best or even the correct approach
BOOST_REQUIRE_CLOSE(x, 1.23, 0.15)
->REQUIRE(result == Approx(1.23).epsilon(0.0015))
Boost uses the "0.15" to express 0.15%. I'm not certain on the Catch2 equivalent expression. I've followed the example in the docs for assertion macros, which uses
.epsilon(0.01)
to express a 1% difference. The Catch2 docs appear unclear on the exact meaning of.epsilon(val)
: "epsilon serves to set the coefficient by which a result can differ from Approx's value before it is rejected." Coefficient of what?BOOST_REQUIRE_EQUAL(i, 123)
->REQUIRE(i == 123)
BOOST_REQUIRE_GT(x, 0.05)
->REQUIRE(x > 0.05)
BOOST_REQUIRE_GE(x, 0.05)
->REQUIRE(x >= 0.05)
BOOST_REQUIRE_LT(x, 0.05)
->REQUIRE(x < 0.05)
BOOST_REQUIRE_LE(x, 0.05)
->REQUIRE(x <= 0.05)
The text was updated successfully, but these errors were encountered: