当前位置: 首页>>代码示例>>C++>>正文


C++ ASSERT_FLOAT_EQ函数代码示例

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


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

示例1: TEST

TEST(YogaTest, all_overridden) {
  const YGNodeRef root = YGNodeNew();
  YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn);
  YGNodeStyleSetWidth(root, 100);
  YGNodeStyleSetHeight(root, 100);

  const YGNodeRef root_child0 = YGNodeNew();
  YGNodeStyleSetFlexGrow(root_child0, 1);
  YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 10);
  YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10);
  YGNodeStyleSetMargin(root_child0, YGEdgeRight, 10);
  YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 10);
  YGNodeStyleSetMargin(root_child0, YGEdgeAll, 20);
  YGNodeInsertChild(root, root_child0, 0);

  YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
  ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
  ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
  ASSERT_FLOAT_EQ(10, YGNodeLayoutGetRight(root_child0));
  ASSERT_FLOAT_EQ(10, YGNodeLayoutGetBottom(root_child0));

  YGNodeFreeRecursive(root);
}
开发者ID:netanelweizman,项目名称:FlexLayout,代码行数:23,代码来源:YGEdgeTest.cpp

示例2: TEST

TEST(TestISTLMatrix, AssembleMPI)
{
  InspectMatrixSIM sim(1);
  sim.read("src/LinAlg/Test/refdata/petsc_test.xinp");
  sim.opt.solver = SystemMatrix::ISTL;
  sim.preprocess();
  sim.initSystem(SystemMatrix::ISTL);

  Matrix stencil(4,4);
  stencil(1,1) = stencil(2,2) = stencil(3,3) = stencil(4,4) = 1.0;

  for (int iel = 1; iel <= sim.getSAM()->getNoElms(); ++iel)
    sim.getMatrix()->assemble(stencil, *sim.getSAM(), iel);

  sim.getMatrix()->beginAssembly();
  sim.getMatrix()->endAssembly();

  // now inspect the matrix
  const ProcessAdm& adm = sim.getProcessAdm();
  ISTL::Mat& mat = static_cast<ISTLMatrix*>(sim.getMatrix())->getMatrix();
  ISTL::Vec b(mat.N()), b2(mat.N());

  try {
    Dune::OwnerOverlapCopyCommunication<int,int> comm(*adm.getCommunicator());
    comm.indexSet().beginResize();
    typedef Dune::ParallelLocalIndex<Dune::OwnerOverlapCopyAttributeSet::AttributeSet> LI;
    for (size_t i = 0; i < adm.dd.getMLGEQ().size(); ++i) {
      int gid = adm.dd.getGlobalEq(i+1);
      comm.indexSet().add(gid-1, LI(i, gid >= adm.dd.getMinEq() ?
                                       Dune::OwnerOverlapCopyAttributeSet::owner :
                                       Dune::OwnerOverlapCopyAttributeSet::overlap));
    }
    comm.indexSet().endResize();
    comm.remoteIndices().setIncludeSelf(true);
    comm.remoteIndices().template rebuild<false>();

    ISTL::ParMatrixAdapter op(mat, comm);

    b = 1.0;
    op.apply(b, b2);
  } catch (Dune::ISTLError& e) {
    std::cerr << e << std::endl;
    ASSERT_TRUE(false);
  }

  IntVec v = readIntVector("src/LinAlg/Test/refdata/petsc_matrix_diagonal.ref");
  for (size_t i = 1; i <= adm.dd.getMLGEQ().size(); ++i)
    ASSERT_FLOAT_EQ(v[adm.dd.getGlobalEq(i)-1], b2[i-1]);
}
开发者ID:kmokstad,项目名称:IFEM-2,代码行数:49,代码来源:TestISTLMatrix.C

示例3: TEST

TEST(FloatTest, SaveLoadTest)
{
	INIT_DONUT;
	std::string providerName;
	XValue data;
	{
		Handler<FloatObject> obj( heap->createFloatObject(10.1) );
		ASSERT_ANY_THROW(obj->toBool(heap));
		ASSERT_ANY_THROW(obj->toInt(heap));
		ASSERT_ANY_THROW(obj->toString(heap));
		ASSERT_FLOAT_EQ(10.1, obj->toFloat(heap));
		data = Handler<HeapObject>(obj)->save(heap);
		providerName = obj->providerName(heap);
	}
	{
		Handler<HeapObject> obj(new FloatObject(heap->findHeapProvider(providerName).get()));
		obj->load(heap, data);
		ASSERT_NO_THROW(obj.cast<FloatObject>());
		ASSERT_ANY_THROW(obj->toBool(heap));
		ASSERT_ANY_THROW(obj->toInt(heap));
		ASSERT_ANY_THROW(obj->toString(heap));
		ASSERT_FLOAT_EQ(10.1, obj->toFloat(heap));
	}
}
开发者ID:kaiinui,项目名称:Chisa,代码行数:24,代码来源:FloatTet.cpp

示例4: testit

  void testit () {
    d_results = Kokkos::View<Kokkos::complex<double>*,ExecSpace>("TestComplexSpecialFunctions",20);
    h_results = Kokkos::create_mirror_view(d_results);

    Kokkos::parallel_for(Kokkos::RangePolicy<ExecSpace>(0,1), *this);
    Kokkos::fence();
    Kokkos::deep_copy(h_results,d_results);

    std::complex<double> a(1.5,2.5);
    double c = 9.3;

    std::complex<double> r;
    r = a;             ASSERT_FLOAT_EQ(h_results(0).real(),  r.real()); ASSERT_FLOAT_EQ(h_results(0).imag(),  r.imag());
    r = std::sqrt(a);  ASSERT_FLOAT_EQ(h_results(1).real(),  r.real()); ASSERT_FLOAT_EQ(h_results(1).imag(),  r.imag());
    r = std::pow(a,c); ASSERT_FLOAT_EQ(h_results(2).real(),  r.real()); ASSERT_FLOAT_EQ(h_results(2).imag(),  r.imag());
    r = std::abs(a);   ASSERT_FLOAT_EQ(h_results(3).real(),  r.real()); ASSERT_FLOAT_EQ(h_results(3).imag(),  r.imag());
  }
开发者ID:UoB-HPC,项目名称:TeaLeaf,代码行数:17,代码来源:TestComplex.hpp

示例5: TEST_F

TEST_F(TrapezoidalTesting, DiagonalValue){

	ASSERT_FLOAT_EQ(0.5, rect_left.CalculateMembership(5.5));
	ASSERT_FLOAT_EQ(0.25, rect_left.CalculateMembership(5.75));
	ASSERT_FLOAT_EQ(0.75, rect_left.CalculateMembership(5.25));

	ASSERT_FLOAT_EQ(0.75, rect_right.CalculateMembership(2.75));
	ASSERT_FLOAT_EQ(0.25, rect_right.CalculateMembership(2.25));
	ASSERT_FLOAT_EQ(0.5, rect_right.CalculateMembership(2.5));
	float m1 = 1.0 - 1.0 / 3.0;
	float m2 = 1.0 - 2.0/ 3.0;

	ASSERT_FLOAT_EQ(m1, normal.CalculateMembership(3));
	ASSERT_FLOAT_EQ(m2, normal.CalculateMembership(4));


}
开发者ID:pablosproject,项目名称:FuzzyBrain,代码行数:17,代码来源:TrapezoidalTesting.cpp

示例6: TEST

TEST (AudioDataTest, DiscardFromFront) {
  KeyFinder::AudioData a;

  a.setChannels(1);
  a.setFrameRate(1);

  ASSERT_THROW(a.discardFramesFromFront(1), KeyFinder::Exception);
  a.addToFrameCount(10);
  ASSERT_THROW(a.discardFramesFromFront(11), KeyFinder::Exception);
  ASSERT_NO_THROW(a.discardFramesFromFront(0));
  a.setSampleByFrame(5, 0, 10.0);
  ASSERT_NO_THROW(a.discardFramesFromFront(5));
  ASSERT_EQ(5, a.getFrameCount());
  ASSERT_FLOAT_EQ(10.0, a.getSampleByFrame(0, 0));
}
开发者ID:PimpinFou,项目名称:libKeyFinder,代码行数:15,代码来源:audiodatatest.cpp

示例7: TEST

TEST(CircularBufferSingle, TestMultiWriteRead)
{
    const float data[4] = {1,2,3,4};
    float out[4] = {0,0,0,0};
    CircularBuffer *buffer = CircularBufferInit(7);
    CircularBufferWrite(buffer, data, 2);
    CircularBufferWrite(buffer, data + 2, 2);
    CircularBufferRead(buffer, out, 4);
    CircularBufferFree(buffer);
    
    for (unsigned i = 0; i < 4; ++i)
    {
        ASSERT_FLOAT_EQ(out[i], data[i]);
    }
}
开发者ID:eriser,项目名称:FxDSP,代码行数:15,代码来源:TestCircularBuffer.cpp

示例8: TEST

TEST(Quaternion, Normalize) {
	narf::Quaternion<float> q1(3, -1, 4, 3);
	ASSERT_FLOAT_EQ(q1.norm(), 5.91608f);
	auto q2 = q1.normalize();
	ASSERT_FLOAT_EQ(q2.norm(), 1.0f);
	ASSERT_FLOAT_EQ(q2.w, 0.50709254f);
	ASSERT_FLOAT_EQ(q2.v.x, -0.16903085f);
	ASSERT_FLOAT_EQ(q2.v.y, 0.67612338f);
	ASSERT_FLOAT_EQ(q2.v.z, 0.50709254f);
}
开发者ID:narfblock,项目名称:narfblock,代码行数:10,代码来源:quaternions.cpp

示例9: TEST_F

TEST_F(VCFReaderTest, QualField) {
	const char* value = nullptr;
	sph_umich_edu::QualField field;

	value = "";
	ASSERT_THROW(field.parse(value, value + strlen(value)), sph_umich_edu::VCFException);
	ASSERT_TRUE(field.is_empty());

	value = ".";
	ASSERT_NO_THROW(field.parse(value, value + strlen(value)));
	ASSERT_TRUE(field.is_empty());
	ASSERT_TRUE(std::isnan(field.get_value()));

	value = "0";
	ASSERT_NO_THROW(field.parse(value, value + strlen(value)));
	ASSERT_FALSE(field.is_empty());
	ASSERT_FLOAT_EQ(0.0, field.get_value());

	value = "30";
	ASSERT_NO_THROW(field.parse(value, value + strlen(value)));
	ASSERT_FALSE(field.is_empty());
	ASSERT_FLOAT_EQ(30.0, field.get_value());

	value = "-30";
	ASSERT_THROW(field.parse(value, value + strlen(value)), sph_umich_edu::VCFException);
	ASSERT_TRUE(field.is_empty());

	value = "12.2";
	ASSERT_NO_THROW(field.parse(value, value + strlen(value)));
	ASSERT_FALSE(field.is_empty());
	ASSERT_FLOAT_EQ(12.2, field.get_value());

	value = "12.0";
	ASSERT_NO_THROW(field.parse(value, value + strlen(value)));
	ASSERT_FALSE(field.is_empty());
	ASSERT_FLOAT_EQ(12.0, field.get_value());

	value = "0.0";
	ASSERT_NO_THROW(field.parse(value, value + strlen(value)));
	ASSERT_FALSE(field.is_empty());
	ASSERT_FLOAT_EQ(0.0, field.get_value());

	value = "0.12";
	ASSERT_NO_THROW(field.parse(value, value + strlen(value)));
	ASSERT_FALSE(field.is_empty());
	ASSERT_FLOAT_EQ(0.12, field.get_value());

	value = ".12";
	ASSERT_THROW(field.parse(value, value + strlen(value)), sph_umich_edu::VCFException);
	ASSERT_TRUE(field.is_empty());

	value = "aBc";
	ASSERT_THROW(field.parse(value, value + strlen(value)), sph_umich_edu::VCFException);
	ASSERT_TRUE(field.is_empty());
}
开发者ID:dtaliun,项目名称:auxc,代码行数:55,代码来源:VCFReaderTest.cpp

示例10: TEST_F

/// tests Matrix4 array getter
TEST_F(Math_Matrix4Tests, ArrayGetter)
{
    float in_array[] = {5,-71,-13,86,-86,-8,-62,8,-69,-106,81,125,-1,-52,84,47};
    const float* out_array;
    
    for(int i=0; i < 4; i++)
    {
        for (int j=0; j < 4; j++)
            m1.set(i, j, in_array[i*4 + j]);
    }
    
    out_array = m1.getArray();
    
    for(int i=0; i < 16; i++)
        ASSERT_FLOAT_EQ(in_array[i], out_array[i]);
}
开发者ID:anobin,项目名称:3DMagic,代码行数:17,代码来源:MatrixTests.cpp

示例11: TEST_F

TEST_F(TabuAlgorithmTest, BigTestOnRealData)
{
    std::shared_ptr<Vrp::CvrpFile> l_file = std::make_shared<Vrp::CvrpFile>("../../dairyProblem/data/A-n69-k9.vrp");
    Vrp::PolarCoordinatesMatrixConverter l_polarConv(Vrp::CvrpFileReader(l_file).getData());
    TabuAlgorithm l_algorithm(l_polarConv.convertAndSortByAngle());

    DairyPath l_result;
    l_result.distance = 1281.9614;
    l_result.path = {1, 30, 16, 28, 23, 10, 25, 19, 9, 15, 1,
                     12, 5, 29, 24, 7, 4, 3, 27, 1, 14, 8, 18,
                     20, 31, 32, 1, 17, 22, 2, 13, 21, 1, 26, 6, 11, 1};

    //ASSERT_EQ(l_algorithm.compute().path, l_result.path);
ASSERT_FLOAT_EQ(l_algorithm.compute().distance, l_result.distance);
    //ASSERT_FLOAT_EQ(l_algorithm.getDistance(), l_result.distance);
}
开发者ID:edyp87,项目名称:dairy_problem,代码行数:16,代码来源:TabuAlgorithmUT.cpp

示例12: TEST

TEST(DSP, FloatDoubleConversion)
{
    float in[10] = {1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0};
    double out[10];
    float fout[10];
    
    FloatToDouble(out, in, 10);
    for (unsigned i = 0; i < 10; ++i)
    {
        ASSERT_DOUBLE_EQ((double)in[i], out[i]);
    }
    
    DoubleToFloat(fout, out, 10);
    for (unsigned i = 0; i < 10; ++i)
    {
        ASSERT_FLOAT_EQ(in[i], fout[i]);
    }
}
开发者ID:eriser,项目名称:FxDSP,代码行数:18,代码来源:TestDSP.cpp

示例13: TEST_F

TEST_F(CConfigFileTest, ReadTest)
{
    m_configFile.SetUseCurrentDirectory(true);

    ASSERT_TRUE(m_configFile.Init()); // load colobot.ini file

    std::string result;
    ASSERT_TRUE(m_configFile.GetStringProperty("test_string", "string_value", result));
    ASSERT_STREQ("Hello world", result.c_str());

    int int_value;
    ASSERT_TRUE(m_configFile.GetIntProperty("test_int", "int_value", int_value));
    ASSERT_EQ(42, int_value);

    float float_value;
    ASSERT_TRUE(m_configFile.GetFloatProperty("test_float", "float_value", float_value));
    ASSERT_FLOAT_EQ(1.5, float_value);
}
开发者ID:2asoft,项目名称:colobot,代码行数:18,代码来源:config_file_test.cpp

示例14: TEST

    TEST(xphoto_DenoisingBm3dKaiserWindow, regression_4)
    {
        float beta = 2.0f;
        int N = 4;

        cv::Mat kaiserWindow;
        calcKaiserWindow1D(kaiserWindow, N, beta);

        float kaiser4[] = {
            0.43869004f,
            0.92432547f,
            0.92432547f,
            0.43869004f
        };

        for (int i = 0; i < N; ++i)
            ASSERT_FLOAT_EQ(kaiser4[i], kaiserWindow.at<float>(i));
    }
开发者ID:AmbroiseMoreau,项目名称:opencv_contrib,代码行数:18,代码来源:test_denoise_bm3d.cpp

示例15: TEST

TEST(TestISTLPETScMatrix, SchurComplement)
{
  ASMmxBase::Type = ASMmxBase::FULL_CONT_RAISE_BASIS1;
  ASMmxBase::geoBasis = 2;

  Matrix stencil(13,13);
  for (size_t i = 1; i<= 13; ++i)
    for (size_t j = 1; j <= 13; ++j)
      stencil(i,j) = 1.0;

  std::array<InspectMatrixSIM,2> sim;
  for (size_t i = 0; i < 2; ++i) {
    sim[i].read("src/LinAlg/Test/refdata/petsc_test_blocks_basis.xinp");
    sim[i].opt.solver = i == 0 ? SystemMatrix::PETSC : SystemMatrix::ISTL;
    sim[i].preprocess();
    sim[i].initSystem(i == 0 ? SystemMatrix::PETSC : SystemMatrix::ISTL);

    for (int iel = 1; iel <= sim[i].getSAM()->getNoElms(); ++iel)
      sim[i].getMatrix()->assemble(stencil, *sim[i].getSAM(), iel);

    sim[i].getMatrix()->beginAssembly();
    sim[i].getMatrix()->endAssembly();
  }

  const ProcessAdm& adm = sim[1].getProcessAdm();
  ISTL::Mat& A = static_cast<ISTLMatrix*>(sim[1].getMatrix())->getMatrix();
  ISTL::BlockPreconditioner block(A, adm.dd, "upper");

  ISTL::Mat& S = block.getBlock(1);
  PETScSolParams params(LinSolParams(), adm);
  params.setupSchurComplement(static_cast<PETScMatrix*>(sim[0].getMatrix())->getBlockMatrices());

  // check that matrices are the same
  for (size_t r = 0; r < S.N(); ++r) {
    const PetscInt* cols;
    PetscInt ncols;
    const PetscScalar* vals;
    MatGetRow(params.getSchurComplement(), r, &ncols, &cols, &vals);
    for (PetscInt i = 0; i < ncols; ++i)
      ASSERT_FLOAT_EQ(vals[i], S[r][cols[i]]);
    MatRestoreRow(params.getSchurComplement(), r, &ncols, &cols, &vals);
  }
}
开发者ID:kmokstad,项目名称:IFEM-2,代码行数:43,代码来源:TestISTLPETScMatrix.C


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