mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-13 01:30:34 +08:00
matrix: fix slice to slice assignment to do deep copy
To fix usage of a.xy() = b.xy() which should copy the first two elements over into a and not act on a copy of a.
This commit is contained in:
@@ -262,3 +262,12 @@ TEST(MatrixSliceTest, Slice)
|
||||
float O_check_data_12 [4] = {2.5, 3, 4, 5};
|
||||
EXPECT_EQ(res_12, (SquareMatrix<float, 2>(O_check_data_12)));
|
||||
}
|
||||
|
||||
TEST(MatrixSliceTest, XYAssignmentTest)
|
||||
{
|
||||
Vector3f a(1, 2, 3);
|
||||
Vector3f b(4, 5, 6);
|
||||
// Assign first two elements from b to first two slot of a
|
||||
a.xy() = b.xy();
|
||||
EXPECT_EQ(a, Vector3f(4, 5, 3));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user