From 882da47609b3b85ef6303e9fc8749649ada7490f Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 10 Mar 2025 03:19:31 +0800 Subject: [PATCH] Use Qt built-in function for comparing values PR #22389. --- test/testpath.cpp | 30 +++++++++++++++--------------- test/testutilsgzip.cpp | 2 +- test/testutilsversion.cpp | 30 +++++++++++++++--------------- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/test/testpath.cpp b/test/testpath.cpp index 6449a8071..5bbfe4bab 100644 --- a/test/testpath.cpp +++ b/test/testpath.cpp @@ -44,25 +44,25 @@ public: private slots: void testConstructors() const { - QVERIFY(Path(u""_s) == Path(std::string(""))); - QVERIFY(Path(u"abc"_s) == Path(std::string("abc"))); - QVERIFY(Path(u"/abc"_s) == Path(std::string("/abc"))); - QVERIFY(Path(uR"(\abc)"_s) == Path(std::string(R"(\abc)"))); + QCOMPARE_EQ(Path(u""_s), Path(std::string(""))); + QCOMPARE_EQ(Path(u"abc"_s), Path(std::string("abc"))); + QCOMPARE_EQ(Path(u"/abc"_s), Path(std::string("/abc"))); + QCOMPARE_EQ(Path(uR"(\abc)"_s), Path(std::string(R"(\abc)"))); #ifdef Q_OS_WIN - QVERIFY(Path(uR"(c:)"_s) == Path(std::string(R"(c:)"))); - QVERIFY(Path(uR"(c:/)"_s) == Path(std::string(R"(c:/)"))); - QVERIFY(Path(uR"(c:/)"_s) == Path(std::string(R"(c:\)"))); - QVERIFY(Path(uR"(c:\)"_s) == Path(std::string(R"(c:/)"))); - QVERIFY(Path(uR"(c:\)"_s) == Path(std::string(R"(c:\)"))); + QCOMPARE_EQ(Path(uR"(c:)"_s), Path(std::string(R"(c:)"))); + QCOMPARE_EQ(Path(uR"(c:/)"_s), Path(std::string(R"(c:/)"))); + QCOMPARE_EQ(Path(uR"(c:/)"_s), Path(std::string(R"(c:\)"))); + QCOMPARE_EQ(Path(uR"(c:\)"_s), Path(std::string(R"(c:/)"))); + QCOMPARE_EQ(Path(uR"(c:\)"_s), Path(std::string(R"(c:\)"))); - QVERIFY(Path(uR"(\\?\C:)"_s) == Path(std::string(R"(\\?\C:)"))); - QVERIFY(Path(uR"(\\?\C:/)"_s) == Path(std::string(R"(\\?\C:/)"))); - QVERIFY(Path(uR"(\\?\C:/)"_s) == Path(std::string(R"(\\?\C:\)"))); - QVERIFY(Path(uR"(\\?\C:\)"_s) == Path(std::string(R"(\\?\C:/)"))); - QVERIFY(Path(uR"(\\?\C:\)"_s) == Path(std::string(R"(\\?\C:\)"))); + QCOMPARE_EQ(Path(uR"(\\?\C:)"_s), Path(std::string(R"(\\?\C:)"))); + QCOMPARE_EQ(Path(uR"(\\?\C:/)"_s), Path(std::string(R"(\\?\C:/)"))); + QCOMPARE_EQ(Path(uR"(\\?\C:/)"_s), Path(std::string(R"(\\?\C:\)"))); + QCOMPARE_EQ(Path(uR"(\\?\C:\)"_s), Path(std::string(R"(\\?\C:/)"))); + QCOMPARE_EQ(Path(uR"(\\?\C:\)"_s), Path(std::string(R"(\\?\C:\)"))); - QVERIFY(Path(uR"(\\?\C:\abc)"_s) == Path(std::string(R"(\\?\C:\abc)"))); + QCOMPARE_EQ(Path(uR"(\\?\C:\abc)"_s), Path(std::string(R"(\\?\C:\abc)"))); #endif } diff --git a/test/testutilsgzip.cpp b/test/testutilsgzip.cpp index 637e71922..3e60c1caf 100644 --- a/test/testutilsgzip.cpp +++ b/test/testutilsgzip.cpp @@ -58,7 +58,7 @@ private slots: bool ok = false; const QByteArray compressedData = Utils::Gzip::compress(data, 6, &ok); QVERIFY(ok); - QVERIFY(compressedData != data); + QCOMPARE_NE(compressedData, data); ok = false; const QByteArray decompressedData = Utils::Gzip::decompress(compressedData, &ok); diff --git a/test/testutilsversion.cpp b/test/testutilsversion.cpp index fcabedca6..733fadac8 100644 --- a/test/testutilsversion.cpp +++ b/test/testutilsversion.cpp @@ -169,26 +169,26 @@ private slots: { using ThreeDigits = Utils::Version<3>; - QVERIFY(ThreeDigits() == ThreeDigits()); + QCOMPARE_EQ(ThreeDigits(), ThreeDigits()); QVERIFY(!(ThreeDigits() != ThreeDigits())); - QVERIFY(ThreeDigits() <= ThreeDigits()); - QVERIFY(ThreeDigits() >= ThreeDigits()); + QCOMPARE_LE(ThreeDigits(), ThreeDigits()); + QCOMPARE_GE(ThreeDigits(), ThreeDigits()); - QVERIFY(ThreeDigits() != ThreeDigits(1, 2, 3)); - QVERIFY(ThreeDigits() < ThreeDigits(1, 2, 3)); - QVERIFY(ThreeDigits() <= ThreeDigits(1, 2, 3)); + QCOMPARE_NE(ThreeDigits(), ThreeDigits(1, 2, 3)); + QCOMPARE_LT(ThreeDigits(), ThreeDigits(1, 2, 3)); + QCOMPARE_LE(ThreeDigits(), ThreeDigits(1, 2, 3)); - QVERIFY(ThreeDigits(1, 2, 3) != ThreeDigits()); - QVERIFY(ThreeDigits(1, 2, 3) > ThreeDigits()); - QVERIFY(ThreeDigits(1, 2, 3) >= ThreeDigits()); + QCOMPARE_NE(ThreeDigits(1, 2, 3), ThreeDigits()); + QCOMPARE_GT(ThreeDigits(1, 2, 3), ThreeDigits()); + QCOMPARE_GE(ThreeDigits(1, 2, 3), ThreeDigits()); - QVERIFY(ThreeDigits(1, 3, 3) != ThreeDigits(2, 2, 3)); - QVERIFY(ThreeDigits(1, 3, 3) < ThreeDigits(2, 2, 3)); - QVERIFY(ThreeDigits(1, 3, 3) <= ThreeDigits(2, 2, 3)); + QCOMPARE_NE(ThreeDigits(1, 3, 3), ThreeDigits(2, 2, 3)); + QCOMPARE_LT(ThreeDigits(1, 3, 3), ThreeDigits(2, 2, 3)); + QCOMPARE_LE(ThreeDigits(1, 3, 3), ThreeDigits(2, 2, 3)); - QVERIFY(ThreeDigits(1, 2, 3) != ThreeDigits(1, 2, 4)); - QVERIFY(ThreeDigits(1, 2, 3) < ThreeDigits(1, 2, 4)); - QVERIFY(ThreeDigits(1, 2, 3) <= ThreeDigits(1, 2, 4)); + QCOMPARE_NE(ThreeDigits(1, 2, 3), ThreeDigits(1, 2, 4)); + QCOMPARE_LT(ThreeDigits(1, 2, 3), ThreeDigits(1, 2, 4)); + QCOMPARE_LE(ThreeDigits(1, 2, 3), ThreeDigits(1, 2, 4)); } };