2
0

Geometry3DUtilsTests.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  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 <AzCore/Math/Geometry3DUtils.h>
  9. #include <AzCore/UnitTest/TestTypes.h>
  10. namespace UnitTest
  11. {
  12. class Geometry3DUtilsFixture :
  13. public UnitTest::LeakDetectionFixture,
  14. public ::testing::WithParamInterface<uint8_t>
  15. {
  16. };
  17. TEST_P(Geometry3DUtilsFixture, IcoSphere_UnitRadius)
  18. {
  19. const AZStd::vector<AZ::Vector3> icoSphere = AZ::Geometry3dUtils::GenerateIcoSphere(GetParam());
  20. float minRadius = AZ::Constants::FloatMax;
  21. float maxRadius = 0;
  22. for (const auto& vertex : icoSphere)
  23. {
  24. const float radius = vertex.GetLength();
  25. minRadius = AZ::GetMin(minRadius, radius);
  26. maxRadius = AZ::GetMax(maxRadius, radius);
  27. }
  28. EXPECT_NEAR(minRadius, 1.0f, 1e-3f);
  29. EXPECT_NEAR(maxRadius, 1.0f, 1e-3f);
  30. }
  31. INSTANTIATE_TEST_SUITE_P(MATH_Geometry3DUtilsTests, Geometry3DUtilsFixture, ::testing::Values(0u, 1u, 2u, 3u));
  32. } // namespace UnitTest