diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/AssetTest.cpp | 13 | ||||
-rw-r--r-- | src/test/RenderSystemTest.cpp | 8 | ||||
-rw-r--r-- | src/test/main.cpp | 23 |
3 files changed, 27 insertions, 17 deletions
diff --git a/src/test/AssetTest.cpp b/src/test/AssetTest.cpp index 8aa7629..93fd6a9 100644 --- a/src/test/AssetTest.cpp +++ b/src/test/AssetTest.cpp @@ -7,17 +7,12 @@ using namespace std; using namespace crepe; using namespace testing; -class AssetTest : public Test { -public: - Config & cfg = Config::get_instance(); - void SetUp() override { this->cfg.asset.root_pattern = ".crepe-root"; } -}; - -TEST_F(AssetTest, Existant) { ASSERT_NO_THROW(Asset{"asset/texture/img.png"}); } +TEST(AssetTest, Existant) { ASSERT_NO_THROW(Asset{"asset/texture/img.png"}); } -TEST_F(AssetTest, Nonexistant) { ASSERT_ANY_THROW(Asset{"asset/nonexistant"}); } +TEST(AssetTest, Nonexistant) { ASSERT_ANY_THROW(Asset{"asset/nonexistant"}); } -TEST_F(AssetTest, Rootless) { +TEST(AssetTest, Rootless) { + Config & cfg = Config::get_instance(); cfg.asset.root_pattern.clear(); string arbitrary = "\\/this is / /../passed through as-is"; diff --git a/src/test/RenderSystemTest.cpp b/src/test/RenderSystemTest.cpp index ac479d3..f37fb56 100644 --- a/src/test/RenderSystemTest.cpp +++ b/src/test/RenderSystemTest.cpp @@ -30,7 +30,7 @@ public: void SetUp() override { auto & sprite1 - = entity1.add_component<Sprite>(make_shared<Texture>("../asset/texture/img.png"), + = entity1.add_component<Sprite>(make_shared<Texture>("asset/texture/img.png"), Color(0, 0, 0, 0), FlipSettings{false, false}); ASSERT_NE(sprite1.sprite_image.get(), nullptr); sprite1.order_in_layer = 5; @@ -38,7 +38,7 @@ public: EXPECT_EQ(sprite1.order_in_layer, 5); EXPECT_EQ(sprite1.sorting_in_layer, 5); auto & sprite2 - = entity2.add_component<Sprite>(make_shared<Texture>("../asset/texture/img.png"), + = entity2.add_component<Sprite>(make_shared<Texture>("asset/texture/img.png"), Color(0, 0, 0, 0), FlipSettings{false, false}); ASSERT_NE(sprite2.sprite_image.get(), nullptr); sprite2.sorting_in_layer = 2; @@ -48,7 +48,7 @@ public: EXPECT_EQ(sprite2.order_in_layer, 1); auto & sprite3 - = entity3.add_component<Sprite>(make_shared<Texture>("../asset/texture/img.png"), + = entity3.add_component<Sprite>(make_shared<Texture>("asset/texture/img.png"), Color(0, 0, 0, 0), FlipSettings{false, false}); ASSERT_NE(sprite3.sprite_image.get(), nullptr); sprite3.sorting_in_layer = 1; @@ -58,7 +58,7 @@ public: EXPECT_EQ(sprite3.order_in_layer, 2); auto & sprite4 - = entity4.add_component<Sprite>(make_shared<Texture>("../asset/texture/img.png"), + = entity4.add_component<Sprite>(make_shared<Texture>("asset/texture/img.png"), Color(0, 0, 0, 0), FlipSettings{false, false}); ASSERT_NE(sprite4.sprite_image.get(), nullptr); sprite4.sorting_in_layer = 1; diff --git a/src/test/main.cpp b/src/test/main.cpp index 241015d..aece72d 100644 --- a/src/test/main.cpp +++ b/src/test/main.cpp @@ -1,15 +1,30 @@ -#include <crepe/api/Config.h> - #include <gtest/gtest.h> +#define protected public +#define private public + +#include <crepe/api/Config.h> + 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(); } |