GraphCanvasTranslation.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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/Component/ComponentApplication.h>
  9. #include <AzCore/Jobs/JobManagerComponent.h>
  10. #include <AzCore/Memory/PoolAllocator.h>
  11. #include <AzTest/AzTest.h>
  12. #include <Translation/TranslationBus.h>
  13. class GraphCanvasTranslationTests : public ::testing::Test
  14. {
  15. protected:
  16. void SetUp() override
  17. {
  18. AZ::ComponentApplication::Descriptor appDesc;
  19. appDesc.m_memoryBlocksByteSize = 20 * 1024 * 1024;
  20. appDesc.m_recordingMode = AZ::Debug::AllocationRecords::Mode::RECORD_NO_RECORDS;
  21. AZ::ComponentApplication::StartupParameters startupParameters;
  22. startupParameters.m_loadSettingsRegistry = false;
  23. m_app.Create(appDesc, startupParameters);
  24. }
  25. void TearDown() override
  26. {
  27. m_app.Destroy();
  28. }
  29. AZ::ComponentApplication m_app;
  30. };
  31. TEST_F(GraphCanvasTranslationTests, TranslationKey)
  32. {
  33. GraphCanvas::TranslationKey key1("Constructed");
  34. EXPECT_STRCASEEQ(key1.ToString().c_str(), "Constructed");
  35. GraphCanvas::TranslationKey key2;
  36. // Test key assignment
  37. key2 = "START";
  38. EXPECT_EQ(key2, "START");
  39. // Test key concatenation with const char*
  40. key2 << "TEST";
  41. EXPECT_EQ(key2, "START.TEST");
  42. // Test key concatenation with AZStd::string
  43. AZStd::string test1 = "STRING";
  44. key2 << test1;
  45. EXPECT_EQ(key2, "START.TEST.STRING");
  46. // Test clear
  47. key2.clear();
  48. EXPECT_EQ(key2, "");
  49. // Test Key assignment into AZStd::string
  50. key2 << "NEW";
  51. AZStd::string test2 = key2;
  52. EXPECT_STRCASEEQ(test2.c_str(), key2.ToString().c_str());
  53. GraphCanvas::TranslationKey key3 = key2;
  54. // Compare Key to Key
  55. EXPECT_EQ(key2, key3);
  56. // Compare Key to const char*
  57. EXPECT_EQ(key3, "NEW");
  58. }