• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ BOOST_CHECK_CLOSE函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中BOOST_CHECK_CLOSE函数的典型用法代码示例。如果您正苦于以下问题:C++ BOOST_CHECK_CLOSE函数的具体用法?C++ BOOST_CHECK_CLOSE怎么用?C++ BOOST_CHECK_CLOSE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了BOOST_CHECK_CLOSE函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: test_one_lp

void test_one_lp(std::string const& caseid,
        std::string const& wkt1, std::string const& wkt2,
        std::size_t expected_count,
        int expected_point_count,
        double expected_length)
{
    G1 g1;
    bg::read_wkt(wkt1, g1);

    G2 g2;
    bg::read_wkt(wkt2, g2);

    bg::correct(g1);

    std::vector<OutputType> pieces;
    bg::difference(g1, g2, pieces);

    typename bg::default_length_result<G1>::type length = 0;
    std::size_t n = 0;
    std::size_t piece_count = 0;
    for (typename std::vector<OutputType>::iterator it = pieces.begin();
            it != pieces.end();
            ++it)
    {
        if (expected_point_count >= 0)
        {
            n += bg::num_points(*it);
        }
        piece_count++;
        length += bg::length(*it);
    }

    BOOST_CHECK_MESSAGE(piece_count == expected_count,
            "difference: " << caseid
            << " #outputs expected: " << expected_count
            << " detected: " << pieces.size()
            );

    if (expected_point_count >= 0)
    {
        BOOST_CHECK_EQUAL(n, std::size_t(expected_point_count));
    }

    BOOST_CHECK_CLOSE(length, expected_length, 0.001);

    std::string lp = "lp_";
    difference_output(lp + caseid, g1, g2, pieces);
}
开发者ID:MarcelRaad,项目名称:geometry,代码行数:48,代码来源:test_difference.hpp


示例2: test_boxes

void test_boxes(std::string const& wkt1, std::string const& wkt2, double expected_area, bool expected_result)
{
    Box box1, box2;
    bg::read_wkt(wkt1, box1);
    bg::read_wkt(wkt2, box2);

    Box box_out;
    bool detected = bg::intersection(box1, box2, box_out);
    typename bg::default_area_result<Box>::type area = bg::area(box_out);

    BOOST_CHECK_EQUAL(detected, expected_result);
    if (detected && expected_result)
    {
        BOOST_CHECK_CLOSE(area, expected_area, 0.01);
    }
}
开发者ID:TheRyaz,项目名称:c_reading,代码行数:16,代码来源:intersection.cpp


示例3: BOOST_AUTO_TEST_CASE_TEMPLATE

BOOST_AUTO_TEST_CASE_TEMPLATE(slerp, T, float_types) {
	vmath::core::Quaternion<T> H1(
		vmath::core::Vector<T, 3>(static_cast<T>(1.0), static_cast<T>(0.0), static_cast<T>(0.0)),
		vmath::radians(static_cast<T>(20.0)));
	vmath::core::Quaternion<T> H2(
		vmath::core::Vector<T, 3>(static_cast<T>(1.0), static_cast<T>(0.0), static_cast<T>(0.0)),
		vmath::radians(static_cast<T>(40.0)));
	vmath::core::Quaternion<T> Hs = vmath::core::Quaternion<T>::slerp(H1, H2, static_cast<T>(0.0));
	BOOST_CHECK_CLOSE(Hs.x, H1.x, 1e-4f);
	BOOST_CHECK_CLOSE(Hs.y, H1.y, 1e-4f);
	BOOST_CHECK_CLOSE(Hs.z, H1.z, 1e-4f);
	BOOST_CHECK_CLOSE(Hs.w, H1.w, 1e-4f);
	Hs = vmath::core::Quaternion<T>::slerp(H1, H2, static_cast<T>(1.0));
	BOOST_CHECK_CLOSE(Hs.x, H2.x, 1e-4f);
	BOOST_CHECK_CLOSE(Hs.y, H2.y, 1e-4f);
	BOOST_CHECK_CLOSE(Hs.z, H2.z, 1e-4f);
	BOOST_CHECK_CLOSE(Hs.w, H2.w, 1e-4f);
}
开发者ID:kernan,项目名称:vmath,代码行数:18,代码来源:quaternion.cpp


示例4: BOOST_AUTO_TEST_CASE_TEMPLATE

BOOST_AUTO_TEST_CASE_TEMPLATE(inverse, T, float_types) {
	vmath::core::Matrix<T, 3> M;
	M[0][0] = static_cast<T>(1.0);
	M[0][1] = static_cast<T>(2.0);
	M[0][2] = static_cast<T>(3.0);
	M[1][0] = static_cast<T>(3.0);
	M[1][1] = static_cast<T>(1.0);
	M[1][2] = static_cast<T>(2.0);
	M[2][0] = static_cast<T>(2.0);
	M[2][1] = static_cast<T>(3.0);
	M[2][2] = static_cast<T>(1.0);
	vmath::core::Matrix<T, 3> M_inv = M.inverse();
	BOOST_CHECK_CLOSE(M_inv[0][0], static_cast<T>(-0.277777791), 1e-4f);
	BOOST_CHECK_CLOSE(M_inv[0][1], static_cast<T>(0.388888896), 1e-4f);
	BOOST_CHECK_CLOSE(M_inv[0][2], static_cast<T>(0.055555556), 1e-4f);
	BOOST_CHECK_CLOSE(M_inv[1][0], static_cast<T>(0.055555556), 1e-4f);
	BOOST_CHECK_CLOSE(M_inv[1][1], static_cast<T>(-0.277777791), 1e-4f);
	BOOST_CHECK_CLOSE(M_inv[1][2], static_cast<T>(0.388888896), 1e-4f);
	BOOST_CHECK_CLOSE(M_inv[2][0], static_cast<T>(0.388888896), 1e-4f);
	BOOST_CHECK_CLOSE(M_inv[2][1], static_cast<T>(0.055555556), 1e-4f);
	BOOST_CHECK_CLOSE(M_inv[2][2], static_cast<T>(-0.277777791), 1e-4f);
}
开发者ID:kernan,项目名称:vmath,代码行数:22,代码来源:matrix3x3.cpp


示例5: apply

    static void apply(Box const& b, const type& x1, const type& y1, const type& z1,
                const type& x2, const type& y2, const type& z2)
    {
        BOOST_CHECK_CLOSE((bg::get<bg::min_corner, 0>(b)), x1, 0.001);
        BOOST_CHECK_CLOSE((bg::get<bg::min_corner, 1>(b)), y1, 0.001);
        BOOST_CHECK_CLOSE((bg::get<bg::min_corner, 2>(b)), z1, 0.001);

        BOOST_CHECK_CLOSE((bg::get<bg::max_corner, 0>(b)), x2, 0.001);
        BOOST_CHECK_CLOSE((bg::get<bg::max_corner, 1>(b)), y2, 0.001);
        BOOST_CHECK_CLOSE((bg::get<bg::max_corner, 2>(b)), z2, 0.001);
    }
开发者ID:AlexMioMio,项目名称:boost,代码行数:11,代码来源:test_envelope.hpp


示例6: BOOST_FIXTURE_TEST_CASE

BOOST_FIXTURE_TEST_CASE(proportional_plus_integral_cooling, PidTest)
{
    pid->setConstants(10.0, 600, 0);
    pid->setActuatorIsNegative(true);
    sp->write(19.0);

    sensor->setTemp(20.0);

    // update for 10 minutes
    for(int i = 0; i < 600; i++){
        pid->update();
        act->update();
    }

    // integrator result is error / Ti * time, So 600 * 1 degree error / 60 = 10.0
    BOOST_CHECK_CLOSE(double(act->getValue()), 20.0, 2);
}
开发者ID:elcojacobs,项目名称:brewpi-firmware,代码行数:17,代码来源:PidTest.cpp


示例7: test_spots

void test_spots(T)
{
   //
   // Basic sanity checks, tolerance is 20 epsilon expressed as a percentage:
   //
   T tolerance = boost::math::tools::epsilon<T>() * 20 * 100;
   T small = boost::math::tools::epsilon<T>() / 1024;
   BOOST_CHECK_CLOSE(::boost::math::beta(static_cast<T>(1), static_cast<T>(1)), static_cast<T>(1), tolerance);
   BOOST_CHECK_CLOSE(::boost::math::beta(static_cast<T>(1), static_cast<T>(4)), static_cast<T>(0.25), tolerance);
   BOOST_CHECK_CLOSE(::boost::math::beta(static_cast<T>(4), static_cast<T>(1)), static_cast<T>(0.25), tolerance);
   BOOST_CHECK_CLOSE(::boost::math::beta(small, static_cast<T>(4)), 1/small, tolerance);
   BOOST_CHECK_CLOSE(::boost::math::beta(static_cast<T>(4), small), 1/small, tolerance);
   BOOST_CHECK_CLOSE(::boost::math::beta(static_cast<T>(4), static_cast<T>(20)), static_cast<T>(0.00002823263692828910220214568040654997176736L), tolerance);
   BOOST_CHECK_CLOSE(::boost::math::beta(static_cast<T>(0.0125L), static_cast<T>(0.000023L)), static_cast<T>(43558.24045647538375006349016083320744662L), tolerance);
}
开发者ID:gnu3ra,项目名称:SCC15HPCRepast,代码行数:15,代码来源:test_beta.hpp


示例8: test_large_integers

void test_large_integers()
{
    typedef bg::model::point<int, 2, bg::cs::cartesian> int_point_type;
    typedef bg::model::point<double, 2, bg::cs::cartesian> double_point_type;

    bg::model::box<int_point_type> int_box;
    bg::model::box<double_point_type> double_box;

    std::string const box_li = "POLYGON((1536119 192000, 1872000 528000))";
    bg::read_wkt(box_li, int_box);
    bg::read_wkt(box_li, double_box);

    double int_value = bgi::detail::comparable_margin(int_box);
    double double_value = bgi::detail::comparable_margin(double_box);

    BOOST_CHECK_CLOSE(int_value, double_value, 0.0001);
}
开发者ID:LancelotGHX,项目名称:Simula,代码行数:17,代码来源:margin.cpp


示例9: test_length

void test_length(Geometry const& geometry, long double expected_length)
{
    typename bg::default_length_result<Geometry>::type length = bg::length(geometry);

#ifdef GEOMETRY_TEST_DEBUG
    std::ostringstream out;
    out << typeid(typename bg::coordinate_type<Geometry>::type).name()
        << std::endl
        << typeid(typename bg::default_length_result<Geometry>::type).name()
        << std::endl
        << "length : " << bg::length(geometry)
        << std::endl;
    std::cout << out.str();
#endif

    BOOST_CHECK_CLOSE(length, expected_length, 0.0001);
}
开发者ID:0xDEC0DE8,项目名称:mcsema,代码行数:17,代码来源:test_length.hpp


示例10: test_content

void test_content(Geometry const& geometry,
            typename bgi::detail::default_content_result<Geometry>::type expected_value)
{
    typename bgi::detail::default_content_result<Geometry>::type value = bgi::detail::content(geometry);

#ifdef BOOST_GEOMETRY_TEST_DEBUG
    std::ostringstream out;
    out << typeid(typename bg::coordinate_type<Geometry>::type).name()
        << " "
        << typeid(typename bgi::detail::default_content_result<Geometry>::type).name()
        << " "
        << "content : " << value
        << std::endl;
    std::cout << out.str();
#endif

    BOOST_CHECK_CLOSE(value, expected_value, 0.0001);
}
开发者ID:Adikteev,项目名称:rtbkit-deps,代码行数:18,代码来源:test_content.hpp


示例11: BOOST_AUTO_TEST_CASE_TEMPLATE

BOOST_AUTO_TEST_CASE_TEMPLATE(copy, T, float_types) {
	vmath::core::Matrix<T, 4, 2> M;
	M[0][0] = static_cast<T>(1.0);
	M[0][1] = static_cast<T>(2.0);
	M[0][2] = static_cast<T>(3.0);
	M[0][3] = static_cast<T>(4.0);
	M[1][0] = static_cast<T>(5.0);
	M[1][1] = static_cast<T>(6.0);
	M[1][2] = static_cast<T>(7.0);
	M[1][3] = static_cast<T>(8.0);
	vmath::core::Matrix<T, 4, 2> M_copy(M);
	BOOST_CHECK_CLOSE(M_copy[0][0], static_cast<T>(1.0), 1e-4f);
	BOOST_CHECK_CLOSE(M_copy[0][1], static_cast<T>(2.0), 1e-4f);
	BOOST_CHECK_CLOSE(M_copy[0][2], static_cast<T>(3.0), 1e-4f);
	BOOST_CHECK_CLOSE(M_copy[0][3], static_cast<T>(4.0), 1e-4f);
	BOOST_CHECK_CLOSE(M_copy[1][0], static_cast<T>(5.0), 1e-4f);
	BOOST_CHECK_CLOSE(M_copy[1][1], static_cast<T>(6.0), 1e-4f);
	BOOST_CHECK_CLOSE(M_copy[1][2], static_cast<T>(7.0), 1e-4f);
	BOOST_CHECK_CLOSE(M_copy[1][3], static_cast<T>(8.0), 1e-4f);
}
开发者ID:kernan,项目名称:vmath,代码行数:20,代码来源:matrix4x2.cpp


示例12: test_structs_minimal

void test_structs_minimal()
{
  std::random_device rd;
  std::mt19937 gen(rd());

  for(int ii=0; ii<100; ++ii)
  {
    TestStruct o_struct = { random_basic_string<char>(gen), random_value<double>(gen),
                            random_value<std::uint32_t>(gen), random_value<uint8_t>(gen) % 2 ? true : false };

    Issue79Struct o_struct2 = { random_value<std::int32_t>(gen) };
    Issue79StructInternal o_struct3 = { random_value<std::int32_t>(gen) };

    std::ostringstream os;
    {
      OArchive oar(os);
      oar( o_struct );
      oar( o_struct2 );
      oar( o_struct3 );
    }

    decltype(o_struct) i_struct;
    decltype(o_struct2) i_struct2;
    decltype(o_struct3) i_struct3;

    std::istringstream is(os.str());
    {
      IArchive iar(is);
      iar( i_struct );
      iar( i_struct2 );
      iar( i_struct3 );
    }

    BOOST_CHECK(o_struct.mm.x == i_struct.mm.x);
    BOOST_CHECK_CLOSE(o_struct.mmv.x, i_struct.mmv.x, 1e-5);

    BOOST_CHECK(o_struct.nmm.x == i_struct.nmm.x);
    BOOST_CHECK(o_struct.nmmv.x == i_struct.nmmv.x);

    BOOST_CHECK(o_struct2.x == i_struct2.x);

    BOOST_CHECK(o_struct3.x == i_struct3.x);
  }
}
开发者ID:BlindHouse,项目名称:xMemory,代码行数:44,代码来源:structs_minimal.cpp


示例13: check_controls_epoch1

void check_controls_epoch1( struct WellControls ** ctrls) {
    // The injector
    {
        const struct WellControls * ctrls0 = ctrls[0];
        BOOST_CHECK_EQUAL( 3 , well_controls_get_num(ctrls0));   // The number of controls for the injector == 3??

        BOOST_CHECK_EQUAL( SURFACE_RATE   , well_controls_iget_type(ctrls0 , 0 ));
        BOOST_CHECK_EQUAL( RESERVOIR_RATE , well_controls_iget_type(ctrls0 , 1 ));
        BOOST_CHECK_EQUAL( BHP            , well_controls_iget_type(ctrls0 , 2 ));

        // The different targets
        BOOST_CHECK_CLOSE( 10.0 / 86400 , well_controls_iget_target(ctrls0 , 0) , 0.001);
        BOOST_CHECK_CLOSE( 20.0 / 86400 , well_controls_iget_target(ctrls0 , 1) , 0.001);
        BOOST_CHECK_CLOSE( 40 * 100000  , well_controls_iget_target(ctrls0 , 2) , 0.001);

        // Which control is active
        BOOST_CHECK_EQUAL( 1 , well_controls_get_current(ctrls0));

        {
            const double * distr = well_controls_iget_distr( ctrls0 , 1 );
            BOOST_CHECK_EQUAL( 1 , distr[0] );  // Water
            BOOST_CHECK_EQUAL( 0 , distr[1] );  // Oil
            BOOST_CHECK_EQUAL( 0 , distr[2] );  // Gas
        }
    }
    
    // The producer
    {
        const struct WellControls * ctrls1 = ctrls[1];
        BOOST_CHECK_EQUAL( 3 , well_controls_get_num(ctrls1));   // The number of controls for the producer - now 3.
        BOOST_CHECK_EQUAL( SURFACE_RATE   , well_controls_iget_type(ctrls1 , 0) );
        BOOST_CHECK_EQUAL( RESERVOIR_RATE , well_controls_iget_type(ctrls1 , 1) );
        BOOST_CHECK_EQUAL( BHP            , well_controls_iget_type(ctrls1 , 2) );

        // The different targets
        BOOST_CHECK_CLOSE( -999.0 / 86400 , well_controls_iget_target(ctrls1 , 0), 0.001);
        BOOST_CHECK_CLOSE( -123.0 / 86400 , well_controls_iget_target(ctrls1 , 1), 0.001);
        BOOST_CHECK_CLOSE(  100 * 100000  , well_controls_iget_target(ctrls1 , 2), 0.001);

        // Which control is active
        BOOST_CHECK_EQUAL( 1 , well_controls_get_current(ctrls1) );

        {
            const double * distr = well_controls_iget_distr( ctrls1 , 1 );
            BOOST_CHECK_EQUAL( 1 , distr[0] );  // Water
            BOOST_CHECK_EQUAL( 1 , distr[1] );  // Oil
            BOOST_CHECK_EQUAL( 1 , distr[2] );  // Gas
        }
    }
}
开发者ID:vkip,项目名称:opm-core,代码行数:50,代码来源:test_wellsmanager.cpp


示例14: BOOST_AUTO_TEST_CASE_TEMPLATE

BOOST_AUTO_TEST_CASE_TEMPLATE(members, T, float_types) {
	vmath::core::Matrix<T, 3, 2> M;
	M[0] = vmath::core::Vector<T, 3>(static_cast<T>(1.0), static_cast<T>(2.0), static_cast<T>(3.0));
	M[1] = vmath::core::Vector<T, 3>(static_cast<T>(4.0), static_cast<T>(5.0), static_cast<T>(6.0));
	BOOST_CHECK_CLOSE(M[0][0], static_cast<T>(1.0), 1e-4f);
	BOOST_CHECK_CLOSE(M[0][1], static_cast<T>(2.0), 1e-4f);
	BOOST_CHECK_CLOSE(M[0][2], static_cast<T>(3.0), 1e-4f);
	BOOST_CHECK_CLOSE(M[1][0], static_cast<T>(4.0), 1e-4f);
	BOOST_CHECK_CLOSE(M[1][1], static_cast<T>(5.0), 1e-4f);
	BOOST_CHECK_CLOSE(M[1][2], static_cast<T>(6.0), 1e-4f);
	// invalid index
	BOOST_CHECK_THROW(M[2], std::out_of_range);
	BOOST_CHECK_THROW((M[2] = vmath::core::Vector<T, 3>()), std::out_of_range);
}
开发者ID:kernan,项目名称:vmath,代码行数:14,代码来源:matrix3x2.cpp


示例15: test_large_integers

void test_large_integers()
{
    typedef bg::model::point<int, 2, bg::cs::cartesian> int_point_type;
    typedef bg::model::point<double, 2, bg::cs::cartesian> double_point_type;

    bg::model::box<int_point_type> int_box1, int_box2;
    bg::model::box<double_point_type> double_box1, double_box2;

    std::string const box_li1 = "POLYGON((1536119 192000, 1872000 528000))";
    std::string const box_li2 = "POLYGON((1701234 368250, 2673400 777400))";
    bg::read_wkt(box_li1, int_box1);
    bg::read_wkt(box_li1, double_box1);
    bg::read_wkt(box_li2, int_box2);
    bg::read_wkt(box_li2, double_box2);

    double int_value = bgi::detail::union_content(int_box1, int_box2);
    double double_value = bgi::detail::union_content(double_box1, double_box2);

    BOOST_CHECK_CLOSE(int_value, double_value, 0.0001);
}
开发者ID:AlexMioMio,项目名称:boost,代码行数:20,代码来源:union_content.cpp


示例16: BOOST_FIXTURE_TEST_CASE_TEMPLATE

BOOST_FIXTURE_TEST_CASE_TEMPLATE(trivial_convolveImageLocalMem, T, Fixtures, T)
{
	const float* image = T::image_.data();
	anyfold::image_stack expected(T::image_);


	float* kernel = new float[T::kernel_size_];
	std::fill(kernel, kernel+T::kernel_size_,0.f);

	anyfold::opencl::convolve_3dImageLocalMem(image, &T::image_shape_[0],
	                             kernel,&T::kernel_dims_[0],
	                             T::output_.data());

	float sum = std::accumulate(T::output_.data(),
	                            T::output_.data() + T::output_.num_elements(),0.f);

	BOOST_CHECK_CLOSE(sum, 0.f, .00001);

	delete [] kernel;
}
开发者ID:Phornp,项目名称:anyfold,代码行数:20,代码来源:test_opencl_convolve.cpp


示例17: test

void test(Point const& pt, Indexable const& indexable,
    typename bg::default_distance_result<Point, Indexable>::type expected_value)
{
    typename bg::default_distance_result<Point, Indexable>::type value = bgi::detail::minmaxdist(pt, indexable);

#ifdef GEOMETRY_TEST_DEBUG
    std::ostringstream out;
    out << typeid(typename bg::coordinate_type<Point>::type).name()
        << " "
        << typeid(typename bg::coordinate_type<Indexable>::type).name()
        << " "
        << typeid(bg::default_distance_result<Point, Indexable>::type).name()
        << " "
        << "minmaxdist : " << value
        << std::endl;
    std::cout << out.str();
#endif

    BOOST_CHECK_CLOSE(value, expected_value, 0.0001);
}
开发者ID:avasopht,项目名称:boost_1_55_0-llvm,代码行数:20,代码来源:minmaxdist.cpp



注:本文中的BOOST_CHECK_CLOSE函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ BOOST_CHECK_MESSAGE函数代码示例发布时间:2022-05-30
下一篇:
C++ BOOST_CHECK函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap