FeatureMatrixTests.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <Fixture.h>
  9. #include <FeatureMatrix.h>
  10. namespace EMotionFX::MotionMatching
  11. {
  12. class FeatureMatrixFixture
  13. : public Fixture
  14. {
  15. public:
  16. void SetUp() override
  17. {
  18. Fixture::SetUp();
  19. // Construct 3x3 matrix:
  20. // 1 2 3
  21. // 4 5 6
  22. // 7 8 9
  23. m_featureMatrix.resize(3, 3);
  24. float counter = 1.0f;
  25. for (size_t row = 0; row < 3; ++row)
  26. {
  27. for (size_t column = 0; column < 3; ++column)
  28. {
  29. m_featureMatrix(row, column) = counter;
  30. counter++;
  31. }
  32. }
  33. }
  34. FeatureMatrix m_featureMatrix;
  35. };
  36. TEST_F(FeatureMatrixFixture, AccessOperators)
  37. {
  38. EXPECT_FLOAT_EQ(m_featureMatrix(1, 1), 5.0f);
  39. EXPECT_FLOAT_EQ(m_featureMatrix(0, 2), 3.0f);
  40. EXPECT_FLOAT_EQ(m_featureMatrix.coeff(2, 1), 8.0f);
  41. EXPECT_FLOAT_EQ(m_featureMatrix.coeff(1, 2), 6.0f);
  42. }
  43. TEST_F(FeatureMatrixFixture, SetValue)
  44. {
  45. m_featureMatrix(1, 1) = 100.0f;
  46. EXPECT_FLOAT_EQ(m_featureMatrix(1, 1), 100.0f);
  47. }
  48. TEST_F(FeatureMatrixFixture, Size)
  49. {
  50. EXPECT_EQ(m_featureMatrix.size(), 9);
  51. EXPECT_EQ(m_featureMatrix.rows(), 3);
  52. EXPECT_EQ(m_featureMatrix.cols(), 3);
  53. }
  54. } // EMotionFX::MotionMatching