コード例 #1
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
TEST(ArrayTest, CopyData)
{
    DoubleArray a;

    a.resize(6);

    a[0] = 1.23;
    a[1] = 4.56;
    a[2] = 7.89;

    double data[] = { 3.2, 1.0, 0.0 };
    
    a.copyData(data, 3, 3);

    ASSERT_DOUBLE_EQ(3.2, a[3]);
    ASSERT_DOUBLE_EQ(1.0, a[4]);
    ASSERT_DOUBLE_EQ(0.0, a[5]);

    DoubleArray b;
    b.resize(3);
    b[0] = 10.0;
    b[1] = 20.0;
    b[2] = 30.0;

    a.copyData(b, b.size(), 2, 0);

    ASSERT_DOUBLE_EQ(1.23, a[0]);
    ASSERT_DOUBLE_EQ(4.56, a[1]);
    ASSERT_DOUBLE_EQ(10.0, a[2]);
    ASSERT_DOUBLE_EQ(20.0, a[3]);
    ASSERT_DOUBLE_EQ(30.0, a[4]);
    ASSERT_DOUBLE_EQ(0.0, a[5]);
}