From cc41b039e6ba2a24c0ded9fb573bee6050aa2ac9 Mon Sep 17 00:00:00 2001 From: Rachel Powers <508861+Ryex@users.noreply.github.com> Date: Sun, 4 Jun 2023 14:59:37 -0700 Subject: chore: clean up after new compiler warnings Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com> --- tests/DummyResourceAPI.h | 2 +- tests/FileSystem_test.cpp | 7 +++---- tests/GZip_test.cpp | 2 +- tests/ResourceModel_test.cpp | 10 +++++----- tests/Task_test.cpp | 4 ++-- 5 files changed, 12 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/DummyResourceAPI.h b/tests/DummyResourceAPI.h index 0cc90958..35de9515 100644 --- a/tests/DummyResourceAPI.h +++ b/tests/DummyResourceAPI.h @@ -32,7 +32,7 @@ class DummyResourceAPI : public ResourceAPI { } DummyResourceAPI() : ResourceAPI() {} - [[nodiscard]] auto getSortingMethods() const -> QList override { return {}; }; + [[nodiscard]] auto getSortingMethods() const -> QList override { return {}; } [[nodiscard]] Task::Ptr searchProjects(SearchArgs&&, SearchCallbacks&& callbacks) const override { diff --git a/tests/FileSystem_test.cpp b/tests/FileSystem_test.cpp index ec1f0bcf..9bb681ae 100644 --- a/tests/FileSystem_test.cpp +++ b/tests/FileSystem_test.cpp @@ -91,10 +91,9 @@ class LinkTask : public Task { emitSucceeded(); } - }; + } FS::create_link *m_lnk; - bool m_useHard = false; bool m_linkRecursive = true; }; @@ -346,7 +345,7 @@ slots: void test_link() { QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder"); - auto f = [&folder, this]() + auto f = [&folder]() { QTemporaryDir tempDir; tempDir.setAutoRemove(true); @@ -640,7 +639,7 @@ slots: void test_link_with_max_depth() { QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder"); - auto f = [&folder, this]() + auto f = [&folder]() { QTemporaryDir tempDir; tempDir.setAutoRemove(true); diff --git a/tests/GZip_test.cpp b/tests/GZip_test.cpp index 82503d81..ccaa3610 100644 --- a/tests/GZip_test.cpp +++ b/tests/GZip_test.cpp @@ -29,7 +29,7 @@ slots: // initialize random buffer for(int i = 0; i < size; i++) { - random.append((char)idis(eng)); + random.append(static_cast(idis(eng))); } // initialize fibonacci diff --git a/tests/ResourceModel_test.cpp b/tests/ResourceModel_test.cpp index c0d9cd95..ecaea524 100644 --- a/tests/ResourceModel_test.cpp +++ b/tests/ResourceModel_test.cpp @@ -39,17 +39,17 @@ class DummyResourceModel : public ResourceModel { public: DummyResourceModel() : ResourceModel(new DummyResourceAPI) {} - [[nodiscard]] auto metaEntryBase() const -> QString override { return ""; }; + [[nodiscard]] auto metaEntryBase() const -> QString override { return ""; } - ResourceAPI::SearchArgs createSearchArguments() override { return {}; }; - ResourceAPI::VersionSearchArgs createVersionsArguments(QModelIndex&) override { return {}; }; - ResourceAPI::ProjectInfoArgs createInfoArguments(QModelIndex&) override { return {}; }; + ResourceAPI::SearchArgs createSearchArguments() override { return {}; } + ResourceAPI::VersionSearchArgs createVersionsArguments(QModelIndex&) override { return {}; } + ResourceAPI::ProjectInfoArgs createInfoArguments(QModelIndex&) override { return {}; } QJsonArray documentToArray(QJsonDocument& doc) const override { return doc.object().value("hits").toArray(); } void loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj) override { - pack.authors.append({ Json::requireString(obj, "author") }); + pack.authors.append({ Json::requireString(obj, "author"), "" }); pack.description = Json::requireString(obj, "description"); pack.addonId = Json::requireString(obj, "project_id"); } diff --git a/tests/Task_test.cpp b/tests/Task_test.cpp index dabe5da2..04f2abcc 100644 --- a/tests/Task_test.cpp +++ b/tests/Task_test.cpp @@ -22,7 +22,7 @@ class BasicTask : public Task { void executeTask() override { emitSucceeded(); - }; + } }; /* Does nothing. Only used for testing. */ @@ -34,7 +34,7 @@ class BasicTask_MultiStep : public Task { private: auto isMultiStep() const -> bool override { return true; } - void executeTask() override {}; + void executeTask() override {} }; class BigConcurrentTask : public ConcurrentTask { -- cgit From df18d8560dd4648d21cfdddb463e5e9770a822f7 Mon Sep 17 00:00:00 2001 From: Rachel Powers <508861+Ryex@users.noreply.github.com> Date: Sun, 4 Jun 2023 22:46:05 -0700 Subject: chore: fix test & clean up one last warning Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com> --- tests/FileSystem_test.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/FileSystem_test.cpp b/tests/FileSystem_test.cpp index 9bb681ae..49397e07 100644 --- a/tests/FileSystem_test.cpp +++ b/tests/FileSystem_test.cpp @@ -94,6 +94,7 @@ class LinkTask : public Task { } FS::create_link *m_lnk; + [[maybe_unused]] bool m_useHard = false; bool m_linkRecursive = true; }; -- cgit From 1d468ac35ad88d8c77cc83f25e3704d9bd7df01b Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Wed, 2 Aug 2023 18:35:35 +0200 Subject: chore: reformat Signed-off-by: Sefa Eyeoglu --- tests/DataPackParse_test.cpp | 8 +- tests/FileSystem_test.cpp | 275 +- tests/GZip_test.cpp | 14 +- tests/GradleSpecifier_test.cpp | 22 +- tests/Index_test.cpp | 22 +- tests/JavaVersion_test.cpp | 69 +- tests/Library_test.cpp | 60 +- tests/MojangVersionFormat_test.cpp | 11 +- tests/Packwiz_test.cpp | 16 +- tests/ParseUtils_test.cpp | 24 +- tests/ResourceFolderModel_test.cpp | 100 +- tests/ResourceModel_test.cpp | 3 +- tests/ResourcePackParse_test.cpp | 14 +- tests/ShaderPackParse_test.cpp | 8 +- tests/Task_test.cpp | 5 +- tests/TexturePackParse_test.cpp | 8 +- tests/Version_test.cpp | 79 +- tests/WorldSaveParse_test.cpp | 18 +- tests/testdata/MojangVersionFormat/1.9-simple.json | 3 +- tests/testdata/MojangVersionFormat/1.9.json | 54 +- tests/testdata/MojangVersionFormat/lib-native.json | 12 +- tests/testdata/PackageManifest/1.8.0_202-x64.json | 4668 +++++++++++++++++++- 22 files changed, 5082 insertions(+), 411 deletions(-) (limited to 'tests') diff --git a/tests/DataPackParse_test.cpp b/tests/DataPackParse_test.cpp index 61ce1e2b..cd6ae8e8 100644 --- a/tests/DataPackParse_test.cpp +++ b/tests/DataPackParse_test.cpp @@ -30,13 +30,13 @@ class DataPackParseTest : public QObject { Q_OBJECT - private slots: + private slots: void test_parseZIP() { QString source = QFINDTESTDATA("testdata/DataPackParse"); QString zip_dp = FS::PathCombine(source, "test_data_pack_boogaloo.zip"); - DataPack pack { QFileInfo(zip_dp) }; + DataPack pack{ QFileInfo(zip_dp) }; bool valid = DataPackUtils::processZIP(pack); @@ -50,7 +50,7 @@ class DataPackParseTest : public QObject { QString source = QFINDTESTDATA("testdata/DataPackParse"); QString folder_dp = FS::PathCombine(source, "test_folder"); - DataPack pack { QFileInfo(folder_dp) }; + DataPack pack{ QFileInfo(folder_dp) }; bool valid = DataPackUtils::processFolder(pack); @@ -64,7 +64,7 @@ class DataPackParseTest : public QObject { QString source = QFINDTESTDATA("testdata/DataPackParse"); QString folder_dp = FS::PathCombine(source, "another_test_folder"); - DataPack pack { QFileInfo(folder_dp) }; + DataPack pack{ QFileInfo(folder_dp) }; bool valid = DataPackUtils::process(pack); diff --git a/tests/FileSystem_test.cpp b/tests/FileSystem_test.cpp index a41345c2..3adcd343 100644 --- a/tests/FileSystem_test.cpp +++ b/tests/FileSystem_test.cpp @@ -1,7 +1,7 @@ -#include #include -#include #include +#include +#include #include @@ -11,16 +11,16 @@ // Snippet from https://github.com/gulrak/filesystem#using-it-as-single-file-header #ifdef __APPLE__ -#include // for deployment target to support pre-catalina targets without std::fs -#endif // __APPLE__ +#include // for deployment target to support pre-catalina targets without std::fs +#endif // __APPLE__ #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (defined(__cplusplus) && __cplusplus >= 201703L)) && defined(__has_include) #if __has_include() && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) #define GHC_USE_STD_FS #include namespace fs = std::filesystem; -#endif // MacOS min version check -#endif // Other OSes version check +#endif // MacOS min version check +#endif // Other OSes version check #ifndef GHC_USE_STD_FS #include @@ -29,8 +29,6 @@ namespace fs = ghc::filesystem; #include - - class LinkTask : public Task { Q_OBJECT @@ -42,41 +40,30 @@ class LinkTask : public Task { m_lnk->debug(true); } - ~LinkTask() { - delete m_lnk; - } + ~LinkTask() { delete m_lnk; } - void matcher(const IPathMatcher *filter) - { - m_lnk->matcher(filter); - } + void matcher(const IPathMatcher* filter) { m_lnk->matcher(filter); } - void linkRecursively(bool recursive) + void linkRecursively(bool recursive) { m_lnk->linkRecursively(recursive); m_linkRecursive = recursive; } - void whitelist(bool b) - { - m_lnk->whitelist(b); - } + void whitelist(bool b) { m_lnk->whitelist(b); } - void setMaxDepth(int depth) - { - m_lnk->setMaxDepth(depth); - } + void setMaxDepth(int depth) { m_lnk->setMaxDepth(depth); } private: void executeTask() override { - if(!(*m_lnk)()){ + if (!(*m_lnk)()) { #if defined Q_OS_WIN32 if (!m_useHard) { qDebug() << "EXPECTED: Link failure, Windows requires permissions for symlinks"; qDebug() << "atempting to run with privelage"; - connect(m_lnk, &FS::create_link::finishedPrivileged, this, [&](bool gotResults){ + connect(m_lnk, &FS::create_link::finishedPrivileged, this, [&](bool gotResults) { if (gotResults) { emitSucceeded(); } else { @@ -87,32 +74,28 @@ class LinkTask : public Task { m_lnk->runPrivileged(); } else { qDebug() << "Link Failed!" << m_lnk->getOSError().value() << m_lnk->getOSError().message().c_str(); - } + } #else qDebug() << "Link Failed!" << m_lnk->getOSError().value() << m_lnk->getOSError().message().c_str(); #endif } else { emitSucceeded(); } - }; - FS::create_link *m_lnk; + FS::create_link* m_lnk; bool m_useHard = false; bool m_linkRecursive = true; }; - -class FileSystemTest : public QObject -{ +class FileSystemTest : public QObject { Q_OBJECT const QString bothSlash = "/foo/"; const QString trailingSlash = "foo/"; const QString leadingSlash = "/foo"; -private -slots: + private slots: void test_pathCombine() { QCOMPARE(QString("/foo/foo"), FS::PathCombine(bothSlash, bothSlash)); @@ -130,12 +113,22 @@ slots: QTest::addColumn("path1"); QTest::addColumn("path2"); - QTest::newRow("qt 1") << "/abc/def/ghi/jkl" << "/abc/def" << "ghi/jkl"; - QTest::newRow("qt 2") << "/abc/def/ghi/jkl" << "/abc/def/" << "ghi/jkl"; + QTest::newRow("qt 1") << "/abc/def/ghi/jkl" + << "/abc/def" + << "ghi/jkl"; + QTest::newRow("qt 2") << "/abc/def/ghi/jkl" + << "/abc/def/" + << "ghi/jkl"; #if defined(Q_OS_WIN) - QTest::newRow("win native, from C:") << "C:/abc" << "C:" << "abc"; - QTest::newRow("win native 1") << "C:/abc/def/ghi/jkl" << "C:\\abc\\def" << "ghi\\jkl"; - QTest::newRow("win native 2") << "C:/abc/def/ghi/jkl" << "C:\\abc\\def\\" << "ghi\\jkl"; + QTest::newRow("win native, from C:") << "C:/abc" + << "C:" + << "abc"; + QTest::newRow("win native 1") << "C:/abc/def/ghi/jkl" + << "C:\\abc\\def" + << "ghi\\jkl"; + QTest::newRow("win native 2") << "C:/abc/def/ghi/jkl" + << "C:\\abc\\def\\" + << "ghi\\jkl"; #endif } @@ -155,15 +148,39 @@ slots: QTest::addColumn("path2"); QTest::addColumn("path3"); - QTest::newRow("qt 1") << "/abc/def/ghi/jkl" << "/abc" << "def" << "ghi/jkl"; - QTest::newRow("qt 2") << "/abc/def/ghi/jkl" << "/abc/" << "def" << "ghi/jkl"; - QTest::newRow("qt 3") << "/abc/def/ghi/jkl" << "/abc" << "def/" << "ghi/jkl"; - QTest::newRow("qt 4") << "/abc/def/ghi/jkl" << "/abc/" << "def/" << "ghi/jkl"; + QTest::newRow("qt 1") << "/abc/def/ghi/jkl" + << "/abc" + << "def" + << "ghi/jkl"; + QTest::newRow("qt 2") << "/abc/def/ghi/jkl" + << "/abc/" + << "def" + << "ghi/jkl"; + QTest::newRow("qt 3") << "/abc/def/ghi/jkl" + << "/abc" + << "def/" + << "ghi/jkl"; + QTest::newRow("qt 4") << "/abc/def/ghi/jkl" + << "/abc/" + << "def/" + << "ghi/jkl"; #if defined(Q_OS_WIN) - QTest::newRow("win 1") << "C:/abc/def/ghi/jkl" << "C:\\abc" << "def" << "ghi\\jkl"; - QTest::newRow("win 2") << "C:/abc/def/ghi/jkl" << "C:\\abc\\" << "def" << "ghi\\jkl"; - QTest::newRow("win 3") << "C:/abc/def/ghi/jkl" << "C:\\abc" << "def\\" << "ghi\\jkl"; - QTest::newRow("win 4") << "C:/abc/def/ghi/jkl" << "C:\\abc\\" << "def" << "ghi\\jkl"; + QTest::newRow("win 1") << "C:/abc/def/ghi/jkl" + << "C:\\abc" + << "def" + << "ghi\\jkl"; + QTest::newRow("win 2") << "C:/abc/def/ghi/jkl" + << "C:\\abc\\" + << "def" + << "ghi\\jkl"; + QTest::newRow("win 3") << "C:/abc/def/ghi/jkl" + << "C:\\abc" + << "def\\" + << "ghi\\jkl"; + QTest::newRow("win 4") << "C:/abc/def/ghi/jkl" + << "C:\\abc\\" + << "def" + << "ghi\\jkl"; #endif } @@ -180,8 +197,7 @@ slots: void test_copy() { QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder"); - auto f = [&folder]() - { + auto f = [&folder]() { QTemporaryDir tempDir; tempDir.setAutoRemove(true); qDebug() << "From:" << folder << "To:" << tempDir.path(); @@ -192,8 +208,7 @@ slots: FS::copy c(folder, target_dir.path()); c(); - for(auto entry: target_dir.entryList()) - { + for (auto entry : target_dir.entryList()) { qDebug() << entry; } QVERIFY(target_dir.entryList().contains("pack.mcmeta")); @@ -213,8 +228,7 @@ slots: void test_copy_with_blacklist() { QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder"); - auto f = [&folder]() - { + auto f = [&folder]() { QTemporaryDir tempDir; tempDir.setAutoRemove(true); qDebug() << "From:" << folder << "To:" << tempDir.path(); @@ -227,8 +241,7 @@ slots: c.matcher(&re); c(); - for(auto entry: target_dir.entryList()) - { + for (auto entry : target_dir.entryList()) { qDebug() << entry; } QVERIFY(!target_dir.entryList().contains("pack.mcmeta")); @@ -248,8 +261,7 @@ slots: void test_copy_with_whitelist() { QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder"); - auto f = [&folder]() - { + auto f = [&folder]() { QTemporaryDir tempDir; tempDir.setAutoRemove(true); qDebug() << "From:" << folder << "To:" << tempDir.path(); @@ -263,8 +275,7 @@ slots: c.whitelist(true); c(); - for(auto entry: target_dir.entryList()) - { + for (auto entry : target_dir.entryList()) { qDebug() << entry; } QVERIFY(target_dir.entryList().contains("pack.mcmeta")); @@ -284,8 +295,7 @@ slots: void test_copy_with_dot_hidden() { QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder"); - auto f = [&folder]() - { + auto f = [&folder]() { QTemporaryDir tempDir; tempDir.setAutoRemove(true); qDebug() << "From:" << folder << "To:" << tempDir.path(); @@ -298,7 +308,7 @@ slots: auto filter = QDir::Filter::Files | QDir::Filter::Dirs | QDir::Filter::Hidden; - for (auto entry: target_dir.entryList(filter)) { + for (auto entry : target_dir.entryList(filter)) { qDebug() << entry; } @@ -335,7 +345,7 @@ slots: auto filter = QDir::Filter::Files; - for (auto entry: target_dir.entryList(filter)) { + for (auto entry : target_dir.entryList(filter)) { qDebug() << entry; } @@ -348,12 +358,10 @@ slots: QCOMPARE(FS::getDesktopDir(), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)); } - void test_link() { QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder"); - auto f = [&folder, this]() - { + auto f = [&folder, this]() { QTemporaryDir tempDir; tempDir.setAutoRemove(true); qDebug() << "From:" << folder << "To:" << tempDir.path(); @@ -364,17 +372,13 @@ slots: LinkTask lnk_tsk(folder, target_dir.path()); lnk_tsk.linkRecursively(false); - QObject::connect(&lnk_tsk, &Task::finished, [&]{ - QVERIFY2(lnk_tsk.wasSuccessful(), "Task finished but was not successful when it should have been."); - }); + QObject::connect(&lnk_tsk, &Task::finished, + [&] { QVERIFY2(lnk_tsk.wasSuccessful(), "Task finished but was not successful when it should have been."); }); lnk_tsk.start(); - QVERIFY2(QTest::qWaitFor([&]() { - return lnk_tsk.isFinished(); - }, 100000), "Task didn't finish as it should."); + QVERIFY2(QTest::qWaitFor([&]() { return lnk_tsk.isFinished(); }, 100000), "Task didn't finish as it should."); - for(auto entry: target_dir.entryList()) - { + for (auto entry : target_dir.entryList()) { qDebug() << entry; QFileInfo entry_lnk_info(target_dir.filePath(entry)); if (!entry_lnk_info.isDir()) @@ -402,10 +406,9 @@ slots: void test_hard_link() { QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder"); - auto f = [&folder]() - { + auto f = [&folder]() { // use working dir to prevent makeing a hard link to a tmpfs or across devices - QTemporaryDir tempDir("./tmp"); + QTemporaryDir tempDir("./tmp"); tempDir.setAutoRemove(true); qDebug() << "From:" << folder << "To:" << tempDir.path(); @@ -415,23 +418,20 @@ slots: FS::create_link lnk(folder, target_dir.path()); lnk.useHardLinks(true); lnk.debug(true); - if(!lnk()){ + if (!lnk()) { qDebug() << "Link Failed!" << lnk.getOSError().value() << lnk.getOSError().message().c_str(); } - for(auto entry: target_dir.entryList()) - { + for (auto entry : target_dir.entryList()) { qDebug() << entry; QFileInfo entry_lnk_info(target_dir.filePath(entry)); QVERIFY(!entry_lnk_info.isSymLink()); QFileInfo entry_orig_info(QDir(folder).filePath(entry)); if (!entry_lnk_info.isDir()) { qDebug() << "hard link equivalency?" << entry_lnk_info.absoluteFilePath() << "vs" << entry_orig_info.absoluteFilePath(); - QVERIFY(fs::equivalent( - fs::path(StringUtils::toStdString(entry_lnk_info.absoluteFilePath())), - fs::path(StringUtils::toStdString(entry_orig_info.absoluteFilePath())) - )); - } + QVERIFY(fs::equivalent(fs::path(StringUtils::toStdString(entry_lnk_info.absoluteFilePath())), + fs::path(StringUtils::toStdString(entry_orig_info.absoluteFilePath())))); + } } QFileInfo lnk_info(target_dir.path()); @@ -455,8 +455,7 @@ slots: void test_link_with_blacklist() { QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder"); - auto f = [&folder]() - { + auto f = [&folder]() { QTemporaryDir tempDir; tempDir.setAutoRemove(true); qDebug() << "From:" << folder << "To:" << tempDir.path(); @@ -469,18 +468,13 @@ slots: RegexpMatcher re("[.]?mcmeta"); lnk_tsk.matcher(&re); lnk_tsk.linkRecursively(true); - QObject::connect(&lnk_tsk, &Task::finished, [&]{ - QVERIFY2(lnk_tsk.wasSuccessful(), "Task finished but was not successful when it should have been."); - }); + QObject::connect(&lnk_tsk, &Task::finished, + [&] { QVERIFY2(lnk_tsk.wasSuccessful(), "Task finished but was not successful when it should have been."); }); lnk_tsk.start(); - QVERIFY2(QTest::qWaitFor([&]() { - return lnk_tsk.isFinished(); - }, 100000), "Task didn't finish as it should."); - + QVERIFY2(QTest::qWaitFor([&]() { return lnk_tsk.isFinished(); }, 100000), "Task didn't finish as it should."); - for(auto entry: target_dir.entryList()) - { + for (auto entry : target_dir.entryList()) { qDebug() << entry; QFileInfo entry_lnk_info(target_dir.filePath(entry)); if (!entry_lnk_info.isDir()) @@ -507,8 +501,7 @@ slots: void test_link_with_whitelist() { QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder"); - auto f = [&folder]() - { + auto f = [&folder]() { QTemporaryDir tempDir; tempDir.setAutoRemove(true); qDebug() << "From:" << folder << "To:" << tempDir.path(); @@ -522,17 +515,13 @@ slots: lnk_tsk.matcher(&re); lnk_tsk.linkRecursively(true); lnk_tsk.whitelist(true); - QObject::connect(&lnk_tsk, &Task::finished, [&]{ - QVERIFY2(lnk_tsk.wasSuccessful(), "Task finished but was not successful when it should have been."); - }); + QObject::connect(&lnk_tsk, &Task::finished, + [&] { QVERIFY2(lnk_tsk.wasSuccessful(), "Task finished but was not successful when it should have been."); }); lnk_tsk.start(); - QVERIFY2(QTest::qWaitFor([&]() { - return lnk_tsk.isFinished(); - }, 100000), "Task didn't finish as it should."); + QVERIFY2(QTest::qWaitFor([&]() { return lnk_tsk.isFinished(); }, 100000), "Task didn't finish as it should."); - for(auto entry: target_dir.entryList()) - { + for (auto entry : target_dir.entryList()) { qDebug() << entry; QFileInfo entry_lnk_info(target_dir.filePath(entry)); if (!entry_lnk_info.isDir()) @@ -559,8 +548,7 @@ slots: void test_link_with_dot_hidden() { QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder"); - auto f = [&folder]() - { + auto f = [&folder]() { QTemporaryDir tempDir; tempDir.setAutoRemove(true); qDebug() << "From:" << folder << "To:" << tempDir.path(); @@ -571,18 +559,15 @@ slots: LinkTask lnk_tsk(folder, target_dir.path()); lnk_tsk.linkRecursively(true); - QObject::connect(&lnk_tsk, &Task::finished, [&]{ - QVERIFY2(lnk_tsk.wasSuccessful(), "Task finished but was not successful when it should have been."); - }); + QObject::connect(&lnk_tsk, &Task::finished, + [&] { QVERIFY2(lnk_tsk.wasSuccessful(), "Task finished but was not successful when it should have been."); }); lnk_tsk.start(); - QVERIFY2(QTest::qWaitFor([&]() { - return lnk_tsk.isFinished(); - }, 100000), "Task didn't finish as it should."); + QVERIFY2(QTest::qWaitFor([&]() { return lnk_tsk.isFinished(); }, 100000), "Task didn't finish as it should."); auto filter = QDir::Filter::Files | QDir::Filter::Dirs | QDir::Filter::Hidden; - for (auto entry: target_dir.entryList(filter)) { + for (auto entry : target_dir.entryList(filter)) { qDebug() << entry; QFileInfo entry_lnk_info(target_dir.filePath(entry)); if (!entry_lnk_info.isDir()) @@ -621,19 +606,16 @@ slots: qDebug() << tempDir.path(); qDebug() << target_dir.path(); - LinkTask lnk_tsk(file, target_dir.filePath("pack.mcmeta")); - QObject::connect(&lnk_tsk, &Task::finished, [&]{ - QVERIFY2(lnk_tsk.wasSuccessful(), "Task finished but was not successful when it should have been."); - }); + LinkTask lnk_tsk(file, target_dir.filePath("pack.mcmeta")); + QObject::connect(&lnk_tsk, &Task::finished, + [&] { QVERIFY2(lnk_tsk.wasSuccessful(), "Task finished but was not successful when it should have been."); }); lnk_tsk.start(); - QVERIFY2(QTest::qWaitFor([&]() { - return lnk_tsk.isFinished(); - }, 100000), "Task didn't finish as it should."); + QVERIFY2(QTest::qWaitFor([&]() { return lnk_tsk.isFinished(); }, 100000), "Task didn't finish as it should."); auto filter = QDir::Filter::Files; - for (auto entry: target_dir.entryList(filter)) { + for (auto entry : target_dir.entryList(filter)) { qDebug() << entry; } @@ -648,8 +630,7 @@ slots: void test_link_with_max_depth() { QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder"); - auto f = [&folder, this]() - { + auto f = [&folder, this]() { QTemporaryDir tempDir; tempDir.setAutoRemove(true); qDebug() << "From:" << folder << "To:" << tempDir.path(); @@ -661,22 +642,19 @@ slots: LinkTask lnk_tsk(folder, target_dir.path()); lnk_tsk.linkRecursively(true); lnk_tsk.setMaxDepth(0); - QObject::connect(&lnk_tsk, &Task::finished, [&]{ - QVERIFY2(lnk_tsk.wasSuccessful(), "Task finished but was not successful when it should have been."); - }); + QObject::connect(&lnk_tsk, &Task::finished, + [&] { QVERIFY2(lnk_tsk.wasSuccessful(), "Task finished but was not successful when it should have been."); }); lnk_tsk.start(); - QVERIFY2(QTest::qWaitFor([&]() { - return lnk_tsk.isFinished(); - }, 100000), "Task didn't finish as it should."); + QVERIFY2(QTest::qWaitFor([&]() { return lnk_tsk.isFinished(); }, 100000), "Task didn't finish as it should."); QVERIFY(!QFileInfo(target_dir.path()).isSymLink()); auto filter = QDir::Filter::Files | QDir::Filter::Dirs | QDir::Filter::Hidden; - for(auto entry: target_dir.entryList(filter)) - { + for (auto entry : target_dir.entryList(filter)) { qDebug() << entry; - if (entry == "." || entry == "..") continue; + if (entry == "." || entry == "..") + continue; QFileInfo entry_lnk_info(target_dir.filePath(entry)); QVERIFY(entry_lnk_info.isSymLink()); } @@ -687,8 +665,6 @@ slots: QVERIFY(target_dir.entryList().contains("pack.mcmeta")); QVERIFY(target_dir.entryList().contains("assets")); - - }; // first try variant without trailing / @@ -704,8 +680,7 @@ slots: void test_link_with_no_max_depth() { QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder"); - auto f = [&folder]() - { + auto f = [&folder]() { QTemporaryDir tempDir; tempDir.setAutoRemove(true); qDebug() << "From:" << folder << "To:" << tempDir.path(); @@ -717,24 +692,19 @@ slots: LinkTask lnk_tsk(folder, target_dir.path()); lnk_tsk.linkRecursively(true); lnk_tsk.setMaxDepth(-1); - QObject::connect(&lnk_tsk, &Task::finished, [&]{ - QVERIFY2(lnk_tsk.wasSuccessful(), "Task finished but was not successful when it should have been."); - }); + QObject::connect(&lnk_tsk, &Task::finished, + [&] { QVERIFY2(lnk_tsk.wasSuccessful(), "Task finished but was not successful when it should have been."); }); lnk_tsk.start(); - QVERIFY2(QTest::qWaitFor([&]() { - return lnk_tsk.isFinished(); - }, 100000), "Task didn't finish as it should."); - + QVERIFY2(QTest::qWaitFor([&]() { return lnk_tsk.isFinished(); }, 100000), "Task didn't finish as it should."); std::function verify_check = [&](QString check_path) { QDir check_dir(check_path); auto filter = QDir::Filter::Files | QDir::Filter::Dirs | QDir::Filter::Hidden; - for(auto entry: check_dir.entryList(filter)) - { + for (auto entry : check_dir.entryList(filter)) { QFileInfo entry_lnk_info(check_dir.filePath(entry)); qDebug() << entry << check_dir.filePath(entry); - if (!entry_lnk_info.isDir()){ + if (!entry_lnk_info.isDir()) { QVERIFY(entry_lnk_info.isSymLink()); } else if (entry != "." && entry != "..") { qDebug() << "Decending tree to verify symlinks:" << check_dir.filePath(entry); @@ -742,9 +712,8 @@ slots: } } }; - + verify_check(target_dir.path()); - QFileInfo lnk_info(target_dir.path()); QVERIFY(lnk_info.exists()); @@ -763,7 +732,8 @@ slots: f(); } - void test_path_depth() { + void test_path_depth() + { QCOMPARE(FS::pathDepth(""), 0); QCOMPARE(FS::pathDepth("."), 0); QCOMPARE(FS::pathDepth("foo.txt"), 0); @@ -777,7 +747,8 @@ slots: QCOMPARE(FS::pathDepth("/baz/../bar/foo.txt"), 1); } - void test_path_trunc() { + void test_path_trunc() + { QCOMPARE(FS::pathTruncate("", 0), QDir::toNativeSeparators("")); QCOMPARE(FS::pathTruncate("foo.txt", 0), QDir::toNativeSeparators("")); QCOMPARE(FS::pathTruncate("foo.txt", 1), QDir::toNativeSeparators("")); diff --git a/tests/GZip_test.cpp b/tests/GZip_test.cpp index 82503d81..4c1259c2 100644 --- a/tests/GZip_test.cpp +++ b/tests/GZip_test.cpp @@ -3,18 +3,16 @@ #include #include -void fib(int &prev, int &cur) +void fib(int& prev, int& cur) { auto ret = prev + cur; prev = cur; cur = ret; } -class GZipTest : public QObject -{ +class GZipTest : public QObject { Q_OBJECT -private -slots: + private slots: void test_Through() { @@ -27,8 +25,7 @@ slots: std::uniform_int_distribution idis(0, std::numeric_limits::max()); // initialize random buffer - for(int i = 0; i < size; i++) - { + for (int i = 0; i < size; i++) { random.append((char)idis(eng)); } @@ -37,8 +34,7 @@ slots: int cur = 1; // test if fibonacci long random buffers pass through GZip - do - { + do { QByteArray copy = random; copy.resize(cur); compressed.clear(); diff --git a/tests/GradleSpecifier_test.cpp b/tests/GradleSpecifier_test.cpp index 850f8388..fa3c4ad9 100644 --- a/tests/GradleSpecifier_test.cpp +++ b/tests/GradleSpecifier_test.cpp @@ -2,19 +2,11 @@ #include -class GradleSpecifierTest : public QObject -{ +class GradleSpecifierTest : public QObject { Q_OBJECT -private -slots: - void initTestCase() - { - - } - void cleanupTestCase() - { - - } + private slots: + void initTestCase() {} + void cleanupTestCase() {} void test_Positive_data() { @@ -40,8 +32,10 @@ slots: QTest::addColumn("spec"); QTest::addColumn("expected"); - QTest::newRow("3 parter") << "group.id:artifact:1.0" << "group/id/artifact/1.0/artifact-1.0.jar"; - QTest::newRow("doom") << "id.software:doom:1.666:demons@wad" << "id/software/doom/1.666/doom-1.666-demons.wad"; + QTest::newRow("3 parter") << "group.id:artifact:1.0" + << "group/id/artifact/1.0/artifact-1.0.jar"; + QTest::newRow("doom") << "id.software:doom:1.666:demons@wad" + << "id/software/doom/1.666/doom-1.666-demons.wad"; } void test_Path() { diff --git a/tests/Index_test.cpp b/tests/Index_test.cpp index 436b753e..888021e2 100644 --- a/tests/Index_test.cpp +++ b/tests/Index_test.cpp @@ -3,14 +3,13 @@ #include #include -class IndexTest : public QObject -{ +class IndexTest : public QObject { Q_OBJECT -private -slots: + private slots: void test_hasUid_and_getList() { - Meta::Index windex({std::make_shared("list1"), std::make_shared("list2"), std::make_shared("list3")}); + Meta::Index windex({ std::make_shared("list1"), std::make_shared("list2"), + std::make_shared("list3") }); QVERIFY(windex.hasUid("list1")); QVERIFY(!windex.hasUid("asdf")); QVERIFY(windex.get("list2") != nullptr); @@ -20,13 +19,18 @@ slots: void test_merge() { - Meta::Index windex({std::make_shared("list1"), std::make_shared("list2"), std::make_shared("list3")}); + Meta::Index windex({ std::make_shared("list1"), std::make_shared("list2"), + std::make_shared("list3") }); QCOMPARE(windex.lists().size(), 3); - windex.merge(std::shared_ptr(new Meta::Index({std::make_shared("list1"), std::make_shared("list2"), std::make_shared("list3")}))); + windex.merge(std::shared_ptr( + new Meta::Index({ std::make_shared("list1"), std::make_shared("list2"), + std::make_shared("list3") }))); QCOMPARE(windex.lists().size(), 3); - windex.merge(std::shared_ptr(new Meta::Index({std::make_shared("list4"), std::make_shared("list2"), std::make_shared("list5")}))); + windex.merge(std::shared_ptr( + new Meta::Index({ std::make_shared("list4"), std::make_shared("list2"), + std::make_shared("list5") }))); QCOMPARE(windex.lists().size(), 5); - windex.merge(std::shared_ptr(new Meta::Index({std::make_shared("list6")}))); + windex.merge(std::shared_ptr(new Meta::Index({ std::make_shared("list6") }))); QCOMPARE(windex.lists().size(), 6); } }; diff --git a/tests/JavaVersion_test.cpp b/tests/JavaVersion_test.cpp index 76d9af2f..fd285195 100644 --- a/tests/JavaVersion_test.cpp +++ b/tests/JavaVersion_test.cpp @@ -2,11 +2,9 @@ #include -class JavaVersionTest : public QObject -{ +class JavaVersionTest : public QObject { Q_OBJECT -private -slots: + private slots: void test_Parse_data() { QTest::addColumn("string"); @@ -50,33 +48,54 @@ slots: QTest::addColumn("bigger"); // old format and new format equivalence - QTest::newRow("1.6.0_33 == 6.0.33") << "1.6.0_33" << "6.0.33" << false << true << false; + QTest::newRow("1.6.0_33 == 6.0.33") << "1.6.0_33" + << "6.0.33" << false << true << false; // old format major version - QTest::newRow("1.5.0_33 < 1.6.0_33") << "1.5.0_33" << "1.6.0_33" << true << false << false; + QTest::newRow("1.5.0_33 < 1.6.0_33") << "1.5.0_33" + << "1.6.0_33" << true << false << false; // new format - first release vs first security patch - QTest::newRow("9 < 9.0.1") << "9" << "9.0.1" << true << false << false; - QTest::newRow("9.0.1 > 9") << "9.0.1" << "9" << false << false << true; + QTest::newRow("9 < 9.0.1") << "9" + << "9.0.1" << true << false << false; + QTest::newRow("9.0.1 > 9") << "9.0.1" + << "9" << false << false << true; // new format - first minor vs first release/security patch - QTest::newRow("9.1 > 9.0.1") << "9.1" << "9.0.1" << false << false << true; - QTest::newRow("9.0.1 < 9.1") << "9.0.1" << "9.1" << true << false << false; - QTest::newRow("9.1 > 9") << "9.1" << "9" << false << false << true; - QTest::newRow("9 > 9.1") << "9" << "9.1" << true << false << false; + QTest::newRow("9.1 > 9.0.1") << "9.1" + << "9.0.1" << false << false << true; + QTest::newRow("9.0.1 < 9.1") << "9.0.1" + << "9.1" << true << false << false; + QTest::newRow("9.1 > 9") << "9.1" + << "9" << false << false << true; + QTest::newRow("9 > 9.1") << "9" + << "9.1" << true << false << false; // new format - omitted numbers - QTest::newRow("9 == 9.0") << "9" << "9.0" << false << true << false; - QTest::newRow("9 == 9.0.0") << "9" << "9.0.0" << false << true << false; - QTest::newRow("9.0 == 9.0.0") << "9.0" << "9.0.0" << false << true << false; + QTest::newRow("9 == 9.0") << "9" + << "9.0" << false << true << false; + QTest::newRow("9 == 9.0.0") << "9" + << "9.0.0" << false << true << false; + QTest::newRow("9.0 == 9.0.0") << "9.0" + << "9.0.0" << false << true << false; // early access and prereleases compared to final release - QTest::newRow("9-ea < 9") << "9-ea" << "9" << true << false << false; - QTest::newRow("9 < 9.0.1-ea") << "9" << "9.0.1-ea" << true << false << false; - QTest::newRow("9.0.1-ea > 9") << "9.0.1-ea" << "9" << false << false << true; + QTest::newRow("9-ea < 9") << "9-ea" + << "9" << true << false << false; + QTest::newRow("9 < 9.0.1-ea") << "9" + << "9.0.1-ea" << true << false << false; + QTest::newRow("9.0.1-ea > 9") << "9.0.1-ea" + << "9" << false << false << true; // prerelease difference only testing - QTest::newRow("9-1 == 9-1") << "9-1" << "9-1" << false << true << false; - QTest::newRow("9-1 < 9-2") << "9-1" << "9-2" << true << false << false; - QTest::newRow("9-5 < 9-20") << "9-5" << "9-20" << true << false << false; - QTest::newRow("9-rc1 < 9-rc2") << "9-rc1" << "9-rc2" << true << false << false; - QTest::newRow("9-rc5 < 9-rc20") << "9-rc5" << "9-rc20" << true << false << false; - QTest::newRow("9-rc < 9-rc2") << "9-rc" << "9-rc2" << true << false << false; - QTest::newRow("9-ea < 9-rc") << "9-ea" << "9-rc" << true << false << false; + QTest::newRow("9-1 == 9-1") << "9-1" + << "9-1" << false << true << false; + QTest::newRow("9-1 < 9-2") << "9-1" + << "9-2" << true << false << false; + QTest::newRow("9-5 < 9-20") << "9-5" + << "9-20" << true << false << false; + QTest::newRow("9-rc1 < 9-rc2") << "9-rc1" + << "9-rc2" << true << false << false; + QTest::newRow("9-rc5 < 9-rc20") << "9-rc5" + << "9-rc20" << true << false << false; + QTest::newRow("9-rc < 9-rc2") << "9-rc" + << "9-rc2" << true << false << false; + QTest::newRow("9-ea < 9-rc") << "9-ea" + << "9-rc" << true << false << false; } void test_Sort() { diff --git a/tests/Library_test.cpp b/tests/Library_test.cpp index db8380c7..e8090c09 100644 --- a/tests/Library_test.cpp +++ b/tests/Library_test.cpp @@ -35,17 +35,16 @@ #include +#include +#include +#include #include #include -#include #include -#include -#include -class LibraryTest : public QObject -{ +class LibraryTest : public QObject { Q_OBJECT -private: + private: LibraryPtr readMojangJson(const QString path) { QFile jsonFile(path); @@ -56,20 +55,17 @@ private: return MojangVersionFormat::libraryFromJson(problems, QJsonDocument::fromJson(data).object(), path); } // get absolute path to expected storage, assuming default cache prefix - QStringList getStorage(QString relative) - { - return {FS::PathCombine(cache->getBasePath("libraries"), relative)}; - } + QStringList getStorage(QString relative) { return { FS::PathCombine(cache->getBasePath("libraries"), relative) }; } - RuntimeContext dummyContext(QString system = "linux", QString arch = "64", QString realArch = "amd64") { + RuntimeContext dummyContext(QString system = "linux", QString arch = "64", QString realArch = "amd64") + { RuntimeContext r; r.javaArchitecture = arch; r.javaRealArchitecture = realArch; r.system = system; return r; } -private -slots: + private slots: void initTestCase() { cache.reset(new HttpMetaCache()); @@ -111,7 +107,7 @@ slots: test.setHint("local"); auto downloads = test.getDownloads(r, cache.get(), failedFiles, QString()); QCOMPARE(downloads.size(), 0); - QCOMPARE(failedFiles, {"testname-testversion.jar"}); + QCOMPARE(failedFiles, { "testname-testversion.jar" }); } void test_legacy_url_local_override() { @@ -127,7 +123,7 @@ slots: QStringList jar, native, native32, native64; test.getApplicableFiles(r, jar, native, native32, native64, QFINDTESTDATA("testdata/Library")); - QCOMPARE(jar, {QFileInfo(QFINDTESTDATA("testdata/Library/codecwav-20101023.jar")).absoluteFilePath()}); + QCOMPARE(jar, { QFileInfo(QFINDTESTDATA("testdata/Library/codecwav-20101023.jar")).absoluteFilePath() }); QCOMPARE(native, {}); QCOMPARE(native32, {}); QCOMPARE(native64, {}); @@ -158,9 +154,9 @@ slots: { RuntimeContext r = dummyContext(); Library test("test.package:testname:testversion"); - test.m_nativeClassifiers["linux"]="linux-${arch}"; - test.m_nativeClassifiers["osx"]="osx-${arch}"; - test.m_nativeClassifiers["windows"]="windows-${arch}"; + test.m_nativeClassifiers["linux"] = "linux-${arch}"; + test.m_nativeClassifiers["osx"] = "osx-${arch}"; + test.m_nativeClassifiers["windows"] = "windows-${arch}"; QCOMPARE(test.isNative(), true); test.setRepositoryURL("file://foo/bar"); { @@ -212,7 +208,7 @@ slots: { RuntimeContext r = dummyContext(); Library test("test.package:testname:testversion"); - test.m_nativeClassifiers["linux"]="linux-${arch}"; + test.m_nativeClassifiers["linux"] = "linux-${arch}"; test.setHint("local"); QCOMPARE(test.isNative(), true); test.setRepositoryURL("file://foo/bar"); @@ -221,12 +217,13 @@ slots: test.getApplicableFiles(r, jar, native, native32, native64, QFINDTESTDATA("testdata/Library")); QCOMPARE(jar, {}); QCOMPARE(native, {}); - QCOMPARE(native32, {QFileInfo(QFINDTESTDATA("testdata/Library/testname-testversion-linux-32.jar")).absoluteFilePath()}); - QCOMPARE(native64, {QFileInfo(QFINDTESTDATA("testdata/Library") + "/testname-testversion-linux-64.jar").absoluteFilePath()}); + QCOMPARE(native32, { QFileInfo(QFINDTESTDATA("testdata/Library/testname-testversion-linux-32.jar")).absoluteFilePath() }); + QCOMPARE(native64, { QFileInfo(QFINDTESTDATA("testdata/Library") + "/testname-testversion-linux-64.jar").absoluteFilePath() }); QStringList failedFiles; auto dls = test.getDownloads(r, cache.get(), failedFiles, QFINDTESTDATA("testdata/Library")); QCOMPARE(dls.size(), 0); - QCOMPARE(failedFiles, {QFileInfo(QFINDTESTDATA("testdata/Library") + "/testname-testversion-linux-64.jar").absoluteFilePath()}); + QCOMPARE(failedFiles, + { QFileInfo(QFINDTESTDATA("testdata/Library") + "/testname-testversion-linux-64.jar").absoluteFilePath() }); } } void test_onenine() @@ -254,7 +251,7 @@ slots: { QStringList jar, native, native32, native64; test->getApplicableFiles(r, jar, native, native32, native64, QFINDTESTDATA("testdata/Library")); - QCOMPARE(jar, {QFileInfo(QFINDTESTDATA("testdata/Library/codecwav-20101023.jar")).absoluteFilePath()}); + QCOMPARE(jar, { QFileInfo(QFINDTESTDATA("testdata/Library/codecwav-20101023.jar")).absoluteFilePath() }); QCOMPARE(native, {}); QCOMPARE(native32, {}); QCOMPARE(native64, {}); @@ -275,7 +272,7 @@ slots: { QStringList jar, native, native32, native64; test->getApplicableFiles(r, jar, native, native32, native64, QFINDTESTDATA("testdata/Library")); - QCOMPARE(jar, {QFileInfo(QFINDTESTDATA("testdata/Library/codecwav-20101023.jar")).absoluteFilePath()}); + QCOMPARE(jar, { QFileInfo(QFINDTESTDATA("testdata/Library/codecwav-20101023.jar")).absoluteFilePath() }); QCOMPARE(native, {}); QCOMPARE(native32, {}); QCOMPARE(native64, {}); @@ -295,14 +292,16 @@ slots: QStringList jar, native, native32, native64; test->getApplicableFiles(r, jar, native, native32, native64, QString()); QCOMPARE(jar, QStringList()); - QCOMPARE(native, getStorage("org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar")); + QCOMPARE(native, + getStorage("org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar")); QCOMPARE(native32, {}); QCOMPARE(native64, {}); QStringList failedFiles; auto dls = test->getDownloads(r, cache.get(), failedFiles, QString()); QCOMPARE(dls.size(), 1); QCOMPARE(failedFiles, {}); - QCOMPARE(dls[0]->m_url, QUrl("https://libraries.minecraft.net/org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar")); + QCOMPARE(dls[0]->m_url, QUrl("https://libraries.minecraft.net/org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/" + "lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar")); } void test_onenine_native_arch() { @@ -318,10 +317,13 @@ slots: auto dls = test->getDownloads(r, cache.get(), failedFiles, QString()); QCOMPARE(dls.size(), 2); QCOMPARE(failedFiles, {}); - QCOMPARE(dls[0]->m_url, QUrl("https://libraries.minecraft.net/tv/twitch/twitch-platform/5.16/twitch-platform-5.16-natives-windows-32.jar")); - QCOMPARE(dls[1]->m_url, QUrl("https://libraries.minecraft.net/tv/twitch/twitch-platform/5.16/twitch-platform-5.16-natives-windows-64.jar")); + QCOMPARE(dls[0]->m_url, + QUrl("https://libraries.minecraft.net/tv/twitch/twitch-platform/5.16/twitch-platform-5.16-natives-windows-32.jar")); + QCOMPARE(dls[1]->m_url, + QUrl("https://libraries.minecraft.net/tv/twitch/twitch-platform/5.16/twitch-platform-5.16-natives-windows-64.jar")); } -private: + + private: std::unique_ptr cache; QString dataDir; }; diff --git a/tests/MojangVersionFormat_test.cpp b/tests/MojangVersionFormat_test.cpp index 219fbfa2..9ff5d78c 100644 --- a/tests/MojangVersionFormat_test.cpp +++ b/tests/MojangVersionFormat_test.cpp @@ -1,10 +1,9 @@ -#include #include +#include #include -class MojangVersionFormatTest : public QObject -{ +class MojangVersionFormatTest : public QObject { Q_OBJECT static QJsonDocument readJson(const QString path) @@ -15,7 +14,7 @@ class MojangVersionFormatTest : public QObject jsonFile.close(); return QJsonDocument::fromJson(data); } - static void writeJson(const char *file, QJsonDocument doc) + static void writeJson(const char* file, QJsonDocument doc) { QFile jsonFile(file); jsonFile.open(QIODevice::WriteOnly | QIODevice::Text); @@ -25,8 +24,7 @@ class MojangVersionFormatTest : public QObject jsonFile.close(); } -private -slots: + private slots: void test_Through_Simple() { QJsonDocument doc = readJson(QFINDTESTDATA("testdata/MojangVersionFormat/1.9-simple.json")); @@ -50,4 +48,3 @@ slots: QTEST_GUILESS_MAIN(MojangVersionFormatTest) #include "MojangVersionFormat_test.moc" - diff --git a/tests/Packwiz_test.cpp b/tests/Packwiz_test.cpp index 29289469..6f4aa5d1 100644 --- a/tests/Packwiz_test.cpp +++ b/tests/Packwiz_test.cpp @@ -26,9 +26,9 @@ class PackwizTest : public QObject { Q_OBJECT private slots: - // Files taken from https://github.com/packwiz/packwiz-example-pack - void loadFromFile_Modrinth() - { + // Files taken from https://github.com/packwiz/packwiz-example-pack + void loadFromFile_Modrinth() + { QString source = QFINDTESTDATA("testdata/Packwiz"); QDir index_dir(source); @@ -43,15 +43,17 @@ class PackwizTest : public QObject { QCOMPARE(metadata.name, "Borderless Mining"); QCOMPARE(metadata.filename, "borderless-mining-1.1.1+1.18.jar"); QCOMPARE(metadata.side, "client"); - + QCOMPARE(metadata.url, QUrl("https://cdn.modrinth.com/data/kYq5qkSL/versions/1.1.1+1.18/borderless-mining-1.1.1+1.18.jar")); QCOMPARE(metadata.hash_format, "sha512"); - QCOMPARE(metadata.hash, "c8fe6e15ddea32668822dddb26e1851e5f03834be4bcb2eff9c0da7fdc086a9b6cead78e31a44d3bc66335cba11144ee0337c6d5346f1ba63623064499b3188d"); + QCOMPARE(metadata.hash, + "c8fe6e15ddea32668822dddb26e1851e5f03834be4bcb2eff9c0da7fdc086a9b6cead78e31a44d3bc66335cba11144ee0337c6d5346f1ba6362306449" + "9b3188d"); QCOMPARE(metadata.provider, ModPlatform::ResourceProvider::MODRINTH); QCOMPARE(metadata.version(), "ug2qKTPR"); QCOMPARE(metadata.mod_id(), "kYq5qkSL"); - } + } void loadFromFile_Curseforge() { @@ -71,7 +73,7 @@ class PackwizTest : public QObject { QCOMPARE(metadata.name, "Screenshot to Clipboard (Fabric)"); QCOMPARE(metadata.filename, "screenshot-to-clipboard-1.0.7-fabric.jar"); QCOMPARE(metadata.side, "both"); - + QCOMPARE(metadata.url, QUrl("https://edge.forgecdn.net/files/3509/43/screenshot-to-clipboard-1.0.7-fabric.jar")); QCOMPARE(metadata.hash_format, "murmur2"); QCOMPARE(metadata.hash, "1781245820"); diff --git a/tests/ParseUtils_test.cpp b/tests/ParseUtils_test.cpp index 02208fdf..0f64a601 100644 --- a/tests/ParseUtils_test.cpp +++ b/tests/ParseUtils_test.cpp @@ -2,27 +2,16 @@ #include -class ParseUtilsTest : public QObject -{ +class ParseUtilsTest : public QObject { Q_OBJECT -private -slots: + private slots: void test_Through_data() { QTest::addColumn("timestamp"); - const char * timestamps[] = - { - "2016-02-29T13:49:54+01:00", - "2016-02-26T15:21:11+00:01", - "2016-02-24T15:52:36+01:13", - "2016-02-18T17:41:00+00:00", - "2016-02-17T15:23:19+00:00", - "2016-02-16T15:22:39+09:22", - "2016-02-10T15:06:41+00:00", - "2016-02-04T15:28:02-05:33" - }; - for(unsigned i = 0; i < (sizeof(timestamps) / sizeof(const char *)); i++) - { + const char* timestamps[] = { "2016-02-29T13:49:54+01:00", "2016-02-26T15:21:11+00:01", "2016-02-24T15:52:36+01:13", + "2016-02-18T17:41:00+00:00", "2016-02-17T15:23:19+00:00", "2016-02-16T15:22:39+09:22", + "2016-02-10T15:06:41+00:00", "2016-02-04T15:28:02-05:33" }; + for (unsigned i = 0; i < (sizeof(timestamps) / sizeof(const char*)); i++) { QTest::newRow(timestamps[i]) << QString(timestamps[i]); } } @@ -35,7 +24,6 @@ slots: QCOMPARE(time_serialized, timestamp); } - }; QTEST_GUILESS_MAIN(ParseUtilsTest) diff --git a/tests/ResourceFolderModel_test.cpp b/tests/ResourceFolderModel_test.cpp index 962d89f1..8012d4df 100644 --- a/tests/ResourceFolderModel_test.cpp +++ b/tests/ResourceFolderModel_test.cpp @@ -1,40 +1,40 @@ // SPDX-License-Identifier: GPL-3.0-only /* -* PolyMC - Minecraft Launcher -* Copyright (C) 2022 Sefa Eyeoglu -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, version 3. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* -* This file incorporates work covered by the following copyright and -* permission notice: -* -* Copyright 2013-2021 MultiMC Contributors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * PolyMC - Minecraft Launcher + * Copyright (C) 2022 Sefa Eyeoglu + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright 2013-2021 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -#include #include +#include #include #include "BaseInstance.h" @@ -61,12 +61,10 @@ \ disconnect(&model, nullptr, &loop, nullptr); -class ResourceFolderModelTest : public QObject -{ +class ResourceFolderModelTest : public QObject { Q_OBJECT -private -slots: + private slots: // test for GH-1178 - install a folder with files to a mod list void test_1178() { @@ -76,8 +74,7 @@ slots: // sanity check QVERIFY(!source.endsWith('/')); - auto verify = [](QString path) - { + auto verify = [](QString path) { QDir target_dir(FS::PathCombine(path, "test_folder")); QVERIFY(target_dir.entryList().contains("pack.mcmeta")); QVERIFY(target_dir.entryList().contains("assets")); @@ -161,23 +158,17 @@ slots: QCOMPARE(model.size(), 0); - { - EXEC_UPDATE_TASK(model.installResource(file_mod), QVERIFY) - } + { EXEC_UPDATE_TASK(model.installResource(file_mod), QVERIFY) } QCOMPARE(model.size(), 1); qDebug() << "Added first mod."; - { - EXEC_UPDATE_TASK(model.startWatching(), ) - } + { EXEC_UPDATE_TASK(model.startWatching(), ) } QCOMPARE(model.size(), 1); qDebug() << "Started watching the temp folder."; - - { - EXEC_UPDATE_TASK(model.installResource(folder_resource), QVERIFY) - } + + { EXEC_UPDATE_TASK(model.installResource(folder_resource), QVERIFY) } QCOMPARE(model.size(), 2); qDebug() << "Added second mod."; @@ -189,7 +180,7 @@ slots: QCOMPARE(model.size(), 1); qDebug() << "Removed first mod."; - QString mod_file_name {model.at(0).fileinfo().fileName()}; + QString mod_file_name{ model.at(0).fileinfo().fileName() }; QVERIFY(!mod_file_name.isEmpty()); { @@ -212,10 +203,7 @@ slots: QCOMPARE(model.size(), 0); - { - EXEC_UPDATE_TASK(model.installResource(folder_resource), QVERIFY) - } - { + { EXEC_UPDATE_TASK(model.installResource(folder_resource), QVERIFY) } { EXEC_UPDATE_TASK(model.installResource(file_mod), QVERIFY) } @@ -228,8 +216,8 @@ slots: auto& res_2 = model.at(0).type() == ResourceType::FOLDER ? model.at(0) : model.at(1); auto id_1 = res_1.internal_id(); auto id_2 = res_2.internal_id(); - bool initial_enabled_res_2 = res_2.enabled(); - bool initial_enabled_res_1 = res_1.enabled(); + bool initial_enabled_res_2 = res_2.enabled(); + bool initial_enabled_res_1 = res_1.enabled(); QVERIFY(res_1.type() != ResourceType::FOLDER && res_1.type() != ResourceType::UNKNOWN); qDebug() << "res_1 is of the correct type."; diff --git a/tests/ResourceModel_test.cpp b/tests/ResourceModel_test.cpp index 30353d3f..9626c64e 100644 --- a/tests/ResourceModel_test.cpp +++ b/tests/ResourceModel_test.cpp @@ -59,7 +59,8 @@ class DummyResourceModel : public ResourceModel { class ResourceModelTest : public QObject { Q_OBJECT private slots: - void test_abstract_item_model() { + void test_abstract_item_model() + { auto dummy = DummyResourceModel(); auto tester = QAbstractItemModelTester(&dummy); } diff --git a/tests/ResourcePackParse_test.cpp b/tests/ResourcePackParse_test.cpp index 7f2f86bf..1dcce324 100644 --- a/tests/ResourcePackParse_test.cpp +++ b/tests/ResourcePackParse_test.cpp @@ -27,18 +27,20 @@ class ResourcePackParseTest : public QObject { Q_OBJECT - private slots: + private slots: void test_parseZIP() { QString source = QFINDTESTDATA("testdata/ResourcePackParse"); QString zip_rp = FS::PathCombine(source, "test_resource_pack_idk.zip"); - ResourcePack pack { QFileInfo(zip_rp) }; + ResourcePack pack{ QFileInfo(zip_rp) }; bool valid = ResourcePackUtils::processZIP(pack, ResourcePackUtils::ProcessingLevel::BasicInfoOnly); QVERIFY(pack.packFormat() == 3); - QVERIFY(pack.description() == "um dois, feijão com arroz, três quatro, feijão no prato, cinco seis, café inglês, sete oito, comer biscoito, nove dez comer pastéis!!"); + QVERIFY(pack.description() == + "um dois, feijão com arroz, três quatro, feijão no prato, cinco seis, café inglês, sete oito, comer biscoito, nove dez " + "comer pastéis!!"); QVERIFY(valid == true); } @@ -47,7 +49,7 @@ class ResourcePackParseTest : public QObject { QString source = QFINDTESTDATA("testdata/ResourcePackParse"); QString folder_rp = FS::PathCombine(source, "test_folder"); - ResourcePack pack { QFileInfo(folder_rp) }; + ResourcePack pack{ QFileInfo(folder_rp) }; bool valid = ResourcePackUtils::processFolder(pack, ResourcePackUtils::ProcessingLevel::BasicInfoOnly); @@ -61,13 +63,13 @@ class ResourcePackParseTest : public QObject { QString source = QFINDTESTDATA("testdata/R