Use Qt built-in function for comparing values

PR #22389.
This commit is contained in:
Chocobo1 2025-03-10 03:19:31 +08:00 committed by GitHub
parent b74b334e34
commit 882da47609
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 31 additions and 31 deletions

View File

@ -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
}

View File

@ -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);

View File

@ -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));
}
};