如何将Boost测试与Boost装置一起使用

时间:2015-06-25 21:12:22

标签: c++ boost boost-test boost-units

我希望这能正确编译:

#include <boost/test/unit_test.hpp>
#include <boost/units/quantity.hpp>
#include <boost/units/systems/angle/degrees.hpp>

using boost::units::quantity;
using boost::units::degree::degrees;
using boost::units::degree::plane_angle;

int main() {
    quantity<plane_angle> q1 = 15 * degrees;

    BOOST_CHECK_CLOSE(q1, 15 * degrees, 1e-8);
    return 0;
}

不幸的是,这会在GCC中产生几百行错误。

当然,我可以这样做。

BOOST_CHECK_CLOSE(q1.value(), 15, 1e-8);

但我想在测试用例中明确单位,以防其他人决定更改q1的单位类型。

有没有办法让单位明确?

0 个答案:

没有答案