diff options
Diffstat (limited to 'src')
24 files changed, 178 insertions, 184 deletions
diff --git a/src/actormanager.cpp b/src/actormanager.cpp index 499652659..4bf4e2d53 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -1980,7 +1980,7 @@ int ActorManager::getPickupItemIndex(const std::string &name) const i_end = list.end();\ while (i != i_end)\ {\ - if (*i == "")\ + if ((*i).empty())\ empty = true;\ m##mob##s.push_back(*i);\ m##mob##sSet.insert(*i);\ diff --git a/src/being/being.cpp b/src/being/being.cpp index 4db35b3c3..a2cdf110f 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -4492,7 +4492,6 @@ void Being::searchSlotValueItr(std::vector<int>::iterator &restrict it, } // logger->log("not found"); idx = -1; - return; } void Being::updateHit(const int amount) restrict2 diff --git a/src/configmanager.cpp b/src/configmanager.cpp index f9c7c447e..c2e7a4c02 100644 --- a/src/configmanager.cpp +++ b/src/configmanager.cpp @@ -181,7 +181,7 @@ void ConfigManager::backupConfig(const std::string &name) } if (Files::loadTextFileLocal(fileName3, arr) == true) { - if (arr.size() == 0) + if (arr.empty()) return; arr.clear(); @@ -189,7 +189,7 @@ void ConfigManager::backupConfig(const std::string &name) name).append(".tmp"); Files::copyFile(fileName3, tmpName); if (Files::loadTextFileLocal(tmpName, arr) == false || - arr.size() == 0) + arr.empty()) { logger->safeError("Error backuping configs. " "Probably no free space on disk."); diff --git a/src/fs/files_unittest.cc b/src/fs/files_unittest.cc index 0a4391f32..c658c34af 100644 --- a/src/fs/files_unittest.cc +++ b/src/fs/files_unittest.cc @@ -126,7 +126,7 @@ TEST_CASE("Files saveTextFile", "") VirtFs::mountDirSilent("../data", Append_false); const std::string dir = VirtFs::getPath("test"); - REQUIRE(dir.size() > 0); + REQUIRE(!dir.empty()); Files::saveTextFile(dir, "tempfile.txt", "test line\ntext line2"); std::string data = VirtFs::loadTextFileString("test/tempfile.txt"); ::remove((dir + "/tempfile.txt").c_str()); @@ -151,7 +151,7 @@ TEST_CASE("Files copyFile1", "") VirtFs::mountDirSilent("../data", Append_false); const std::string dir = VirtFs::getPath("test"); - REQUIRE(dir.size() > 0); + REQUIRE(!dir.empty()); SECTION("copy") { REQUIRE(Files::copyFile(pathJoin(dir, "test.txt"), @@ -183,7 +183,7 @@ TEST_CASE("Files loadTextFileLocal", "") VirtFs::mountDirSilent("../data", Append_false); const std::string dir = VirtFs::getPath("test"); - REQUIRE(dir.size() > 0); + REQUIRE(!dir.empty()); Files::saveTextFile(dir, "tempfile.txt", "test line\ntext line2"); StringVect lines; REQUIRE(Files::loadTextFileLocal(pathJoin(dir, "tempfile.txt"), diff --git a/src/fs/virtfs/fs.cpp b/src/fs/virtfs/fs.cpp index 8a708a9fa..b4847ad13 100644 --- a/src/fs/virtfs/fs.cpp +++ b/src/fs/virtfs/fs.cpp @@ -682,7 +682,7 @@ namespace VirtFs FsEntry *const entry = *it; if (entry->root == oldDir && entry->type == FsEntryType::Zip && - entry->subDir == std::string()) + entry->subDir.empty()) { ZipEntry *const zipEntry = static_cast<ZipEntry*>( entry); diff --git a/src/fs/virtfs/virtfs1_unittest.cc b/src/fs/virtfs/virtfs1_unittest.cc index 87ecd1671..4bec32e5b 100644 --- a/src/fs/virtfs/virtfs1_unittest.cc +++ b/src/fs/virtfs/virtfs1_unittest.cc @@ -71,7 +71,7 @@ TEST_CASE("VirtFs1 mountDir", "") nullptr); REQUIRE(VirtFs::getEntries().size() == 1); REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); REQUIRE(static_cast<VirtFs::DirEntry*>( VirtFs::getEntries()[0])->userDir == "dir1"); @@ -89,7 +89,7 @@ TEST_CASE("VirtFs1 mountDir", "") nullptr); REQUIRE(VirtFs::getEntries().size() == 1); REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); REQUIRE(static_cast<VirtFs::DirEntry*>( VirtFs::getEntries()[0])->userDir == "dir1" + sep); @@ -114,8 +114,8 @@ TEST_CASE("VirtFs1 mountDir", "") REQUIRE(VirtFs::getEntries()[1]->root == "dir1" + sep); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); - REQUIRE(VirtFs::getEntries()[1]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); + REQUIRE(VirtFs::getEntries()[1]->subDir.empty()); REQUIRE(static_cast<VirtFs::DirEntry*>( VirtFs::getEntries()[0])->userDir == "dir2"); REQUIRE(static_cast<VirtFs::DirEntry*>( @@ -139,8 +139,8 @@ TEST_CASE("VirtFs1 mountDir", "") REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); - REQUIRE(VirtFs::getEntries()[1]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); + REQUIRE(VirtFs::getEntries()[1]->subDir.empty()); REQUIRE(static_cast<VirtFs::DirEntry*>( VirtFs::getEntries()[0])->userDir == "dir1" + sep); REQUIRE(static_cast<VirtFs::DirEntry*>( @@ -170,9 +170,9 @@ TEST_CASE("VirtFs1 mountDir", "") REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir); REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Dir); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); - REQUIRE(VirtFs::getEntries()[1]->subDir == std::string()); - REQUIRE(VirtFs::getEntries()[2]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); + REQUIRE(VirtFs::getEntries()[1]->subDir.empty()); + REQUIRE(VirtFs::getEntries()[2]->subDir.empty()); REQUIRE(static_cast<VirtFs::DirEntry*>( VirtFs::getEntries()[0])->userDir == "dir1"); REQUIRE(static_cast<VirtFs::DirEntry*>( @@ -204,9 +204,9 @@ TEST_CASE("VirtFs1 mountDir", "") REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir); REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Dir); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); - REQUIRE(VirtFs::getEntries()[1]->subDir == std::string()); - REQUIRE(VirtFs::getEntries()[2]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); + REQUIRE(VirtFs::getEntries()[1]->subDir.empty()); + REQUIRE(VirtFs::getEntries()[2]->subDir.empty()); REQUIRE(static_cast<VirtFs::DirEntry*>( VirtFs::getEntries()[0])->userDir == "dir3" + sep + "test"); REQUIRE(static_cast<VirtFs::DirEntry*>( @@ -226,7 +226,7 @@ TEST_CASE("VirtFs1 mountDir", "") nullptr); REQUIRE(VirtFs::getEntries().size() == 1); REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); REQUIRE(static_cast<VirtFs::DirEntry*>( VirtFs::getEntries()[0])->userDir == "dir1"); @@ -419,7 +419,7 @@ TEST_CASE("VirtFs1 mountDir", "") nullptr); REQUIRE(VirtFs::getEntries().size() == 2); REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); REQUIRE(VirtFs::getEntries()[1]->root == "dir1" + sep); REQUIRE(VirtFs::getEntries()[1]->subDir == "dir2" + sep); @@ -453,7 +453,7 @@ TEST_CASE("VirtFs1 mountDir", "") nullptr); REQUIRE(VirtFs::getEntries().size() == 2); REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); REQUIRE(VirtFs::getEntries()[1]->root == "dir1" + sep); REQUIRE(VirtFs::getEntries()[1]->subDir == "dir2" + sep); @@ -466,7 +466,7 @@ TEST_CASE("VirtFs1 mountDir", "") REQUIRE(VirtFs::unmountDirSilent2("dir1", "dir2")); REQUIRE(VirtFs::getEntries().size() == 1); REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); REQUIRE(static_cast<VirtFs::DirEntry*>( VirtFs::getEntries()[0])->userDir == "dir1"); @@ -485,7 +485,7 @@ TEST_CASE("VirtFs1 mountDir", "") nullptr); REQUIRE(VirtFs::getEntries().size() == 1); REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); REQUIRE(static_cast<VirtFs::DirEntry*>( VirtFs::getEntries()[0])->userDir == "dir1"); @@ -518,7 +518,7 @@ TEST_CASE("VirtFs1 mountZip", "") REQUIRE(VirtFs::getEntries().size() == 1); REQUIRE(VirtFs::getEntries()[0]->root == prefix + "data" + sep + "test" + sep + "test.zip"); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip); } @@ -538,11 +538,11 @@ TEST_CASE("VirtFs1 mountZip", "") REQUIRE(VirtFs::getEntries()[0]->root == prefix + "data" + sep + "test" + sep + "test2.zip"); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); REQUIRE(VirtFs::getEntries()[1]->root == prefix + "data" + sep + "test" + sep + "test.zip"); REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip); - REQUIRE(VirtFs::getEntries()[1]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[1]->subDir.empty()); } SECTION("simple 3") @@ -561,11 +561,11 @@ TEST_CASE("VirtFs1 mountZip", "") REQUIRE(VirtFs::getEntries()[0]->root == prefix + "data" + sep + "test" + sep + "test.zip"); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); REQUIRE(VirtFs::getEntries()[1]->root == prefix + "data" + sep + "test" + sep + "test2.zip"); REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip); - REQUIRE(VirtFs::getEntries()[1]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[1]->subDir.empty()); } SECTION("simple 4") @@ -589,15 +589,15 @@ TEST_CASE("VirtFs1 mountZip", "") REQUIRE(VirtFs::getEntries()[0]->root == prefix + "data" + sep + "test" + sep + "test2.zip"); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); REQUIRE(VirtFs::getEntries()[1]->root == prefix + "data" + sep + "test" + sep + ""); REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir); - REQUIRE(VirtFs::getEntries()[1]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[1]->subDir.empty()); REQUIRE(VirtFs::getEntries()[2]->root == prefix + "data" + sep + "test" + sep + "test.zip"); REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip); - REQUIRE(VirtFs::getEntries()[2]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[2]->subDir.empty()); } SECTION("simple 5") @@ -621,15 +621,15 @@ TEST_CASE("VirtFs1 mountZip", "") REQUIRE(VirtFs::getEntries()[0]->root == prefix + "data" + sep + "test" + sep + ""); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); REQUIRE(VirtFs::getEntries()[1]->root == prefix + "data" + sep + "test" + sep + "test.zip"); REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip); - REQUIRE(VirtFs::getEntries()[1]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[1]->subDir.empty()); REQUIRE(VirtFs::getEntries()[2]->root == prefix + "data" + sep + "test" + sep + "test2.zip"); REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip); - REQUIRE(VirtFs::getEntries()[2]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[2]->subDir.empty()); } SECTION("subDir 1") @@ -784,7 +784,7 @@ TEST_CASE("VirtFs1 mountZip", "") REQUIRE(VirtFs::getEntries().size() == 1); REQUIRE(VirtFs::getEntries()[0]->root == prefix + "data" + sep + "test" + sep + "test.zip"); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip); } @@ -829,24 +829,24 @@ TEST_CASE("VirtFs1 unmount", "") REQUIRE(VirtFs::unmountDir("dir1")); REQUIRE(VirtFs::getEntries().size() == 2); REQUIRE(VirtFs::getEntries()[0]->root == "dir3" + sep); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); REQUIRE(static_cast<VirtFs::DirEntry*>( VirtFs::getEntries()[0])->userDir == "dir3"); REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep + "dir3" + sep); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); REQUIRE(static_cast<VirtFs::DirEntry*>( VirtFs::getEntries()[1])->userDir == "dir2" + sep + "dir3"); REQUIRE_THROWS(VirtFs::unmountDir("dir1")); REQUIRE(VirtFs::getEntries().size() == 2); REQUIRE(VirtFs::getEntries()[0]->root == "dir3" + sep); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); REQUIRE(static_cast<VirtFs::DirEntry*>( VirtFs::getEntries()[0])->userDir == "dir3"); REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep + "dir3" + sep); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); REQUIRE(static_cast<VirtFs::DirEntry*>( VirtFs::getEntries()[1])->userDir == "dir2" + sep + "dir3"); @@ -854,7 +854,7 @@ TEST_CASE("VirtFs1 unmount", "") REQUIRE_THROWS(VirtFs::unmountDir("dir2/dir3" + sep)); REQUIRE(VirtFs::getEntries().size() == 1); REQUIRE(VirtFs::getEntries()[0]->root == "dir3" + sep); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); REQUIRE(static_cast<VirtFs::DirEntry*>( VirtFs::getEntries()[0])->userDir == "dir3"); @@ -866,18 +866,18 @@ TEST_CASE("VirtFs1 unmount", "") Append_true)); REQUIRE(VirtFs::getEntries().size() == 1); REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); REQUIRE(static_cast<VirtFs::DirEntry*>( VirtFs::getEntries()[0])->userDir == "dir1"); REQUIRE_THROWS(VirtFs::unmountDir("dir2")); REQUIRE(VirtFs::unmountDir("dir1")); - REQUIRE(VirtFs::getEntries().size() == 0); + REQUIRE(VirtFs::getEntries().empty()); REQUIRE(VirtFs::mountDirSilentTest("dir1", Append_true)); REQUIRE(VirtFs::getEntries().size() == 1); REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); REQUIRE(static_cast<VirtFs::DirEntry*>( VirtFs::getEntries()[0])->userDir == "dir1"); @@ -898,11 +898,11 @@ TEST_CASE("VirtFs1 unmount", "") REQUIRE(VirtFs::getEntries().size() == 2); REQUIRE(VirtFs::getEntries()[0]->root == prefix + "data" + sep + "test" + sep + "test.zip"); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip); REQUIRE(VirtFs::getEntries()[1]->root == prefix + "data" + sep + "test" + sep + "test2.zip"); - REQUIRE(VirtFs::getEntries()[1]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[1]->subDir.empty()); REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip); VirtFs::unmountZip(prefix + "data/test/test.zip"); @@ -915,7 +915,7 @@ TEST_CASE("VirtFs1 unmount", "") REQUIRE(VirtFs::getEntries().size() == 1); REQUIRE(VirtFs::getEntries()[0]->root == prefix + "data" + sep + "test" + sep + "test2.zip"); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip); } @@ -940,15 +940,15 @@ TEST_CASE("VirtFs1 unmount", "") REQUIRE(VirtFs::getEntries().size() == 3); REQUIRE(VirtFs::getEntries()[0]->root == prefix + "data" + sep + "test" + sep + "test2.zip"); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip); REQUIRE(VirtFs::getEntries()[1]->root == prefix + "data" + sep + "test" + sep); - REQUIRE(VirtFs::getEntries()[1]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[1]->subDir.empty()); REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir); REQUIRE(VirtFs::getEntries()[2]->root == prefix + "data" + sep + "test" + sep + "test.zip"); - REQUIRE(VirtFs::getEntries()[2]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[2]->subDir.empty()); REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip); VirtFs::unmountZip(prefix + "data/test/test.zip"); @@ -964,11 +964,11 @@ TEST_CASE("VirtFs1 unmount", "") REQUIRE(VirtFs::getEntries().size() == 2); REQUIRE(VirtFs::getEntries()[0]->root == prefix + "data" + sep + "test" + sep + "test2.zip"); - REQUIRE(VirtFs::getEntries()[0]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip); REQUIRE(VirtFs::getEntries()[1]->root == prefix + "data" + sep + "test" + sep); - REQUIRE(VirtFs::getEntries()[1]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[1]->subDir.empty()); REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir); } @@ -1009,7 +1009,7 @@ TEST_CASE("VirtFs1 unmount", "") REQUIRE(static_cast<VirtFs::DirEntry*>( VirtFs::getEntries()[0])->userDir == "dir3"); REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep + "dir3" + sep); - REQUIRE(VirtFs::getEntries()[1]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[1]->subDir.empty()); REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir); REQUIRE(static_cast<VirtFs::DirEntry*>( VirtFs::getEntries()[1])->userDir == "dir2" + sep + "dir3"); @@ -1021,7 +1021,7 @@ TEST_CASE("VirtFs1 unmount", "") REQUIRE(static_cast<VirtFs::DirEntry*>( VirtFs::getEntries()[0])->userDir == "dir3"); REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep + "dir3" + sep); - REQUIRE(VirtFs::getEntries()[1]->subDir == std::string()); + REQUIRE(VirtFs::getEntries()[1]->subDir.empty()); REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir); REQUIRE(static_cast<VirtFs::DirEntry*>( VirtFs::getEntries()[1])->userDir == "dir2" + sep + "dir3"); @@ -1049,7 +1049,7 @@ TEST_CASE("VirtFs1 unmount", "") REQUIRE_THROWS(VirtFs::unmountDir("dir2")); REQUIRE_THROWS(VirtFs::unmountDir("dir1")); REQUIRE(VirtFs::unmountDir2("dir1", "dir2")); - REQUIRE(VirtFs::getEntries().size() == 0); + REQUIRE(VirtFs::getEntries().empty()); REQUIRE(VirtFs::mountDirSilentTest2("dir1", "dir3", Append_true)); @@ -1324,8 +1324,8 @@ TEST_CASE("VirtFs1 getRealDir1", "") VirtFs::init("."); logger = new Logger(); const std::string sep = dirSeparator; - REQUIRE(VirtFs::getRealDir(".") == ""); - REQUIRE(VirtFs::getRealDir("..") == ""); + REQUIRE(VirtFs::getRealDir(".").empty()); + REQUIRE(VirtFs::getRealDir("..").empty()); const bool dir1 = VirtFs::mountDirSilent("data", Append_false); REQUIRE((dir1 || VirtFs::mountDirSilent("../data", @@ -1350,7 +1350,7 @@ TEST_CASE("VirtFs1 getRealDir1", "") REQUIRE(VirtFs::getRealDir("test//test.txt") == "../data"); } - REQUIRE(VirtFs::getRealDir("zzz") == ""); + REQUIRE(VirtFs::getRealDir("zzz").empty()); VirtFs::mountDirSilent("data/test", Append_false); @@ -1376,7 +1376,7 @@ TEST_CASE("VirtFs1 getRealDir1", "") REQUIRE(VirtFs::getRealDir("test.txt") == ".." + sep + "data" + sep + "test"); } - REQUIRE(VirtFs::getRealDir("zzz") == ""); + REQUIRE(VirtFs::getRealDir("zzz").empty()); VirtFs::unmountDirSilent("data/test"); VirtFs::unmountDirSilent("../data/test"); @@ -1393,7 +1393,7 @@ TEST_CASE("VirtFs1 getRealDir1", "") REQUIRE(VirtFs::getRealDir("test/test.txt") == ".." + sep + "data"); } - REQUIRE(VirtFs::getRealDir("zzz") == ""); + REQUIRE(VirtFs::getRealDir("zzz").empty()); VirtFs::unmountDirSilent("data"); VirtFs::unmountDirSilent("../data"); @@ -1413,13 +1413,13 @@ TEST_CASE("VirtFs1 getRealDir2", "") VirtFs::mountZip(prefix + "test2.zip", Append_false); - REQUIRE(VirtFs::getRealDir(".") == ""); - REQUIRE(VirtFs::getRealDir("..") == ""); + REQUIRE(VirtFs::getRealDir(".").empty()); + REQUIRE(VirtFs::getRealDir("..").empty()); REQUIRE(VirtFs::getRealDir("test.txt") == prefix + "test2.zip"); REQUIRE(VirtFs::getRealDir("dir/1") == prefix + "test2.zip"); REQUIRE(VirtFs::getRealDir("dir\\dye.png") == prefix + "test2.zip"); - REQUIRE(VirtFs::getRealDir("zzz") == ""); + REQUIRE(VirtFs::getRealDir("zzz").empty()); VirtFs::mountZip(prefix + "test.zip", Append_false); @@ -1429,15 +1429,15 @@ TEST_CASE("VirtFs1 getRealDir2", "") prefix + "test.zip"); REQUIRE(VirtFs::getRealDir("dir\\\\brimmedhat.png") == prefix + "test.zip"); - REQUIRE(VirtFs::getRealDir("zzz") == ""); + REQUIRE(VirtFs::getRealDir("zzz").empty()); VirtFs::unmountZip(prefix + "test.zip"); - REQUIRE(VirtFs::getRealDir("dir/brimmedhat.png") == ""); + REQUIRE(VirtFs::getRealDir("dir/brimmedhat.png").empty()); REQUIRE(VirtFs::getRealDir("test.txt") == prefix + "test2.zip"); REQUIRE(VirtFs::getRealDir("dir//dye.png") == prefix + "test2.zip"); - REQUIRE(VirtFs::getRealDir("zzz") == ""); + REQUIRE(VirtFs::getRealDir("zzz").empty()); VirtFs::unmountZip(prefix + "test2.zip"); VirtFs::deinit(); @@ -1449,15 +1449,15 @@ TEST_CASE("VirtFs1 getRealDir3", "") VirtFs::init("."); logger = new Logger(); const std::string sep = dirSeparator; - REQUIRE(VirtFs::getRealDir(".") == ""); - REQUIRE(VirtFs::getRealDir("..") == ""); + REQUIRE(VirtFs::getRealDir(".").empty()); + REQUIRE(VirtFs::getRealDir("..").empty()); const bool dir1 = VirtFs::mountDirSilent2("data", "test", Append_false); REQUIRE((dir1 || VirtFs::mountDirSilent2("../data", "test", Append_false)) == true); - REQUIRE(VirtFs::getRealDir("file1.txt") == ""); + REQUIRE(VirtFs::getRealDir("file1.txt").empty()); if (dir1 == true) { REQUIRE(VirtFs::getRealDir("dir1") == "data"); @@ -1468,7 +1468,7 @@ TEST_CASE("VirtFs1 getRealDir3", "") REQUIRE(VirtFs::getRealDir("dir1") == ".." + sep + "data"); REQUIRE(VirtFs::getRealDir("simplefile.txt") == ".." + sep + "data"); } - REQUIRE(VirtFs::getRealDir("zzz") == ""); + REQUIRE(VirtFs::getRealDir("zzz").empty()); VirtFs::mountDirSilent2("data/test", "dir2", @@ -1476,7 +1476,7 @@ TEST_CASE("VirtFs1 getRealDir3", "") VirtFs::mountDirSilent2("../data/test", "dir2", Append_false); - REQUIRE(VirtFs::getRealDir("dir") == ""); + REQUIRE(VirtFs::getRealDir("dir").empty()); if (dir1 == true) { REQUIRE(VirtFs::getRealDir("file1.txt") == "data" + sep + "test"); @@ -1488,7 +1488,7 @@ TEST_CASE("VirtFs1 getRealDir3", "") ".." + sep + "data" + sep + "test"); REQUIRE(VirtFs::getRealDir("simplefile.txt") == ".." + sep + "data"); } - REQUIRE(VirtFs::getRealDir("zzz") == ""); + REQUIRE(VirtFs::getRealDir("zzz").empty()); VirtFs::deinit(); delete2(logger); @@ -1559,7 +1559,7 @@ TEST_CASE("VirtFs1 enumerateFiles1", "") VirtFs::permitLinks(true); list = VirtFs::enumerateFiles("test/units.xml"); - REQUIRE(list->names.size() == 0); + REQUIRE(list->names.empty()); VirtFs::freeList(list); VirtFs::permitLinks(false); @@ -3224,7 +3224,7 @@ TEST_CASE("VirtFs1 getDirs1", "") list.clear(); VirtFs::getDirs("dir2", list); - REQUIRE(list.size() == 0); + REQUIRE(list.empty()); VirtFs::unmountZip(prefix + "data/test/test2.zip"); VirtFs::deinit(); @@ -3253,7 +3253,7 @@ TEST_CASE("VirtFs1 getDirs2", "") list.clear(); VirtFs::getDirs("dir1", list); - REQUIRE(list.size() == 0); + REQUIRE(list.empty()); VirtFs::unmountDir(prefix + "data/test"); } @@ -3300,7 +3300,7 @@ TEST_CASE("VirtFs1 getDirs3", "") list.clear(); VirtFs::getDirs("1", list); - REQUIRE(list.size() == 0); + REQUIRE(list.empty()); VirtFs::unmountZip2(prefix + "data/test/test2.zip", "dir"); @@ -3330,7 +3330,7 @@ TEST_CASE("VirtFs1 getDirs4", "") list.clear(); VirtFs::getDirs("dir1", list); - REQUIRE(list.size() == 0); + REQUIRE(list.empty()); VirtFs::unmountDir2(prefix + "data", "test"); @@ -3405,7 +3405,7 @@ TEST_CASE("VirtFs1 getFilesWithDir2", "") VirtFs::getFilesWithDir("music", list); REQUIRE(list.size() <= 5); - REQUIRE(list.size() >= 1); + REQUIRE(!list.empty()); REQUIRE(inList(list, "music", "keprohm.ogg")); list.clear(); @@ -3490,7 +3490,7 @@ TEST_CASE("VirtFs1 getFilesWithDir4", "") VirtFs::getFilesWithDir("dir1", list); REQUIRE(list.size() <= 6); - REQUIRE(list.size() >= 1); + REQUIRE(!list.empty()); REQUIRE(inList(list, "dir1", "file1.txt")); list.clear(); diff --git a/src/fs/virtfs/virtfs_unittest.cc b/src/fs/virtfs/virtfs_unittest.cc index 705f68ad8..3305c0264 100644 --- a/src/fs/virtfs/virtfs_unittest.cc +++ b/src/fs/virtfs/virtfs_unittest.cc @@ -295,7 +295,7 @@ TEST_CASE("VirtFs enumerateFiles1", "") list = VirtFs::enumerateFiles("test/units.xml"); removeTemp(list->names); - REQUIRE(list->names.size() == 0); + REQUIRE(list->names.empty()); VirtFs::freeList(list); VirtFs::unmountDirSilent("data"); @@ -634,8 +634,8 @@ TEST_CASE("VirtFs getRealDir1", "") { logger = new Logger(); const std::string sep = dirSeparator; - REQUIRE(VirtFs::getRealDir(".") == ""); - REQUIRE(VirtFs::getRealDir("..") == ""); + REQUIRE(VirtFs::getRealDir(".").empty()); + REQUIRE(VirtFs::getRealDir("..").empty()); const bool dir1 = VirtFs::mountDirSilent("data", Append_false); REQUIRE((dir1 || VirtFs::mountDirSilent("../data", Append_false)) == true); @@ -651,7 +651,7 @@ TEST_CASE("VirtFs getRealDir1", "") REQUIRE(VirtFs::getRealDir("test/test.txt") == "../data"); } - REQUIRE(VirtFs::getRealDir("zzz") == ""); + REQUIRE(VirtFs::getRealDir("zzz").empty()); VirtFs::mountDirSilent("data/test", Append_false); VirtFs::mountDirSilent("../data/test", Append_false); @@ -671,7 +671,7 @@ TEST_CASE("VirtFs getRealDir1", "") REQUIRE(VirtFs::getRealDir("test.txt") == ".." + sep + "data" + sep + "test"); } - REQUIRE(VirtFs::getRealDir("zzz") == ""); + REQUIRE(VirtFs::getRealDir("zzz").empty()); if (dir1 == true) { @@ -710,7 +710,7 @@ TEST_CASE("VirtFs getRealDir1", "") ".." + sep + "data" + sep + "test" + sep + "test.zip"); } REQUIRE(VirtFs::exists("dir/hide.png")); - REQUIRE(VirtFs::getRealDir("zzz") == ""); + REQUIRE(VirtFs::getRealDir("zzz").empty()); VirtFs::unmountDirSilent("data"); VirtFs::unmountDirSilent("../data"); @@ -734,7 +734,7 @@ TEST_CASE("VirtFs getrealDir2", "") VirtFs::mountDir(prefix + "data/test", Append_false); VirtFs::mountDir(prefix + "data", Append_false); - REQUIRE(VirtFs::getRealDir("zzz") == ""); + REQUIRE(VirtFs::getRealDir("zzz").empty()); REQUIRE(VirtFs::getRealDir("dir1/file1.txt") == prefix + "data" + sep + "test"); @@ -765,7 +765,7 @@ TEST_CASE("VirtFs getrealDir3", "") Append_false); VirtFs::mountDir(prefix + "data/test", Append_false); - REQUIRE(VirtFs::getRealDir("zzz") == ""); + REQUIRE(VirtFs::getRealDir("zzz").empty()); REQUIRE(VirtFs::getRealDir("dir1/file1.txt") == prefix + "data" + sep + "test"); diff --git a/src/fs/virtfs/zip_unittest.cc b/src/fs/virtfs/zip_unittest.cc index 52629d482..0aa26595f 100644 --- a/src/fs/virtfs/zip_unittest.cc +++ b/src/fs/virtfs/zip_unittest.cc @@ -162,7 +162,7 @@ TEST_CASE("Zip readArchiveInfo", "") REQUIRE(VirtFs::ZipReader::readArchiveInfo(entry)); REQUIRE(entry->root == name); - REQUIRE(headers.size() == 0); + REQUIRE(headers.empty()); delete entry; } diff --git a/src/gui/fonts/textchunklist_unittest.cc b/src/gui/fonts/textchunklist_unittest.cc index a06ec2785..1c0330dce 100644 --- a/src/gui/fonts/textchunklist_unittest.cc +++ b/src/gui/fonts/textchunklist_unittest.cc @@ -32,8 +32,8 @@ TEST_CASE("TextChunkList empty", "TextChunkList") REQUIRE(0 == list.size); REQUIRE(nullptr == list.start); REQUIRE(nullptr == list.end); - REQUIRE(0 == list.search.size()); - REQUIRE(0 == list.searchWidth.size()); + REQUIRE(list.search.empty()); + REQUIRE(list.searchWidth.empty()); } TEST_CASE("TextChunkList add 1", "TextChunkList") @@ -105,8 +105,8 @@ TEST_CASE("TextChunkList addRemoveBack 1", "TextChunkList") REQUIRE(0 == list.size); REQUIRE(nullptr == list.start); REQUIRE(nullptr == list.end); - REQUIRE(0 == list.search.size()); - REQUIRE(0 == list.searchWidth.size()); + REQUIRE(list.search.empty()); + REQUIRE(list.searchWidth.empty()); } TEST_CASE("TextChunkList addRemoveBack 2", "TextChunkList") @@ -154,8 +154,8 @@ TEST_CASE("TextChunkList addRemoveBack 3", "TextChunkList") REQUIRE(nullptr == list.start); REQUIRE(nullptr == list.end); - REQUIRE(0 == list.search.size()); - REQUIRE(0 == list.searchWidth.size()); + REQUIRE(list.search.empty()); + REQUIRE(list.searchWidth.empty()); } TEST_CASE("TextChunkList addRemoveBack 4", "TextChunkList") @@ -185,7 +185,7 @@ TEST_CASE("TextChunkList addRemoveBack 4", "TextChunkList") REQUIRE(chunk1 == (*list.search.find(TextChunkSmall( chunk1->text, chunk1->color, chunk1->color2))).second); - REQUIRE(0 == list.searchWidth.size()); + REQUIRE(list.searchWidth.empty()); delete chunk1; } @@ -306,8 +306,8 @@ TEST_CASE("TextChunkList clear 1", "TextChunkList") REQUIRE(nullptr == list.start); REQUIRE(nullptr == list.end); REQUIRE(chunksLeft == textChunkCnt); - REQUIRE(0 == list.search.size()); - REQUIRE(0 == list.searchWidth.size()); + REQUIRE(list.search.empty()); + REQUIRE(list.searchWidth.empty()); } TEST_CASE("TextChunkList clear 2", "TextChunkList") @@ -331,8 +331,8 @@ TEST_CASE("TextChunkList clear 2", "TextChunkList") REQUIRE(nullptr == list.start); REQUIRE(nullptr == list.end); REQUIRE(chunksLeft == textChunkCnt); - REQUIRE(0 == list.search.size()); - REQUIRE(0 == list.searchWidth.size()); + REQUIRE(list.search.empty()); + REQUIRE(list.searchWidth.empty()); } TEST_CASE("TextChunkList clear 3", "TextChunkList") @@ -358,12 +358,12 @@ TEST_CASE("TextChunkList clear 3", "TextChunkList") list.removeBack(); REQUIRE((chunksLeft + 2) == textChunkCnt); REQUIRE(2 == list.search.size()); - REQUIRE(0 == list.searchWidth.size()); + REQUIRE(list.searchWidth.empty()); list.clear(); REQUIRE(chunksLeft == textChunkCnt); - REQUIRE(0 == list.search.size()); - REQUIRE(0 == list.searchWidth.size()); + REQUIRE(list.search.empty()); + REQUIRE(list.searchWidth.empty()); } TEST_CASE("TextChunkList clear 4", "TextChunkList") @@ -389,12 +389,12 @@ TEST_CASE("TextChunkList clear 4", "TextChunkList") list.removeBack(2); REQUIRE((chunksLeft + 1) == textChunkCnt); REQUIRE(1 == list.search.size()); - REQUIRE(0 == list.searchWidth.size()); + REQUIRE(list.searchWidth.empty()); list.clear(); REQUIRE(chunksLeft == textChunkCnt); - REQUIRE(0 == list.search.size()); - REQUIRE(0 == list.searchWidth.size()); + REQUIRE(list.search.empty()); + REQUIRE(list.searchWidth.empty()); } TEST_CASE("TextChunkList remove 1", "TextChunkList") @@ -413,8 +413,8 @@ TEST_CASE("TextChunkList remove 1", "TextChunkList") REQUIRE(nullptr == list.start); REQUIRE(nullptr == list.end); REQUIRE(chunksLeft == textChunkCnt); - REQUIRE(0 == list.search.size()); - REQUIRE(0 == list.searchWidth.size()); + REQUIRE(list.search.empty()); + REQUIRE(list.searchWidth.empty()); } TEST_CASE("TextChunkList remove 2", "TextChunkList") diff --git a/src/gui/popups/beingpopup.cpp b/src/gui/popups/beingpopup.cpp index c18ac3871..1834fcbe9 100644 --- a/src/gui/popups/beingpopup.cpp +++ b/src/gui/popups/beingpopup.cpp @@ -309,7 +309,6 @@ void BeingPopup::show(const int x, const int y, Being *const b) setContentSize(minWidth, height); position(x, y); - return; } #ifdef USE_PROFILER diff --git a/src/gui/widgets/tabs/socialplayerstab.h b/src/gui/widgets/tabs/socialplayerstab.h index 447e0791e..f4c3f2bbe 100644 --- a/src/gui/widgets/tabs/socialplayerstab.h +++ b/src/gui/widgets/tabs/socialplayerstab.h @@ -156,7 +156,7 @@ class SocialPlayersTab final : public SocialTab const StringVectCIter i_end = names.end(); while (i != i_end) { - if (ava->getName() == (*i) && (*i) != "") + if (ava->getName() == (*i) && !(*i).empty()) { finded = true; break; @@ -180,7 +180,7 @@ class SocialPlayersTab final : public SocialTab while (i != i_end) { - if ((*i) != "") + if (!(*i).empty()) updateAvatar(*i); ++i; } diff --git a/src/gui/widgets/tabs/socialtabbase.h b/src/gui/widgets/tabs/socialtabbase.h index 66f51367f..9cffcae89 100644 --- a/src/gui/widgets/tabs/socialtabbase.h +++ b/src/gui/widgets/tabs/socialtabbase.h @@ -45,7 +45,7 @@ ENUMS_RESOURCES_MAP_MAPITEMTYPE_H {\ std::string name;\ int level = -1;\ - if (*i == "")\ + if ((*i).empty())\ {\ name = _("(default)");\ level = 0;\ diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index 3c63fb2ed..10d9c9890 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -836,8 +836,8 @@ void UpdaterWindow::logic() } mProgressBar->setProgress(mDownloadProgress); - if ((mUpdateFiles.size() != 0u) - && CAST_SIZE(mUpdateIndex) <= mUpdateFiles.size()) + if (!mUpdateFiles.empty() && + CAST_SIZE(mUpdateIndex) <= mUpdateFiles.size()) { mProgressBar->setText(strprintf("%u/%u", mUpdateIndex + mUpdateIndexOffset + 1, CAST_U32( diff --git a/src/net/tmwa/adminhandler.cpp b/src/net/tmwa/adminhandler.cpp index 514c53090..982cce39b 100644 --- a/src/net/tmwa/adminhandler.cpp +++ b/src/net/tmwa/adminhandler.cpp @@ -101,7 +101,6 @@ void AdminHandler::mute(const Being *const being A_UNUSED, const int type A_UNUSED, const int limit A_UNUSED) const { - return; } void AdminHandler::muteName(const std::string &name A_UNUSED) const diff --git a/src/particle/imageparticle.cpp b/src/particle/imageparticle.cpp index 7e4a6105a..859fc6a15 100644 --- a/src/particle/imageparticle.cpp +++ b/src/particle/imageparticle.cpp @@ -89,5 +89,4 @@ void ImageParticle::draw(Graphics *restrict const graphics, mImage->setAlpha(alphafactor); graphics->drawImage(mImage, screenX, screenY); - return; } diff --git a/src/particle/textparticle.cpp b/src/particle/textparticle.cpp index cf4da05f4..dd25e5945 100644 --- a/src/particle/textparticle.cpp +++ b/src/particle/textparticle.cpp @@ -93,5 +93,4 @@ void TextParticle::draw(Graphics *restrict const graphics, mText, screenX - mTextWidth, screenY); } BLOCK_END("TextParticle::draw") - return; } diff --git a/src/resources/map/maplayer_unittest.cc b/src/resources/map/maplayer_unittest.cc index 5c001f543..194128815 100644 --- a/src/resources/map/maplayer_unittest.cc +++ b/src/resources/map/maplayer_unittest.cc @@ -1682,7 +1682,7 @@ TEST_CASE("MapLayer drawSpecialLayer (specialLayer)", "") 0, 0, 1, 0, 0); - REQUIRE(mock->mDraws.size() == 0); + REQUIRE(mock->mDraws.empty()); specialLayer->setTile(0, 0, MapItemType::ARROW_UP); layer->drawSpecialLayer(mock, @@ -1957,13 +1957,13 @@ TEST_CASE("MapLayer drawSpecialLayer (specialLayer)", "") 4, 0, maxX, 0, 0); - REQUIRE(mock->mDraws.size() == 0); + REQUIRE(mock->mDraws.empty()); layer->drawSpecialLayer(mock, 6, 0, maxX, 0, 0); - REQUIRE(mock->mDraws.size() == 0); + REQUIRE(mock->mDraws.empty()); layer->drawSpecialLayer(mock, 20, @@ -2027,7 +2027,7 @@ TEST_CASE("MapLayer drawSpecialLayer (tempLayer)", "") 0, 0, 1, 0, 0); - REQUIRE(mock->mDraws.size() == 0); + REQUIRE(mock->mDraws.empty()); specialLayer->setTile(0, 0, MapItemType::ARROW_UP); layer->drawSpecialLayer(mock, @@ -2308,13 +2308,13 @@ TEST_CASE("MapLayer drawSpecialLayer (tempLayer)", "") 4, 0, maxX, 0, 0); - REQUIRE(mock->mDraws.size() == 0); + REQUIRE(mock->mDraws.empty()); layer->drawSpecialLayer(mock, 6, 0, maxX, 0, 0); - REQUIRE(mock->mDraws.size() == 0); + REQUIRE(mock->mDraws.empty()); layer->drawSpecialLayer(mock, 20, diff --git a/src/resources/resourcemanager/resourcemanager_unittest.cc b/src/resources/resourcemanager/resourcemanager_unittest.cc index 231d5cfc0..fe3e2e995 100644 --- a/src/resources/resourcemanager/resourcemanager_unittest.cc +++ b/src/resources/resourcemanager/resourcemanager_unittest.cc @@ -274,7 +274,7 @@ TEST_CASE("resourcemanager", "resourcemanager") REQUIRE(res2 != nullptr); REQUIRE(testResouceCounter == 1); REQUIRE(res2->mRefCount == 1); - REQUIRE(res2->mSource == ""); + REQUIRE(res2->mSource.empty()); REQUIRE(ResourceManager::getResources().size() == 1 + resSize); REQUIRE(ResourceManager::getResources()["test1"] == res2); REQUIRE(ResourceManager::getOrphanedResources().empty() == true); @@ -302,7 +302,7 @@ TEST_CASE("resourcemanager", "resourcemanager") REQUIRE(res2 != nullptr); REQUIRE(testResouceCounter == 2); REQUIRE(res2->mRefCount == 1); - REQUIRE(res2->mSource == ""); + REQUIRE(res2->mSource.empty()); REQUIRE(ResourceManager::getResources().size() == 2 + resSize); REQUIRE(ResourceManager::getResources()["test1"] == res); REQUIRE(ResourceManager::getResources()["test2"] == res2); @@ -331,7 +331,7 @@ TEST_CASE("resourcemanager", "resourcemanager") REQUIRE(testResouceCounter == 1); REQUIRE(res2->mRefCount == 2); REQUIRE(res == res2); - REQUIRE(res2->mSource == ""); + REQUIRE(res2->mSource.empty()); REQUIRE(ResourceManager::getResources().size() == 1 + resSize); REQUIRE(ResourceManager::getResources()["test1"] == res2); REQUIRE(ResourceManager::getOrphanedResources().empty() == true); @@ -360,7 +360,7 @@ TEST_CASE("resourcemanager", "resourcemanager") REQUIRE(testResouceCounter == 1); REQUIRE(res2->mRefCount == 1); REQUIRE(res == res2); - REQUIRE(res2->mSource == ""); + REQUIRE(res2->mSource.empty()); REQUIRE(ResourceManager::getResources().size() == 1 + resSize); REQUIRE(ResourceManager::getResources()["test1"] == res2); REQUIRE(ResourceManager::getOrphanedResources().empty() == true); @@ -388,7 +388,7 @@ TEST_CASE("resourcemanager", "resourcemanager") REQUIRE(res2 != nullptr); REQUIRE(testResouceCounter == 2); REQUIRE(res2->mRefCount == 1); - REQUIRE(res2->mSource == ""); + REQUIRE(res2->mSource.empty()); REQUIRE(ResourceManager::getResources().size() == 2 + resSize); REQUIRE(ResourceManager::getResources()["test1"] == res); REQUIRE(ResourceManager::getResources()["test2"] == res2); @@ -473,7 +473,7 @@ TEST_CASE("resourcemanager", "resourcemanager") REQUIRE(testResouceCounter == 1); REQUIRE(res2->mRefCount == 1); REQUIRE(res == res2); - REQUIRE(res2->mSource == ""); + REQUIRE(res2->mSource.empty()); REQUIRE(ResourceManager::getResources().size() == 1 + resSize); REQUIRE(ResourceManager::getResources()["test1"] == res2); REQUIRE(ResourceManager::getOrphanedResources().empty() == true); diff --git a/src/utils/chatutils_unittest.cc b/src/utils/chatutils_unittest.cc index bc2013e82..f6e608556 100644 --- a/src/utils/chatutils_unittest.cc +++ b/src/utils/chatutils_unittest.cc @@ -103,7 +103,7 @@ TEST_CASE("chatutils replaceVars", "") SECTION("empty") { replaceVars(str); - REQUIRE(str == ""); + REQUIRE(str.empty()); str = "test line"; replaceVars(str); diff --git a/src/utils/parameters_unittest.cc b/src/utils/parameters_unittest.cc index 192249a12..7739b62bd 100644 --- a/src/utils/parameters_unittest.cc +++ b/src/utils/parameters_unittest.cc @@ -28,7 +28,7 @@ TEST_CASE("parameters basic 1", "") { StringVect pars; REQUIRE(splitParameters(pars, "", ",", '\"') == true); - REQUIRE(pars.size() == 0); + REQUIRE(pars.empty()); } TEST_CASE("parameters basic 2", "") @@ -45,7 +45,7 @@ TEST_CASE("parameters basic 3", "") { StringVect pars; REQUIRE(splitParameters(pars, ", ,,,", ",", '\"') == true); - REQUIRE(pars.size() == 0); + REQUIRE(pars.empty()); } TEST_CASE("parameters basic 4", "") @@ -99,7 +99,7 @@ TEST_CASE("parameters quote 2", "") StringVect pars; REQUIRE(splitParameters(pars, "\"\",,two, tree", ",", '\"') == true); REQUIRE(pars.size() == 3); - REQUIRE(pars[0] == ""); + REQUIRE(pars[0].empty()); REQUIRE(pars[1] == "two"); REQUIRE(pars[2] == "tree"); } @@ -315,7 +315,7 @@ TEST_CASE("parameters broken 2", "") { StringVect pars; REQUIRE(splitParameters(pars, ",", ",", '\"') == true); - REQUIRE(pars.size() == 0); + REQUIRE(pars.empty()); } TEST_CASE("parameters broken 3", "") @@ -323,5 +323,5 @@ TEST_CASE("parameters broken 3", "") StringVect pars; REQUIRE(splitParameters(pars, ",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,", ",", '\"') == true); - REQUIRE(pars.size() == 0); + REQUIRE(pars.empty()); } diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 0dfd3b597..d21702ed1 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -336,7 +336,6 @@ void getSafeUtf8String(std::string text, char *const buf) memcpy(buf, text.c_str(), sz); memset(buf + sz, 0, UTF8_MAX_SIZE); } - return; } std::string getFileName(const std::string &path) diff --git a/src/utils/stringutils_unittest.cc b/src/utils/stringutils_unittest.cc index 57d4336e0..a6c187ac5 100644 --- a/src/utils/stringutils_unittest.cc +++ b/src/utils/stringutils_unittest.cc @@ -53,7 +53,7 @@ TEST_CASE("stringuntils trim 1", "") trim(str)); str = ""; - REQUIRE("" == trim(str)); + REQUIRE(trim(str).empty()); } TEST_CASE("stringuntils toLower 1", "") @@ -71,7 +71,7 @@ TEST_CASE("stringuntils toLower 1", "") toLower(str)); str = ""; - REQUIRE("" == toLower(str)); + REQUIRE(toLower(str).empty()); } TEST_CASE("stringuntils toUpper 1", "") @@ -89,7 +89,7 @@ TEST_CASE("stringuntils toUpper 1", "") toUpper(str)); str = ""; - REQUIRE("" == toUpper(str)); + REQUIRE(toUpper(str).empty()); } TEST_CASE("stringuntils atox 1", "") @@ -226,12 +226,12 @@ TEST_CASE("stringuntils removeToken 1", "") { std::string str = ""; - REQUIRE(removeToken(str, " ") == ""); - REQUIRE(str == ""); + REQUIRE(removeToken(str, " ").empty()); + REQUIRE(str.empty()); str = "test"; - REQUIRE(removeToken(str, " ") == ""); - REQUIRE(str == ""); + REQUIRE(removeToken(str, " ").empty()); + REQUIRE(str.empty()); str = "test line"; REQUIRE(removeToken(str, " ") == "line"); @@ -242,12 +242,12 @@ TEST_CASE("stringuntils removeToken 1", "") REQUIRE(str == "line"); str = "test line"; - REQUIRE(removeToken(str, ",") == ""); - REQUIRE(str == ""); + REQUIRE(removeToken(str, ",").empty()); + REQUIRE(str.empty()); str = ",line"; - REQUIRE(removeToken(str, ",") == ""); - REQUIRE(str == ""); + REQUIRE(removeToken(str, ",").empty()); + REQUIRE(str.empty()); } TEST_CASE("stringuntils strprintf 1", "") @@ -278,10 +278,10 @@ TEST_CASE("stringuntils toString 2", "") TEST_CASE("stringuntils removeColors 1", "") { - REQUIRE("" == removeColors("")); + REQUIRE(removeColors("").empty()); REQUIRE("#" == removeColors("#")); REQUIRE("##" == removeColors("##")); - REQUIRE("" == removeColors("##1")); + REQUIRE(removeColors("##1").empty()); REQUIRE("2" == removeColors("##12")); REQUIRE("1##" == removeColors("1##")); REQUIRE("1" == removeColors("1##2")); @@ -329,7 +329,7 @@ TEST_CASE("stringuntils findSameSubstring", "") std::string str1 = ""; std::string str2 = ""; - REQUIRE("" == findSameSubstring("", "")); + REQUIRE(findSameSubstring("", "").empty()); str1 = "test line"; str2 = "test line"; @@ -341,7 +341,7 @@ TEST_CASE("stringuntils findSameSubstring", "") str1 = "test li"; str2 = "est li"; - REQUIRE("" == findSameSubstring(str1, str2)); + REQUIRE(findSameSubstring(str1, str2).empty()); } TEST_CASE("stringuntils findSameSubstringI", "") @@ -349,7 +349,7 @@ TEST_CASE("stringuntils findSameSubstringI", "") std::string str1 = ""; std::string str2 = ""; - REQUIRE("" == findSameSubstringI("", "")); + REQUIRE(findSameSubstringI("", "").empty()); str1 = "tEst line"; str2 = "tesT line"; @@ -365,7 +365,7 @@ TEST_CASE("stringuntils findSameSubstringI", "") str1 = "teSt li"; str2 = "est li"; - REQUIRE("" == findSameSubstringI(str1, str2)); + REQUIRE(findSameSubstringI(str1, str2).empty()); } TEST_CASE("stringuntils findI 1", "") @@ -396,7 +396,7 @@ TEST_CASE("stringuntils encodeStr 1", "") std::string str = encodeStr(10, 1); REQUIRE(10 == decodeStr(str)); - str = ""; + str.clear(); REQUIRE(0 == decodeStr(str)); str = encodeStr(10, 2); @@ -411,7 +411,7 @@ TEST_CASE("stringuntils encodeStr 1", "") TEST_CASE("stringuntils extractNameFromSprite 1", "") { - REQUIRE("" == extractNameFromSprite("")); + REQUIRE(extractNameFromSprite("").empty()); REQUIRE("test" == extractNameFromSprite("test")); REQUIRE("test" == extractNameFromSprite("test.qwe")); REQUIRE("line" == extractNameFromSprite("test/line.zzz")); @@ -422,7 +422,7 @@ TEST_CASE("stringuntils extractNameFromSprite 1", "") TEST_CASE("stringuntils removeSpriteIndex 1", "") { - REQUIRE("" == removeSpriteIndex("")); + REQUIRE(removeSpriteIndex("").empty()); REQUIRE("test" == removeSpriteIndex("test")); REQUIRE("test" == removeSpriteIndex("test[1]")); REQUIRE("line" == removeSpriteIndex("test/line[12]")); @@ -504,22 +504,22 @@ TEST_CASE("stringutils getSafeUtf8String 2", "") TEST_CASE("stringuntils getFileName 1", "") { - REQUIRE("" == getFileName("")); + REQUIRE(getFileName("").empty()); REQUIRE("file" == getFileName("file")); REQUIRE("file" == getFileName("test/file1\\file")); REQUIRE("file" == getFileName("test\\file1/file")); - REQUIRE("" == getFileName("file/")); + REQUIRE(getFileName("file/").empty()); REQUIRE("file" == getFileName("/file")); } TEST_CASE("stringuntils getFileDir 1", "") { - REQUIRE("" == getFileDir("")); + REQUIRE(getFileDir("").empty()); REQUIRE("file" == getFileDir("file")); REQUIRE("test/file1" == getFileDir("test/file1\\file")); REQUIRE("test\\file1" == getFileDir("test\\file1/file")); REQUIRE("file" == getFileDir("file/")); - REQUIRE("" == getFileDir("/file")); + REQUIRE(getFileDir("/file").empty()); } TEST_CASE("stringuntils replaceAll 1", "") @@ -528,7 +528,7 @@ TEST_CASE("stringuntils replaceAll 1", "") std::string str2 = ""; std::string str3 = ""; - REQUIRE("" == replaceAll(str1, str2, str3)); + REQUIRE(replaceAll(str1, str2, str3).empty()); str1 = "this is test line"; str2 = ""; @@ -551,7 +551,7 @@ TEST_CASE("stringuntils replaceRecursiveAll 1", "") std::string str; str = ""; replaceRecursiveAll(str, "line", '.'); - REQUIRE(str == ""); + REQUIRE(str.empty()); str = "test line"; replaceRecursiveAll(str, "line", '.'); REQUIRE(str == "test ."); @@ -891,7 +891,7 @@ TEST_CASE("stringuntils replaceSpecialChars 1", "") str = ""; replaceSpecialChars(str); - REQUIRE("" == str); + REQUIRE(str.empty()); str = "test"; replaceSpecialChars(str); @@ -936,7 +936,7 @@ TEST_CASE("stringuntils replaceSpecialChars 1", "") TEST_CASE("stringuntils normalize 1", "") { - REQUIRE(normalize("") == ""); + REQUIRE(normalize("").empty()); REQUIRE(normalize("test") == "test"); REQUIRE(normalize("Test") == "test"); REQUIRE(normalize(" test line") == "test line"); @@ -947,7 +947,7 @@ TEST_CASE("stringuntils normalize 1", "") TEST_CASE("stringuntils combineDye 1", "") { - REQUIRE("" == combineDye("", "")); + REQUIRE(combineDye("", "").empty()); REQUIRE("test" == combineDye("test", "")); REQUIRE("|line" == combineDye("", "line")); REQUIRE("test|line" == combineDye("test", "line")); @@ -958,10 +958,10 @@ TEST_CASE("stringuntils combineDye 1", "") TEST_CASE("stringuntils combineDye 2", "") { - REQUIRE("" == combineDye2("", "")); + REQUIRE(combineDye2("", "").empty()); REQUIRE("test" == combineDye2("test", "")); REQUIRE("test" == combineDye2("test", "W")); - REQUIRE("" == combineDye2("", "line")); + REQUIRE(combineDye2("", "line").empty()); REQUIRE("test.xml" == combineDye2("test.xml", "123")); REQUIRE("test.xml|#43413d,59544f,7a706c" == combineDye2("test.xml|#43413d,59544f,7a706c", "")); @@ -973,9 +973,9 @@ TEST_CASE("stringuntils combineDye 2", "") TEST_CASE("stringuntils combineDye 3", "") { - REQUIRE("" == combineDye3("", "")); + REQUIRE(combineDye3("", "").empty()); REQUIRE("test" == combineDye3("test", "")); - REQUIRE("" == combineDye3("", "line")); + REQUIRE(combineDye3("", "line").empty()); REQUIRE("test.xml|123" == combineDye3("test.xml", "123")); REQUIRE("test.xml|#43413d,59544f,7a706c" == combineDye3("test.xml|#43413d,59544f,7a706c", "")); @@ -988,9 +988,9 @@ TEST_CASE("stringuntils combineDye 3", "") TEST_CASE("stringuntils packList 1", "") { std::list <std::string> list; - REQUIRE("" == packList(list)); + REQUIRE(packList(list).empty()); - list.push_back(""); + list.push_back(std::string()); REQUIRE("|" == packList(list)); list.clear(); @@ -1014,7 +1014,7 @@ TEST_CASE("stringuntils stringToHexPath 1", "") std::string str; str = ""; - REQUIRE("" == stringToHexPath(str)); + REQUIRE(stringToHexPath(str).empty()); str = "a"; REQUIRE("%61/" == stringToHexPath(str)); @@ -1036,7 +1036,7 @@ TEST_CASE("stringuntils deleteCharLeft 1", "") str = ""; deleteCharLeft(str, nullptr); - REQUIRE("" == str); + REQUIRE(str.empty()); str = "test line"; pos = 4; @@ -1091,7 +1091,7 @@ TEST_CASE("stringuntils findCutLast 1", "") str = ""; REQUIRE(findCutLast(str, "")); - REQUIRE("" == str); + REQUIRE(str.empty()); str = "test line"; REQUIRE(findCutLast(str, "line")); @@ -1112,7 +1112,7 @@ TEST_CASE("stringuntils CutLast 1", "") str = ""; cutLast(str, ""); - REQUIRE("" == str); + REQUIRE(str.empty()); str = "test line"; cutLast(str, "line"); @@ -1133,7 +1133,7 @@ TEST_CASE("stringuntils findCutFirst 1", "") str = ""; REQUIRE(findCutFirst(str, "")); - REQUIRE("" == str); + REQUIRE(str.empty()); str = "test line"; REQUIRE(findCutFirst(str, "test")); @@ -1154,7 +1154,7 @@ TEST_CASE("stringuntils cutFirst 1", "") str = ""; cutFirst(str, ""); - REQUIRE("" == str); + REQUIRE(str.empty()); str = "test line"; cutFirst(str, "test"); @@ -1174,10 +1174,10 @@ TEST_CASE("stringuntils removeProtocol 1", "") std::string str; str = ""; - REQUIRE("" == removeProtocol(str)); + REQUIRE(removeProtocol(str).empty()); str = "http://"; - REQUIRE("" == removeProtocol(str)); + REQUIRE(removeProtocol(str).empty()); str = "http://test"; REQUIRE("test" == removeProtocol(str)); @@ -1260,7 +1260,7 @@ TEST_CASE("stringuntils sanitizePath", "") const std::string sep = dirSeparator; path = ""; sanitizePath(path); - REQUIRE(path == ""); + REQUIRE(path.empty()); path = "/"; sanitizePath(path); REQUIRE(path == dirSeparator); @@ -1437,7 +1437,7 @@ TEST_CASE("stringuntils secureChatCommand", "") { std::string str; secureChatCommand(str); - REQUIRE(str == ""); + REQUIRE(str.empty()); str = "test"; secureChatCommand(str); REQUIRE(str == "test"); @@ -1522,7 +1522,7 @@ TEST_CASE("stringuntils replaceItemLinks", "") str = ""; replaceItemLinks(str); - REQUIRE(str == ""); + REQUIRE(str.empty()); str = "[]"; replaceItemLinks(str); diff --git a/src/utils/translation/poparser_unittest.cc b/src/utils/translation/poparser_unittest.cc index 82418e09d..54dccb85b 100644 --- a/src/utils/translation/poparser_unittest.cc +++ b/src/utils/translation/poparser_unittest.cc @@ -98,7 +98,7 @@ TEST_CASE("PoParser tests", "PoParser") REQUIRE(dict != nullptr); REQUIRE(dict->getMap() != nullptr); - REQUIRE(dict->getMap()->size() == 0); + REQUIRE(dict->getMap()->empty()); delete parser; delete dict; diff --git a/src/utils/xml_unittest.cc b/src/utils/xml_unittest.cc index 00ec2b5ff..1d4aa52cc 100644 --- a/src/utils/xml_unittest.cc +++ b/src/utils/xml_unittest.cc @@ -228,7 +228,7 @@ TEST_CASE("xml doc", "") REQUIRE(XmlHasProp(node, "option123") == false); REQUIRE(XML::getProperty(node, "name", "") == "padding"); REQUIRE(XML::langProperty(node, "name", "") == "padding"); - REQUIRE(XML::langProperty(node, "name123", "") == ""); + REQUIRE(XML::langProperty(node, "name123", "").empty()); REQUIRE(XML::getProperty(node, "value", 0) == 1); REQUIRE(XML::getProperty(node, "value123", -1) == -1); REQUIRE(XML::getBoolProperty(node, "value", true) == true); |