// SPDX-FileCopyrightText: 2024 Joshua Goins // SPDX-License-Identifier: GPL-3.0-or-later #include #include "utils/texthandler.h" class TextHandlerTest : public QObject { Q_OBJECT private Q_SLOTS: void getNextPrevLinks_data() { using URL = std::optional; QTest::addColumn("header"); QTest::addColumn("next"); QTest::addColumn("prev"); QTest::addRow("next/prev") << QStringLiteral("; rel=\"next\", ; rel=\"prev\"") << URL(QStringLiteral("https://kde.org/")) << URL(QStringLiteral("https://gnome.org/")); QTest::addRow("next") << QStringLiteral("; rel=\"next\", <>; rel=\"prev\"") << URL(QStringLiteral("https://kde.org/")) << URL(std::nullopt); QTest::addRow("prev") << QStringLiteral("<>; rel=\"next\", ; rel=\"prev\"") << URL(std::nullopt) << URL(QStringLiteral("https://gnome.org/")); } void getNextPrevLinks() { QFETCH(QString, header); QFETCH(std::optional, next); QFETCH(std::optional, prev); QCOMPARE(TextHandler::getNextLink(header), next); QCOMPARE(TextHandler::getPrevLink(header), prev); } }; QTEST_MAIN(TextHandlerTest) #include "texthandlertest.moc"