LauncherUnifiedTests.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 <AzTest/AzTest.h>
  9. #include "../Launcher.h"
  10. class UnifiedLauncherTestFixture
  11. : public ::testing::Test
  12. {
  13. protected:
  14. void SetUp() override {}
  15. void TearDown() override {}
  16. };
  17. TEST_F(UnifiedLauncherTestFixture, PlatformMainInfoAddArgument_NoCommandLineFunctions_Success)
  18. {
  19. O3DELauncher::PlatformMainInfo test;
  20. EXPECT_STREQ(test.m_commandLine, "");
  21. EXPECT_EQ(test.m_argC, 0);
  22. }
  23. TEST_F(UnifiedLauncherTestFixture, PlatformMainInfoAddArgument_ValidParams_Success)
  24. {
  25. O3DELauncher::PlatformMainInfo test;
  26. const char* testArguments[] = { "-arg", "value1", "-arg2", "value2", "-argspace", "value one"};
  27. for (const char* testArgument : testArguments)
  28. {
  29. test.AddArgument(testArgument);
  30. }
  31. EXPECT_STREQ(test.m_commandLine, "-arg value1 -arg2 value2 -argspace \"value one\"");
  32. EXPECT_EQ(test.m_argC, 6);
  33. EXPECT_STREQ(test.m_argV[0], "-arg");
  34. EXPECT_STREQ(test.m_argV[1], "value1");
  35. EXPECT_STREQ(test.m_argV[2], "-arg2");
  36. EXPECT_STREQ(test.m_argV[3], "value2");
  37. EXPECT_STREQ(test.m_argV[4], "-argspace");
  38. EXPECT_STREQ(test.m_argV[5], "value one");
  39. }
  40. TEST_F(UnifiedLauncherTestFixture, PlatformMainInfoCopyCommandLineArgCArgV_ValidParams_Success)
  41. {
  42. O3DELauncher::PlatformMainInfo test;
  43. const char* constTestArguments[] = { "-arg", "value1", "-arg2", "value2", "-argspace", "value one" };
  44. char** testArguments = const_cast<char**>(constTestArguments);
  45. int testArgumentCount = AZ_ARRAY_SIZE(constTestArguments);
  46. test.CopyCommandLine(testArgumentCount,testArguments);
  47. EXPECT_STREQ(test.m_commandLine, "-arg value1 -arg2 value2 -argspace \"value one\"");
  48. EXPECT_EQ(test.m_argC, 6);
  49. EXPECT_STREQ(test.m_argV[0], "-arg");
  50. EXPECT_STREQ(test.m_argV[1], "value1");
  51. EXPECT_STREQ(test.m_argV[2], "-arg2");
  52. EXPECT_STREQ(test.m_argV[3], "value2");
  53. EXPECT_STREQ(test.m_argV[4], "-argspace");
  54. EXPECT_STREQ(test.m_argV[5], "value one");
  55. }
  56. AZ_UNIT_TEST_HOOK(DEFAULT_UNIT_TEST_ENV);