mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
added operator for matrix
This commit is contained in:
@@ -37,6 +37,13 @@ namespace omath
|
||||
[[nodiscard]]
|
||||
OMATH_API size_t RowCount() const noexcept;
|
||||
|
||||
|
||||
[[nodiscard]]
|
||||
OMATH_API float& operator[](size_t row, size_t column)
|
||||
{
|
||||
return At(row, column);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
OMATH_API size_t ColumnsCount() const noexcept;
|
||||
|
||||
|
||||
@@ -29,6 +29,15 @@ TEST_F(UnitTestMatrix, Constructor_Size)
|
||||
EXPECT_EQ(m.ColumnsCount(), 3);
|
||||
}
|
||||
|
||||
TEST_F(UnitTestMatrix, Operator_SquareBrackets)
|
||||
{
|
||||
EXPECT_EQ((m2[0, 0]), 1.0f);
|
||||
EXPECT_EQ((m2[0, 1]), 2.0f);
|
||||
EXPECT_EQ((m2[1, 0]), 3.0f);
|
||||
EXPECT_EQ((m2[1, 1]), 4.0f);
|
||||
}
|
||||
|
||||
|
||||
TEST_F(UnitTestMatrix, Constructor_InitializerList)
|
||||
{
|
||||
Matrix m{{1.0f, 2.0f}, {3.0f, 4.0f}};
|
||||
|
||||
Reference in New Issue
Block a user