From 3a0e4546c2a1914c18f71622727997a2a7518ad2 Mon Sep 17 00:00:00 2001 From: Rachel Powers <508861+Ryex@users.noreply.github.com> Date: Thu, 9 Feb 2023 22:07:07 -0800 Subject: [PATCH] fix: windows test compat fix: compiler warning on int qint32 compare Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com> --- launcher/FileSystem.cpp | 5 ++--- tests/FileSystem_test.cpp | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 57b796ad..c3a0c273 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -433,7 +433,7 @@ void create_link::runPrivlaged(const QString& offset) in >> numResults; qDebug() << "numResults" << numResults; - for(int i = 0; i < numResults; i++) { + for(quint32 i = 0; i < numResults; i++) { FS::LinkResult result; in >> result.src; in >> result.dst; @@ -484,7 +484,6 @@ void ExternalLinkFileProcess::runLinkFile() { #if defined Q_OS_WIN32 SHELLEXECUTEINFO ShExecInfo; - HRESULT hr; fileLinkExe = fileLinkExe + ".exe"; @@ -620,7 +619,7 @@ QString PathTruncate(const QString& path, int depth) if (parts.startsWith(".") && !path.startsWith(".")) { parts.removeFirst(); } - if (path.startsWith(QDir::separator())) { + if (QDir::toNativeSeparators(path).startsWith(QDir::separator())) { parts.prepend(""); } diff --git a/tests/FileSystem_test.cpp b/tests/FileSystem_test.cpp index ab78c150..169f0669 100644 --- a/tests/FileSystem_test.cpp +++ b/tests/FileSystem_test.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -769,14 +770,17 @@ slots: } void test_path_trunc() { - QCOMPARE(FS::PathTruncate("", 0), ""); - QCOMPARE(FS::PathTruncate("foo.txt", 0), ""); - QCOMPARE(FS::PathTruncate("foo.txt", 1), ""); - QCOMPARE(FS::PathTruncate("./bar/foo.txt", 0), "./bar"); - QCOMPARE(FS::PathTruncate("./bar/foo.txt", 1), "./bar"); - QCOMPARE(FS::PathTruncate("/bar/foo.txt", 1), "/bar"); - QCOMPARE(FS::PathTruncate("bar/foo.txt", 1), "bar"); - QCOMPARE(FS::PathTruncate("baz/bar/foo.txt", 2), "baz/bar"); + QCOMPARE(FS::PathTruncate("", 0), QDir::toNativeSeparators("")); + QCOMPARE(FS::PathTruncate("foo.txt", 0), QDir::toNativeSeparators("")); + QCOMPARE(FS::PathTruncate("foo.txt", 1), QDir::toNativeSeparators("")); + QCOMPARE(FS::PathTruncate("./bar/foo.txt", 0), QDir::toNativeSeparators("./bar")); + QCOMPARE(FS::PathTruncate("./bar/foo.txt", 1), QDir::toNativeSeparators("./bar")); + QCOMPARE(FS::PathTruncate("/bar/foo.txt", 1), QDir::toNativeSeparators("/bar")); + QCOMPARE(FS::PathTruncate("bar/foo.txt", 1), QDir::toNativeSeparators("bar")); + QCOMPARE(FS::PathTruncate("baz/bar/foo.txt", 2), QDir::toNativeSeparators("baz/bar")); +#if defined(Q_OS_WIN) + QCOMPARE(FS::PathTruncate("C:\\bar\\foo.txt", 1), QDir::toNativeSeparators("C:\\bar")); +#endif } };