diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-11-04 16:19:54 +0100 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-11-04 16:19:54 +0100 |
commit | ad148587dcf5244c2d2011dba339786c765c54c4 (patch) | |
tree | bdd914121cd326da2ed26679838878e3edffc841 /src/unittest/test.cpp | |
parent | 1145b05ea0bda87dc0827821385810eced08f774 (diff) | |
download | dragonfireclient-ad148587dcf5244c2d2011dba339786c765c54c4.tar.xz |
Make Lint Happy
Diffstat (limited to 'src/unittest/test.cpp')
-rw-r--r-- | src/unittest/test.cpp | 89 |
1 files changed, 43 insertions, 46 deletions
diff --git a/src/unittest/test.cpp b/src/unittest/test.cpp index 0f6b36649..55471746a 100644 --- a/src/unittest/test.cpp +++ b/src/unittest/test.cpp @@ -41,7 +41,8 @@ content_t t_CONTENT_BRICK; //// TestGameDef //// -class TestGameDef : public IGameDef { +class TestGameDef : public IGameDef +{ public: TestGameDef(); ~TestGameDef(); @@ -69,13 +70,17 @@ public: static std::vector<ModSpec> testmodspec; return testmodspec; } - virtual const ModSpec* getModSpec(const std::string &modname) const { return NULL; } + virtual const ModSpec *getModSpec(const std::string &modname) const + { + return NULL; + } virtual std::string getModStoragePath() const { return "."; } virtual bool registerModStorage(ModMetadata *meta) { return true; } virtual void unregisterModStorage(const std::string &name) {} bool joinModChannel(const std::string &channel); bool leaveModChannel(const std::string &channel); - bool sendModChannelMessage(const std::string &channel, const std::string &message); + bool sendModChannelMessage( + const std::string &channel, const std::string &message); ModChannel *getModChannel(const std::string &channel) { return m_modchannel_mgr->getModChannel(channel); @@ -94,9 +99,7 @@ private: std::unique_ptr<ModChannelMgr> m_modchannel_mgr; }; - -TestGameDef::TestGameDef() : - m_modchannel_mgr(new ModChannelMgr()) +TestGameDef::TestGameDef() : m_modchannel_mgr(new ModChannelMgr()) { m_itemdef = createItemDefManager(); m_nodedef = createNodeDefManager(); @@ -104,14 +107,12 @@ TestGameDef::TestGameDef() : defineSomeNodes(); } - TestGameDef::~TestGameDef() { delete m_itemdef; delete m_nodedef; } - void TestGameDef::defineSomeNodes() { IWritableItemDefManager *idef = (IWritableItemDefManager *)m_itemdef; @@ -127,9 +128,9 @@ void TestGameDef::defineSomeNodes() itemdef.description = "Stone"; itemdef.groups["cracky"] = 3; itemdef.inventory_image = "[inventorycube" - "{default_stone.png" - "{default_stone.png" - "{default_stone.png"; + "{default_stone.png" + "{default_stone.png" + "{default_stone.png"; f = ContentFeatures(); f.name = itemdef.name; for (TileDef &tiledef : f.tiledef) @@ -145,14 +146,14 @@ void TestGameDef::defineSomeNodes() itemdef.description = "Dirt with grass"; itemdef.groups["crumbly"] = 3; itemdef.inventory_image = "[inventorycube" - "{default_grass.png" - "{default_dirt.png&default_grass_side.png" - "{default_dirt.png&default_grass_side.png"; + "{default_grass.png" + "{default_dirt.png&default_grass_side.png" + "{default_dirt.png&default_grass_side.png"; f = ContentFeatures(); f.name = itemdef.name; f.tiledef[0].name = "default_grass.png"; f.tiledef[1].name = "default_dirt.png"; - for(int i = 2; i < 6; i++) + for (int i = 2; i < 6; i++) f.tiledef[i].name = "default_dirt.png^default_grass_side.png"; f.is_ground_content = true; idef->registerItem(itemdef); @@ -167,7 +168,7 @@ void TestGameDef::defineSomeNodes() f.param_type = CPT_LIGHT; f.light_propagates = true; f.sunlight_propagates = true; - f.light_source = LIGHT_MAX-1; + f.light_source = LIGHT_MAX - 1; idef->registerItem(itemdef); t_CONTENT_TORCH = ndef->set(f.name, f); @@ -177,9 +178,9 @@ void TestGameDef::defineSomeNodes() itemdef.name = "default:water"; itemdef.description = "Water"; itemdef.inventory_image = "[inventorycube" - "{default_water.png" - "{default_water.png" - "{default_water.png"; + "{default_water.png" + "{default_water.png" + "{default_water.png"; f = ContentFeatures(); f.name = itemdef.name; f.alpha = 128; @@ -198,15 +199,15 @@ void TestGameDef::defineSomeNodes() itemdef.name = "default:lava"; itemdef.description = "Lava"; itemdef.inventory_image = "[inventorycube" - "{default_lava.png" - "{default_lava.png" - "{default_lava.png"; + "{default_lava.png" + "{default_lava.png" + "{default_lava.png"; f = ContentFeatures(); f.name = itemdef.name; f.alpha = 128; f.liquid_type = LIQUID_SOURCE; f.liquid_viscosity = 7; - f.light_source = LIGHT_MAX-1; + f.light_source = LIGHT_MAX - 1; f.is_ground_content = true; f.groups["liquids"] = 3; for (TileDef &tiledef : f.tiledef) @@ -214,7 +215,6 @@ void TestGameDef::defineSomeNodes() idef->registerItem(itemdef); t_CONTENT_LAVA = ndef->set(f.name, f); - //// Brick itemdef = ItemDefinition(); itemdef.type = ITEM_NODE; @@ -222,9 +222,9 @@ void TestGameDef::defineSomeNodes() itemdef.description = "Brick"; itemdef.groups["cracky"] = 3; itemdef.inventory_image = "[inventorycube" - "{default_brick.png" - "{default_brick.png" - "{default_brick.png"; + "{default_brick.png" + "{default_brick.png" + "{default_brick.png"; f = ContentFeatures(); f.name = itemdef.name; for (TileDef &tiledef : f.tiledef) @@ -244,8 +244,8 @@ bool TestGameDef::leaveModChannel(const std::string &channel) return m_modchannel_mgr->leaveChannel(channel, PEER_ID_SERVER); } -bool TestGameDef::sendModChannelMessage(const std::string &channel, - const std::string &message) +bool TestGameDef::sendModChannelMessage( + const std::string &channel, const std::string &message) { if (!m_modchannel_mgr->channelRegistered(channel)) return false; @@ -264,9 +264,9 @@ bool run_tests() g_logger.setLevelSilenced(LL_ERROR, true); - u32 num_modules_failed = 0; + u32 num_modules_failed = 0; u32 num_total_tests_failed = 0; - u32 num_total_tests_run = 0; + u32 num_total_tests_run = 0; std::vector<TestBase *> &testmods = TestManager::getTestModules(); for (size_t i = 0; i != testmods.size(); i++) { if (!testmods[i]->testModule(&gamedef)) @@ -282,16 +282,15 @@ bool run_tests() const char *overall_status = (num_modules_failed == 0) ? "PASSED" : "FAILED"; - rawstream - << "++++++++++++++++++++++++++++++++++++++++" - << "++++++++++++++++++++++++++++++++++++++++" << std::endl - << "Unit Test Results: " << overall_status << std::endl - << " " << num_modules_failed << " / " << testmods.size() - << " failed modules (" << num_total_tests_failed << " / " - << num_total_tests_run << " failed individual tests)." << std::endl - << " Testing took " << tdiff << "ms total." << std::endl - << "++++++++++++++++++++++++++++++++++++++++" - << "++++++++++++++++++++++++++++++++++++++++" << std::endl; + rawstream << "++++++++++++++++++++++++++++++++++++++++" + << "++++++++++++++++++++++++++++++++++++++++" << std::endl + << "Unit Test Results: " << overall_status << std::endl + << " " << num_modules_failed << " / " << testmods.size() + << " failed modules (" << num_total_tests_failed << " / " + << num_total_tests_run << " failed individual tests)." << std::endl + << " Testing took " << tdiff << "ms total." << std::endl + << "++++++++++++++++++++++++++++++++++++++++" + << "++++++++++++++++++++++++++++++++++++++++" << std::endl; return num_modules_failed; } @@ -305,14 +304,13 @@ bool TestBase::testModule(IGameDef *gamedef) rawstream << "======== Testing module " << getName() << std::endl; u64 t1 = porting::getTimeMs(); - runTests(gamedef); u64 tdiff = porting::getTimeMs() - t1; rawstream << "======== Module " << getName() << " " - << (num_tests_failed ? "failed" : "passed") << " (" << num_tests_failed - << " failures / " << num_tests_run << " tests) - " << tdiff - << "ms" << std::endl; + << (num_tests_failed ? "failed" : "passed") << " (" << num_tests_failed + << " failures / " << num_tests_run << " tests) - " << tdiff << "ms" + << std::endl; if (!m_test_dir.empty()) fs::RecursiveDelete(m_test_dir); @@ -343,7 +341,6 @@ std::string TestBase::getTestTempFile() return getTestTempDirectory() + DIR_DELIM + buf + ".tmp"; } - /* NOTE: These tests became non-working then NodeContainer was removed. These should be redone, utilizing some kind of a virtual |