File: needupdateparsehtmlutiltest.cpp

package info (click to toggle)
ktextaddons 1.9.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,856 kB
  • sloc: cpp: 62,045; ansic: 6,520; xml: 2,630; sh: 11; makefile: 7
file content (43 lines) | stat: -rw-r--r-- 1,178 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
  SPDX-FileCopyrightText: 2025-2026 Laurent Montel <montel@kde.org>

  SPDX-License-Identifier: GPL-2.0-or-later
*/

#include "needupdateparsehtmlutiltest.h"
#include "needupdateversion/needupdateparsehtmlutil.h"
#include <QTest>

QTEST_MAIN(NeedUpdateParseHtmlUtilTest)

NeedUpdateParseHtmlUtilTest::NeedUpdateParseHtmlUtilTest(QObject *parent)
    : QObject{parent}
{
}

void NeedUpdateParseHtmlUtilTest::shouldExtraDate()
{
    QFETCH(QString, name);
    QFETCH(QString, dateStr);

    const QString originalJsonFile = QLatin1StringView(TEXTADDONSWIDGET_DATA_NEEDUPDATEDIR) + QStringLiteral("/") + name + QStringLiteral(".html");

    QFile f(originalJsonFile);
    [&]() {
        QVERIFY(f.open(QIODevice::ReadOnly));
    }();
    const auto content = f.readAll();
    f.close();

    QCOMPARE(TextAddonsWidgets::NeedUpdateParseHtmlUtil::extractDate(QString::fromUtf8(content)), dateStr);
}

void NeedUpdateParseHtmlUtilTest::shouldExtraDate_data()
{
    QTest::addColumn<QString>("name");
    QTest::addColumn<QString>("dateStr");

    QTest::addRow("test1") << QStringLiteral("test1") << QStringLiteral("2024-12-28");
}

#include "moc_needupdateparsehtmlutiltest.cpp"