From 004ee3aafb6beb4e984877186bced560010f4ddb Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Fri, 22 Nov 2024 21:57:08 +0100 Subject: fix RenderSystem unit test path resolution + reset Config before each test --- src/test/main.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/test/main.cpp') diff --git a/src/test/main.cpp b/src/test/main.cpp index 241015d..e03a989 100644 --- a/src/test/main.cpp +++ b/src/test/main.cpp @@ -1,15 +1,31 @@ -#include - #include +#define protected public +#define private public + +#include + using namespace crepe; using namespace testing; +class GlobalConfigReset : public EmptyTestEventListener { +public: + Config & cfg = Config::get_instance(); + Config cfg_default = Config(); + + // This function is called before each test + void OnTestStart(const TestInfo &) override { + cfg = cfg_default; + cfg.log.level = Log::Level::WARNING; + } +}; + int main(int argc, char ** argv) { InitGoogleTest(&argc, argv); - auto & cfg = Config::get_instance(); - cfg.log.level = Log::Level::ERROR; + UnitTest & ut = *UnitTest::GetInstance(); + ut.listeners().Append(new GlobalConfigReset); return RUN_ALL_TESTS(); } + -- cgit v1.2.3 From ba8c5d5feae48036405f3cdd920dac421fdb6184 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sun, 24 Nov 2024 18:56:41 +0100 Subject: `make format` --- src/test/AssetTest.cpp | 1 - src/test/main.cpp | 1 - 2 files changed, 2 deletions(-) (limited to 'src/test/main.cpp') diff --git a/src/test/AssetTest.cpp b/src/test/AssetTest.cpp index c3c166c..93fd6a9 100644 --- a/src/test/AssetTest.cpp +++ b/src/test/AssetTest.cpp @@ -19,4 +19,3 @@ TEST(AssetTest, Rootless) { Asset asset{arbitrary}; ASSERT_EQ(arbitrary, asset.get_path()); } - diff --git a/src/test/main.cpp b/src/test/main.cpp index e03a989..aece72d 100644 --- a/src/test/main.cpp +++ b/src/test/main.cpp @@ -28,4 +28,3 @@ int main(int argc, char ** argv) { return RUN_ALL_TESTS(); } - -- cgit v1.2.3