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


C++ DOUBLES_EQUAL函數代碼示例

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


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

示例1: TEST

TEST(MatrixTest, should_multiply_correctly) {
    float as[6] = {
        0, 1, 2, 
        3, 4, 5
    };
    Matrix *a = new Matrix(2, 3, as);
    float bs[6] = {
        -1, -2, 
        3, 4, 
        5, 6
    };
    Matrix *b = new Matrix(3, 2, bs);

    Matrix c = a[0] * b[0];

    CHECK_EQUAL(2, c.getRows());
    CHECK_EQUAL(2, c.getCols());

    DOUBLES_EQUAL(13.0f, c.getCell(0, 0), 0.001);
    DOUBLES_EQUAL(16.0f, c.getCell(0, 1), 0.001);
    DOUBLES_EQUAL((float)(-3+12+25), c.getCell(1, 0), 0.001);
    DOUBLES_EQUAL((float)(-6+16+30), c.getCell(1, 1), 0.001);
    delete a;
    delete b;
}
開發者ID:sondrele,項目名稱:NTNU,代碼行數:25,代碼來源:matrix_test.cpp

示例2: TEST

TEST(RTMaterial, shouldSupportAddition) {

  RTMaterial m1;
  m1.setKTransparency(0.1);
  m1.setShininess(0.2);
  m1.setDiffColor(RTColor(0,0.1,0.2));
  m1.setSpecColor(RTColor(0,0.1,0.2));
  m1.setAmbColor(RTColor(0,0.1,0.2));
  m1.setEmissColor(RTColor(0,0.1,0.2));

  RTMaterial m2;
  m2.setKTransparency(0.3);
  m2.setShininess(0.2);
  m2.setDiffColor(RTColor(0,0.1,0.2));
  m2.setSpecColor(RTColor(0,0.1,0.2));
  m2.setAmbColor(RTColor(0,0.1,0.2));
  m2.setEmissColor(RTColor(0,0.1,0.2));

  m1 += m2;

  DOUBLES_EQUAL( 0.4, m1.getKTransparency(), 0.00001 );
  DOUBLES_EQUAL( 0.4, m1.getShininess(), 0.00001 );
  COLOR_EQUAL(0, 51, 102, m1.getDiffColor() );
  COLOR_EQUAL(0, 51, 102, m1.getSpecColor() );
  COLOR_EQUAL(0, 51, 102, m1.getAmbColor() );
  COLOR_EQUAL(0, 51, 102, m1.getEmissColor() );
}
開發者ID:havardh,項目名稱:ECE594Q,代碼行數:27,代碼來源:RTMaterialTest.cpp

示例3: set_test_name

void TestRegistry::test<1>()
{
    set_test_name("Determinant (2x2 matrix)");

    m2f[0] = 1.0f; m2f[2] = 3.0f;
    m2f[1] = 2.0f; m2f[3] = 4.0f;

    result = jship::Hazmat::Determinant(m2f);
    
    DOUBLES_EQUAL(m2f[0], 1.0, 1e-5);
    DOUBLES_EQUAL(m2f[1], 2.0, 1e-5);
    DOUBLES_EQUAL(m2f[2], 3.0, 1e-5);
    DOUBLES_EQUAL(m2f[3], 4.0, 1e-5);
    
    DOUBLES_EQUAL(result, -2.0, 1e-5);
    
    m2f[0] =  1.0f; m2f[2] =  2.0f;
    m2f[1] = -3.0f; m2f[3] =  1.0f;
    
    result = jship::Hazmat::Determinant(m2f);
    
    DOUBLES_EQUAL(m2f[0],  1.0, 1e-5);
    DOUBLES_EQUAL(m2f[1], -3.0, 1e-5);
    DOUBLES_EQUAL(m2f[2],  2.0, 1e-5);
    DOUBLES_EQUAL(m2f[3],  1.0, 1e-5);

    DOUBLES_EQUAL(result, 7.0, 1e-5);
}
開發者ID:jship,項目名稱:Hazmat,代碼行數:28,代碼來源:TestDeterminant.cpp

示例4: TEST

TEST(MS4525DO, pressure_conversion_absolute_type_A)
{
    ms4525do_init(&d, &i2c, 'A', 'I', 2, 'A');
    DOUBLES_EQUAL(0, ms4525do_pressure_raw_to_Pa(&d, 1638), 1); // values from datasheet table
    DOUBLES_EQUAL(1*PSI, ms4525do_pressure_raw_to_Pa(&d, 8192), 1);
    DOUBLES_EQUAL(2*PSI, ms4525do_pressure_raw_to_Pa(&d, 14746), 3);
}
開發者ID:Stapelzeiger,項目名稱:sensor-drivers,代碼行數:7,代碼來源:test_ms4525do.cpp

示例5: TEST

TEST(MockSupport_c, whenNoReturnValueIsGivenReturnDoubleValueOrDefaultShouldlUseTheDefaultValue)
{
    double defaultValue = 2.2;
    mock_c()->expectOneCall("foo");
    DOUBLES_EQUAL(defaultValue, mock_c()->actualCall("foo")->returnDoubleValueOrDefault(defaultValue), 0.005);
    DOUBLES_EQUAL(defaultValue, mock_c()->returnDoubleValueOrDefault(defaultValue), 0.005);
}
開發者ID:DynonAvionics,項目名稱:cpputest,代碼行數:7,代碼來源:MockSupport_cTest.cpp

示例6: TEST

TEST(PositioningTestGroup, OutputParamIsNULL)
{
    position_t p_a = {POINT_A_X, POINT_A_Y};
    position_t p_b = {POINT_B_X, POINT_B_Y};
    position_t p_c = {POINT_C_X, POINT_C_Y};

    reference_triangle_t t = {NULL, NULL, NULL, 0, 0, 0};

    positioning_reference_triangle_from_points(&p_a, &p_b, &p_c, &t);

    position_t some_point = {1.0f, 1.0f};

    Angles angles = Vec2D(&some_point).angles_relative_to_triangle(&t);

    position_t result = {0, 0};

    bool valid = positioning_from_angles(
            angles.alpha,
            angles.beta,
            angles.gamma,
            &t,
            NULL);
    CHECK(!valid);
    DOUBLES_EQUAL(0.0, result.x, 0.0001);
    DOUBLES_EQUAL(0.0, result.y, 0.0001);
}
開發者ID:31415us,項目名稱:beacons,代碼行數:26,代碼來源:positioning_test.cpp

示例7: TEST

TEST(RayTracer, can_compute_point) {
    RayTracer r(30, 20, Vect(0, 0, -1), Vect(0, 1, 0));

    Point_2D pt = r.computePoint(10, 5);
    DOUBLES_EQUAL(0.35, pt.x, 0.00001);
    DOUBLES_EQUAL(0.275, pt.y, 0.00001);
}
開發者ID:sondrele,項目名稱:NTNU,代碼行數:7,代碼來源:raytracer_test.cpp

示例8: TEST

TEST(Matrix, shouldHaveFourComponentVectorConstructor) {

  Matrix m(1, 2, 3, 4);
  
  DOUBLES_EQUAL(1.0, m.get(0), 0.0001);
  DOUBLES_EQUAL(2.0, m.get(1), 0.0001);
  DOUBLES_EQUAL(3.0, m.get(2), 0.0001);
  DOUBLES_EQUAL(4.0, m.get(3), 0.0001);
}
開發者ID:havardh,項目名稱:ECE594Q,代碼行數:9,代碼來源:MatrixTest.cpp

示例9: TEST

TEST(Mesh, shouldComputeBoundingBox) {


	Mesh *m = new MeshMock(values, 2, 2);

  BoundingBox box = m->getBoundingBox();

  DOUBLES_EQUAL(-1, box.getX(), 0.0001);
  DOUBLES_EQUAL(-3, box.getY(), 0.0001);
  DOUBLES_EQUAL(3, box.getDX(), 0.0001);
  DOUBLES_EQUAL(5, box.getDY(), 0.0001);

  delete m;
}
開發者ID:havardh,項目名稱:ECE594Q,代碼行數:14,代碼來源:MeshTest.cpp

示例10: functionThatReturnsAValue

static int functionThatReturnsAValue()
{
    CHECK(0 == 0);
    CHECK_TEXT(0 == 0, "Shouldn't fail");
    CHECK_TRUE(0 == 0);
    CHECK_TRUE_TEXT(0 == 0, "Shouldn't fail");
    CHECK_FALSE(0 != 0);
    CHECK_FALSE_TEXT(0 != 0, "Shouldn't fail");
    LONGS_EQUAL(1,1);
    LONGS_EQUAL_TEXT(1, 1, "Shouldn't fail");
    BYTES_EQUAL(0xab,0xab);
    BYTES_EQUAL_TEXT(0xab, 0xab, "Shouldn't fail");
    CHECK_EQUAL(100,100);
    CHECK_EQUAL_TEXT(100, 100, "Shouldn't fail");
    STRCMP_EQUAL("THIS", "THIS");
    STRCMP_EQUAL_TEXT("THIS", "THIS", "Shouldn't fail");
    DOUBLES_EQUAL(1.0, 1.0, .01);
    DOUBLES_EQUAL_TEXT(1.0, 1.0, .01, "Shouldn't fail");
    POINTERS_EQUAL(0, 0);
    POINTERS_EQUAL_TEXT(0, 0, "Shouldn't fail");
    MEMCMP_EQUAL("THIS", "THIS", 5);
    MEMCMP_EQUAL_TEXT("THIS", "THIS", 5, "Shouldn't fail");
    BITS_EQUAL(0x01, (unsigned char )0x01, 0xFF);
    BITS_EQUAL(0x0001, (unsigned short )0x0001, 0xFFFF);
    BITS_EQUAL(0x00000001, (unsigned long )0x00000001, 0xFFFFFFFF);
    BITS_EQUAL_TEXT(0x01, (unsigned char )0x01, 0xFF, "Shouldn't fail");
    return 0;
}
開發者ID:Andne,項目名稱:cpputest,代碼行數:28,代碼來源:TestUTestMacro.cpp

示例11: TEST

TEST(Vector, shouldComputeLength) {

  Vector v( 3, 3, 2 );

  DOUBLES_EQUAL( 4.69041576, v.length(), 0.0001 );
  
}
開發者ID:havardh,項目名稱:ECE594Q,代碼行數:7,代碼來源:VectorTest.cpp


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