From 3fe5c31fc0014dd38751a818c90f46852f3b3603 Mon Sep 17 00:00:00 2001 From: Romain BOULLARD Date: Sun, 17 May 2026 12:47:34 +0200 Subject: [PATCH] Use gtest recommandation and provide global environment through main --- .../Tests/Engine/EngineTests/Environment.cpp | 32 ------------------- Bigfoot/Tests/Engine/EngineTests/main.cpp | 19 +++++++++++ .../Tests/System/SystemTests/Environment.cpp | 32 ------------------- Bigfoot/Tests/System/SystemTests/main.cpp | 19 +++++++++++ .../Tests/Utils/UtilsTests/Environment.cpp | 32 ------------------- Bigfoot/Tests/Utils/UtilsTests/main.cpp | 19 +++++++++++ 6 files changed, 57 insertions(+), 96 deletions(-) delete mode 100644 Bigfoot/Tests/Engine/EngineTests/Environment.cpp create mode 100644 Bigfoot/Tests/Engine/EngineTests/main.cpp delete mode 100644 Bigfoot/Tests/System/SystemTests/Environment.cpp create mode 100644 Bigfoot/Tests/System/SystemTests/main.cpp delete mode 100644 Bigfoot/Tests/Utils/UtilsTests/Environment.cpp create mode 100644 Bigfoot/Tests/Utils/UtilsTests/main.cpp diff --git a/Bigfoot/Tests/Engine/EngineTests/Environment.cpp b/Bigfoot/Tests/Engine/EngineTests/Environment.cpp deleted file mode 100644 index be2a17f..0000000 --- a/Bigfoot/Tests/Engine/EngineTests/Environment.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/********************************************************************* - * \file Environment.cpp - * - * \author Romain BOULLARD - * \date May 2026 - *********************************************************************/ -#include -#include - -#include - -namespace Bigfoot -{ -class TestingEnvironment: public ::testing::Environment -{ - public: - void SetUp() override - { - BIGFOOT_NOT_OPTIMIZED_ONLY(m_lifetime.emplace()); - } - - void TearDown() override - { - BIGFOOT_NOT_OPTIMIZED_ONLY(m_lifetime.reset()); - } - - BIGFOOT_NOT_OPTIMIZED_ONLY(eastl::optional::Lifetime> m_lifetime); -}; -} // namespace Bigfoot - -// This runs before main() and registers the environment -const ::testing::Environment* const kEnv = ::testing::AddGlobalTestEnvironment(new Bigfoot::TestingEnvironment()); diff --git a/Bigfoot/Tests/Engine/EngineTests/main.cpp b/Bigfoot/Tests/Engine/EngineTests/main.cpp new file mode 100644 index 0000000..6645ee3 --- /dev/null +++ b/Bigfoot/Tests/Engine/EngineTests/main.cpp @@ -0,0 +1,19 @@ +/********************************************************************* + * \file main.cpp + * + * \author Romain BOULLARD + * \date May 2026 + *********************************************************************/ +#include +#include + +#include + +int main(int argc, char** argv) +{ + testing::InitGoogleTest(&argc, argv); + + BIGFOOT_NOT_OPTIMIZED_ONLY(::Bigfoot::Singleton<::Bigfoot::Log>::Lifetime m_lifetime); + + return RUN_ALL_TESTS(); +} diff --git a/Bigfoot/Tests/System/SystemTests/Environment.cpp b/Bigfoot/Tests/System/SystemTests/Environment.cpp deleted file mode 100644 index be2a17f..0000000 --- a/Bigfoot/Tests/System/SystemTests/Environment.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/********************************************************************* - * \file Environment.cpp - * - * \author Romain BOULLARD - * \date May 2026 - *********************************************************************/ -#include -#include - -#include - -namespace Bigfoot -{ -class TestingEnvironment: public ::testing::Environment -{ - public: - void SetUp() override - { - BIGFOOT_NOT_OPTIMIZED_ONLY(m_lifetime.emplace()); - } - - void TearDown() override - { - BIGFOOT_NOT_OPTIMIZED_ONLY(m_lifetime.reset()); - } - - BIGFOOT_NOT_OPTIMIZED_ONLY(eastl::optional::Lifetime> m_lifetime); -}; -} // namespace Bigfoot - -// This runs before main() and registers the environment -const ::testing::Environment* const kEnv = ::testing::AddGlobalTestEnvironment(new Bigfoot::TestingEnvironment()); diff --git a/Bigfoot/Tests/System/SystemTests/main.cpp b/Bigfoot/Tests/System/SystemTests/main.cpp new file mode 100644 index 0000000..6645ee3 --- /dev/null +++ b/Bigfoot/Tests/System/SystemTests/main.cpp @@ -0,0 +1,19 @@ +/********************************************************************* + * \file main.cpp + * + * \author Romain BOULLARD + * \date May 2026 + *********************************************************************/ +#include +#include + +#include + +int main(int argc, char** argv) +{ + testing::InitGoogleTest(&argc, argv); + + BIGFOOT_NOT_OPTIMIZED_ONLY(::Bigfoot::Singleton<::Bigfoot::Log>::Lifetime m_lifetime); + + return RUN_ALL_TESTS(); +} diff --git a/Bigfoot/Tests/Utils/UtilsTests/Environment.cpp b/Bigfoot/Tests/Utils/UtilsTests/Environment.cpp deleted file mode 100644 index be2a17f..0000000 --- a/Bigfoot/Tests/Utils/UtilsTests/Environment.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/********************************************************************* - * \file Environment.cpp - * - * \author Romain BOULLARD - * \date May 2026 - *********************************************************************/ -#include -#include - -#include - -namespace Bigfoot -{ -class TestingEnvironment: public ::testing::Environment -{ - public: - void SetUp() override - { - BIGFOOT_NOT_OPTIMIZED_ONLY(m_lifetime.emplace()); - } - - void TearDown() override - { - BIGFOOT_NOT_OPTIMIZED_ONLY(m_lifetime.reset()); - } - - BIGFOOT_NOT_OPTIMIZED_ONLY(eastl::optional::Lifetime> m_lifetime); -}; -} // namespace Bigfoot - -// This runs before main() and registers the environment -const ::testing::Environment* const kEnv = ::testing::AddGlobalTestEnvironment(new Bigfoot::TestingEnvironment()); diff --git a/Bigfoot/Tests/Utils/UtilsTests/main.cpp b/Bigfoot/Tests/Utils/UtilsTests/main.cpp new file mode 100644 index 0000000..6645ee3 --- /dev/null +++ b/Bigfoot/Tests/Utils/UtilsTests/main.cpp @@ -0,0 +1,19 @@ +/********************************************************************* + * \file main.cpp + * + * \author Romain BOULLARD + * \date May 2026 + *********************************************************************/ +#include +#include + +#include + +int main(int argc, char** argv) +{ + testing::InitGoogleTest(&argc, argv); + + BIGFOOT_NOT_OPTIMIZED_ONLY(::Bigfoot::Singleton<::Bigfoot::Log>::Lifetime m_lifetime); + + return RUN_ALL_TESTS(); +}