當前位置: 首頁>>代碼示例>>C++>>正文


C++ BOOST_CHECK_CLOSE函數代碼示例

本文整理匯總了C++中BOOST_CHECK_CLOSE函數的典型用法代碼示例。如果您正苦於以下問題:C++ BOOST_CHECK_CLOSE函數的具體用法?C++ BOOST_CHECK_CLOSE怎麽用?C++ BOOST_CHECK_CLOSE使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了BOOST_CHECK_CLOSE函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的BOOST_CHECK_CLOSE函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。