mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
49 lines
1.4 KiB
C++
49 lines
1.4 KiB
C++
#include <QTest>
|
|
|
|
#include <modplatform/modrinth/ModrinthUrl.h>
|
|
|
|
class ModrinthUrlTest : public QObject {
|
|
Q_OBJECT
|
|
|
|
private slots:
|
|
void parseModpackLink_data()
|
|
{
|
|
QTest::addColumn<QString>("link");
|
|
QTest::addColumn<QString>("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<QString>("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"
|