#include #include class ModrinthUrlTest : public QObject { Q_OBJECT private slots: void parseModpackLink_data() { QTest::addColumn("link"); QTest::addColumn("slug"); QTest::newRow("official") << "modrinth://modpack/fabulously-optimized" << "fabulously-optimized"; QTest::newRow("trailing slash") << "modrinth://modpack/fabulously-optimized/" << "fabulously-optimized"; QTest::newRow("case insensitive host") << "modrinth://MODPACK/fo" << "fo"; } void parseModpackLink() { QFETCH(QString, link); QFETCH(QString, slug); auto parsed = Modrinth::parseModpackLink(QUrl(link)); QVERIFY(parsed.has_value()); QCOMPARE(parsed->slug, slug); } void rejectInvalidLinks_data() { QTest::addColumn("link"); QTest::newRow("wrong scheme") << "https://modrinth.com/modpack/fabulously-optimized"; QTest::newRow("missing slug") << "modrinth://modpack/"; QTest::newRow("unsupported resource") << "modrinth://mod/sodium"; QTest::newRow("extra path") << "modrinth://modpack/fabulously-optimized/version/latest"; } void rejectInvalidLinks() { QFETCH(QString, link); QVERIFY(!Modrinth::parseModpackLink(QUrl(link)).has_value()); } }; QTEST_GUILESS_MAIN(ModrinthUrlTest) #include "ModrinthUrl_test.moc"