File indexing completed on 2024-12-22 04:46:01

0001 /*
0002   SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
0003 
0004   SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "needupdateversionutilstest.h"
0008 #include "needupdateversion/needupdateversionutils.h"
0009 #include <QStandardPaths>
0010 #include <QTest>
0011 QTEST_GUILESS_MAIN(NeedUpdateVersionUtilsTest)
0012 NeedUpdateVersionUtilsTest::NeedUpdateVersionUtilsTest(QObject *parent)
0013     : QObject{parent}
0014 {
0015     QStandardPaths::setTestModeEnabled(true);
0016     qRegisterMetaType<NeedUpdateVersionUtils::ObsoleteVersion>();
0017 }
0018 
0019 void NeedUpdateVersionUtilsTest::shouldReturnObsoleteVersionStatus()
0020 {
0021     QFETCH(QString, str);
0022     QFETCH(NeedUpdateVersionUtils::ObsoleteVersion, status);
0023     QCOMPARE(NeedUpdateVersionUtils::obsoleteVersionStatus(str, QDate(2023, 12, 12)), status);
0024 }
0025 
0026 void NeedUpdateVersionUtilsTest::shouldReturnObsoleteVersionStatus_data()
0027 {
0028     QTest::addColumn<QString>("str");
0029     QTest::addColumn<NeedUpdateVersionUtils::ObsoleteVersion>("status");
0030     QTest::addRow("empty") << QString() << NeedUpdateVersionUtils::ObsoleteVersion::Unknown;
0031     QTest::addRow("test1") << QStringLiteral("foo (23.08.2)") << NeedUpdateVersionUtils::ObsoleteVersion::NotObsoleteYet;
0032     QTest::addRow("test2") << QStringLiteral("(23.08.2)") << NeedUpdateVersionUtils::ObsoleteVersion::NotObsoleteYet;
0033     QTest::addRow("test3") << QStringLiteral("(20.08.2)") << NeedUpdateVersionUtils::ObsoleteVersion::OlderThan12Months;
0034     QTest::addRow("test4") << QStringLiteral("(23.06.2)") << NeedUpdateVersionUtils::ObsoleteVersion::OlderThan6Months;
0035 }
0036 
0037 #include "moc_needupdateversionutilstest.cpp"