2
0

SpawnableEntitiesInterfaceTests.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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/UnitTest/TestTypes.h>
  9. #include <AzCore/std/containers/array.h>
  10. #include <AzFramework/Spawnable/SpawnableEntitiesInterface.h>
  11. #include <AzTest/AzTest.h>
  12. namespace UnitTest
  13. {
  14. //
  15. // SpawnableEntityContainerView
  16. //
  17. class SpawnableEntityContainerViewTest : public ::testing::Test
  18. {
  19. protected:
  20. AZStd::array<AZ::Entity*, 4> m_values{ reinterpret_cast<AZ::Entity*>(1), reinterpret_cast<AZ::Entity*>(2),
  21. reinterpret_cast<AZ::Entity*>(3), reinterpret_cast<AZ::Entity*>(4) };
  22. AzFramework::SpawnableEntityContainerView m_view{ m_values.begin(), m_values.end() };
  23. };
  24. TEST_F(SpawnableEntityContainerViewTest, begin_Get_MatchesBeginOfArray)
  25. {
  26. EXPECT_EQ(m_view.begin(), m_values.begin());
  27. }
  28. TEST_F(SpawnableEntityContainerViewTest, end_Get_MatchesEndOfArray)
  29. {
  30. EXPECT_EQ(m_view.end(), m_values.end());
  31. }
  32. TEST_F(SpawnableEntityContainerViewTest, cbegin_Get_MatchesBeginOfArray)
  33. {
  34. EXPECT_EQ(m_view.cbegin(), m_values.cbegin());
  35. }
  36. TEST_F(SpawnableEntityContainerViewTest, cend_Get_MatchesEndOfArray)
  37. {
  38. EXPECT_EQ(m_view.cend(), m_values.cend());
  39. }
  40. TEST_F(SpawnableEntityContainerViewTest, IndexOperator_Get_MatchesThirdElement)
  41. {
  42. EXPECT_EQ(m_view[2], m_values[2]);
  43. }
  44. TEST_F(SpawnableEntityContainerViewTest, Size_Get_MatchesSizeOfArray)
  45. {
  46. EXPECT_EQ(m_view.size(), m_values.size());
  47. }
  48. TEST_F(SpawnableEntityContainerViewTest, empty_GetFromFilledArray_ReturnsFalse)
  49. {
  50. EXPECT_FALSE(m_view.empty());
  51. }
  52. TEST_F(SpawnableEntityContainerViewTest, empty_GetFromEmtpyView_ReturnsTrue)
  53. {
  54. AzFramework::SpawnableEntityContainerView view{ nullptr, nullptr };
  55. EXPECT_TRUE(view.empty());
  56. }
  57. //
  58. // SpawnableConstEntityContainerView
  59. //
  60. class SpawnableConstEntityContainerViewTest : public ::testing::Test
  61. {
  62. protected:
  63. AZStd::array<AZ::Entity*, 4> m_values{ reinterpret_cast<AZ::Entity*>(1), reinterpret_cast<AZ::Entity*>(2),
  64. reinterpret_cast<AZ::Entity*>(3), reinterpret_cast<AZ::Entity*>(4) };
  65. AzFramework::SpawnableConstEntityContainerView m_view{ m_values.begin(), m_values.end() };
  66. };
  67. TEST_F(SpawnableConstEntityContainerViewTest, begin_Get_MatchesBeginOfArray)
  68. {
  69. EXPECT_EQ(m_view.begin(), m_values.begin());
  70. }
  71. TEST_F(SpawnableConstEntityContainerViewTest, end_Get_MatchesEndOfArray)
  72. {
  73. EXPECT_EQ(m_view.end(), m_values.end());
  74. }
  75. TEST_F(SpawnableConstEntityContainerViewTest, cbegin_Get_MatchesBeginOfArray)
  76. {
  77. EXPECT_EQ(m_view.cbegin(), m_values.cbegin());
  78. }
  79. TEST_F(SpawnableConstEntityContainerViewTest, cend_Get_MatchesEndOfArray)
  80. {
  81. EXPECT_EQ(m_view.cend(), m_values.cend());
  82. }
  83. TEST_F(SpawnableConstEntityContainerViewTest, IndexOperator_Get_MatchesThirdElement)
  84. {
  85. EXPECT_EQ(m_view[2], m_values[2]);
  86. }
  87. TEST_F(SpawnableConstEntityContainerViewTest, size_Get_MatchesSizeOfArray)
  88. {
  89. EXPECT_EQ(m_view.size(), m_values.size());
  90. }
  91. TEST_F(SpawnableConstEntityContainerViewTest, empty_GetFromFilledArray_ReturnsFalse)
  92. {
  93. EXPECT_FALSE(m_view.empty());
  94. }
  95. TEST_F(SpawnableConstEntityContainerViewTest, empty_GetFromEmtpyView_ReturnsTrue)
  96. {
  97. AzFramework::SpawnableConstEntityContainerView view{ nullptr, nullptr };
  98. EXPECT_TRUE(view.empty());
  99. }
  100. } // namespace UnitTest