Exemplo n.º 1
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
TEST(ArrayTest, resize)
{
    // Vec3f array
    Vec3dArray vA;
    vA.resize(4);
    ASSERT_EQ(4u, vA.size());

    vA[0] = Vec3d(1,2,3);
    vA[1] = Vec3d(1.1, 2.2, 3.3);
    vA[2] = Vec3d(0,0,0);
    vA[3] = Vec3d(4,5,6);

    vA.resize(5);
    vA[4] = Vec3d(9.9, 0, 3.5);

    ASSERT_EQ(5u, vA.size());
    ASSERT_EQ(true, vA[0] == Vec3d(1,2,3));
    ASSERT_EQ(true, vA[4] == Vec3d(9.9,0,3.5));

    vA.resize(3);
    ASSERT_EQ(3u, vA.size());
    ASSERT_EQ(true, vA[0] == Vec3d(1, 2, 3));
    ASSERT_EQ(true, vA[1] == Vec3d(1.1, 2.2, 3.3));
    ASSERT_EQ(true, vA[2] == Vec3d(0, 0, 0));
}
Exemplo n.º 2
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
TEST(ArrayTest, CopyConvertedData)
{
    // Double array to float
    {
        DoubleArray ad;
        ad.resize(4);
        ad[0] = 0.0;
        ad[1] = 1.0;
        ad[2] = 2.0;
        ad[3] = 3.0;

        // Copy full array
        FloatArray af;
        af.resize(4);
        af.copyConvertedData(ad, 4, 0, 0);
        EXPECT_FLOAT_EQ(0.0f, af[0]);
        EXPECT_FLOAT_EQ(1.0f, af[1]);
        EXPECT_FLOAT_EQ(2.0f, af[2]);
        EXPECT_FLOAT_EQ(3.0f, af[3]);

        // Copy partial array to float array
        af.resize(2);
        af.setAll(0);
        af.copyConvertedData(ad, 2, 0, 1);

        EXPECT_FLOAT_EQ(1.0f, af[0]);
        EXPECT_FLOAT_EQ(2.0f, af[1]);
    }

    // Vec3d to Vec3f and Vec3i
    {
        Vec3dArray ad;
        ad.resize(2);
        ad[0].set(1.1, 2.5, 3.9);
        ad[1].set(11.1, 12.5, 13.9);

        Vec3fArray af;
        af.resize(2);
        af.copyConvertedData(ad, 2, 0, 0);
        EXPECT_FLOAT_EQ(1.1f,  af[0].x());
        EXPECT_FLOAT_EQ(2.5f,  af[0].y());
        EXPECT_FLOAT_EQ(3.9f,  af[0].z());
        EXPECT_FLOAT_EQ(11.1f, af[1].x());
        EXPECT_FLOAT_EQ(12.5f, af[1].y());
        EXPECT_FLOAT_EQ(13.9f, af[1].z());

        Array<Vec3i> ai;
        ai.resize(2);
        ai.copyConvertedData(ad, 2, 0, 0);
        EXPECT_EQ(1,  ai[0].x());
        EXPECT_EQ(2,  ai[0].y());
        EXPECT_EQ(3,  ai[0].z());
        EXPECT_EQ(11, ai[1].x());
        EXPECT_EQ(12, ai[1].y());
        EXPECT_EQ(13, ai[1].z());
    }
}
Exemplo n.º 3
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
TEST(ArrayTest, BasicVec3dArray)
{
    // Vec3f array
    Vec3dArray vA;
    vA.resize(4);
    ASSERT_EQ(4u, vA.size());

    vA[0] = Vec3d(1,2,3);
    vA[1] = Vec3d(1.1, 2.2, 3.3);
    vA[2] = Vec3d(0,0,0);
    vA[3] = Vec3d(4,5,6);

    ASSERT_EQ(true, vA[0] == Vec3d(1, 2, 3));
    ASSERT_EQ(true, vA[1] == Vec3d(1.1, 2.2, 3.3));
    ASSERT_EQ(true, vA[2] == Vec3d(0, 0, 0));
    ASSERT_EQ(true, vA[3] == Vec3d(4, 5, 6));

    const double* pf = vA.ptr()->ptr();

    ASSERT_DOUBLE_EQ(1.0, pf[0]);
    ASSERT_DOUBLE_EQ(2.0, pf[1]);
    ASSERT_DOUBLE_EQ(3.0, pf[2]);
    ASSERT_DOUBLE_EQ(1.1, pf[3]);
    ASSERT_DOUBLE_EQ(2.2, pf[4]);
    ASSERT_DOUBLE_EQ(3.3, pf[5]);
    ASSERT_DOUBLE_EQ(0.0, pf[6]);
    ASSERT_DOUBLE_EQ(0.0, pf[7]);
    ASSERT_DOUBLE_EQ(0.0, pf[8]);
    ASSERT_DOUBLE_EQ(4.0, pf[9]);
    ASSERT_DOUBLE_EQ(5.0, pf[10]);
    ASSERT_DOUBLE_EQ(6.0, pf[11]);

    vA.clear();

    ASSERT_EQ(0u, vA.size());
}