HemisphereTests.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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/Hemisphere.h>
  9. #include <AzCore/UnitTest/TestTypes.h>
  10. #include <AZTestShared/Math/MathTestHelpers.h>
  11. namespace UnitTest
  12. {
  13. TEST(MATH_Hemisphere, TestConstruct)
  14. {
  15. AZ::Vector3 pos = AZ::Vector3(10.0f, 10.0f, 10.0f);
  16. float radius = 15.0f;
  17. AZ::Vector3 direction = AZ::Vector3(1.0f, 0.0f, 0.0f);
  18. AZ::Hemisphere hemisphere(pos, radius, direction);
  19. EXPECT_EQ(hemisphere.GetCenter(), pos);
  20. EXPECT_EQ(hemisphere.GetRadius(), radius);
  21. EXPECT_EQ(hemisphere.GetDirection(), direction);
  22. }
  23. TEST(MATH_Hemisphere, TestSet)
  24. {
  25. AZ::Vector3 pos = AZ::Vector3(10.0f, 10.0f, 10.0f);
  26. float radius = 15.0f;
  27. AZ::Vector3 direction = AZ::Vector3(1.0f, 0.0f, 0.0f);
  28. AZ::Hemisphere hemisphere;
  29. hemisphere.SetCenter(pos);
  30. hemisphere.SetRadius(radius);
  31. hemisphere.SetDirection(direction);
  32. EXPECT_EQ(hemisphere.GetCenter(), pos);
  33. EXPECT_EQ(hemisphere.GetRadius(), radius);
  34. EXPECT_EQ(hemisphere.GetDirection(), direction);
  35. }
  36. TEST(MATH_Hemisphere, TestAssignment)
  37. {
  38. AZ::Vector3 pos = AZ::Vector3(10.0f, 10.0f, 10.0f);
  39. float radius = 15.0f;
  40. AZ::Vector3 direction = AZ::Vector3(1.0f, 0.0f, 0.0f);
  41. AZ::Hemisphere hemisphere1(pos, radius, direction);
  42. AZ::Vector3 newPos = AZ::Vector3(20.0f, 20.0f, 20.0f);
  43. float newRadius = 25.0f;
  44. AZ::Vector3 newDirection = AZ::Vector3(0.0f, 1.0f, 0.0f);
  45. AZ::Hemisphere hemisphere2(newPos, newRadius, newDirection);
  46. hemisphere1 = hemisphere2;
  47. EXPECT_EQ(hemisphere1, hemisphere2);
  48. }
  49. } // namespace UnitTest