TestMain.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 <AzFramework/Platform/PlatformDefaults.h>
  9. #include <AzCore/std/smart_ptr/make_shared.h>
  10. #include <AzCore/UnitTest/TestTypes.h>
  11. #include <AzTest/AzTest.h>
  12. #include <AzTest/Utils.h>
  13. #include <AzTest/AzTest.h>
  14. #include <QApplication>
  15. DECLARE_AZ_UNIT_TEST_MAIN();
  16. int runDefaultRunner(int argc, char* argv[])
  17. {
  18. INVOKE_AZ_UNIT_TEST_MAIN(nullptr);
  19. return 0;
  20. }
  21. int main(int argc, char* argv[])
  22. {
  23. const AZ::Debug::Trace tracer;
  24. AZ::Debug::Trace::HandleExceptions(true);
  25. QApplication app(argc, argv);
  26. AZ::Test::ApplyGlobalParameters(&argc, argv);
  27. // ran with no parameters?
  28. if (argc == 1)
  29. {
  30. constexpr int defaultArgc = 2;
  31. char unittest_arg[] = "--unittests"; // Conversion from string literal to char* is not allowed per ISO C++11
  32. char* defaultArgv[defaultArgc] =
  33. {
  34. argv[0],
  35. unittest_arg
  36. };
  37. return runDefaultRunner(defaultArgc, defaultArgv);
  38. }
  39. INVOKE_AZ_UNIT_TEST_MAIN(nullptr);
  40. return 0;
  41. }