File indexing completed on 2025-02-16 04:49:25

0001 /*
0002    SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "markdownutiltest.h"
0008 #include "markdownutil.h"
0009 #include <QTest>
0010 QTEST_GUILESS_MAIN(MarkdownUtilTest)
0011 
0012 MarkdownUtilTest::MarkdownUtilTest(QObject *parent)
0013     : QObject(parent)
0014 {
0015 }
0016 
0017 void MarkdownUtilTest::shouldConvert()
0018 {
0019     QFETCH(QString, input);
0020     QFETCH(QStringList, results);
0021     QCOMPARE(MarkdownUtil::imagePaths(input), results);
0022 }
0023 
0024 void MarkdownUtilTest::shouldConvert_data()
0025 {
0026     QTest::addColumn<QString>("input");
0027     QTest::addColumn<QStringList>("results");
0028     QTest::newRow("empty") << QString() << QStringList();
0029     QTest::newRow("any") << QStringLiteral("![foo]") << QStringList();
0030     QTest::newRow("any-2") << QStringLiteral("![foo]() qsdqsdq") << (QStringList() << QString());
0031     QStringList result;
0032     result << QStringLiteral("image.png");
0033     QTest::newRow("one item") << QStringLiteral("![foo](image.png \"ss\") bla") << result;
0034     QTest::newRow("one item-2") << QStringLiteral("![foo](image.png) bla") << result;
0035     result.clear();
0036     result << QStringLiteral("image.png");
0037     result << QStringLiteral("image2.png");
0038     QTest::newRow("two item") << QStringLiteral("![foo](image.png \"ss\") bla ![bli](image2.png \"sdsd\")") << result;
0039     QTest::newRow("two item-2") << QStringLiteral("![foo](image.png) bla ![bli](image2.png)") << result;
0040     QTest::newRow("two item-3") << QStringLiteral("![foo](image.png  \"blz\") bla ![bli](image2.png)") << result;
0041     QTest::newRow("two item-3") << QStringLiteral("![foo](image.png  \"blz\") bla ![bli](image2.png \"ez\" )") << result;
0042 
0043     // With size
0044     QTest::newRow("two item-3") << QStringLiteral("![foo](image.png =50x50 \"blz\") bla ![bli](image2.png \"ez\" )") << result;
0045     QTest::newRow("two item-3") << QStringLiteral("![foo](image.png =50x50 \"blz\") bla ![bli](image2.png =100x100 \"ez\" ) sdfsdf ") << result;
0046 }
0047 
0048 #include "moc_markdownutiltest.cpp"