File indexing completed on 2024-12-15 04:51:46
0001 /* 0002 SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "noteutilstest.h" 0008 #include "noteutils.h" 0009 #include <QTest> 0010 QTEST_GUILESS_MAIN(NoteUtilsTest) 0011 0012 NoteUtilsTest::NoteUtilsTest(QObject *parent) 0013 : QObject(parent) 0014 { 0015 } 0016 0017 void NoteUtilsTest::testExtractNoteText_data() 0018 { 0019 QTest::addColumn<QString>("titleAddons"); 0020 QTest::addColumn<QString>("noteText"); 0021 QTest::addColumn<QString>("resultNoteTitle"); 0022 QTest::addColumn<QString>("resultNoteText"); 0023 QTest::newRow("empty") << QString() << QString() << QString() << QString(); 0024 QTest::newRow("test1") << QStringLiteral("foo") << QStringLiteral("bla\r\nfoo") << QStringLiteral("blafoo") << QStringLiteral("foo"); 0025 QTest::newRow("test2") << QString() << QStringLiteral("bla\r\nfoo") << QStringLiteral("bla") << QStringLiteral("foo"); 0026 QTest::newRow("test3") << QString() << QStringLiteral("blafoo") << QStringLiteral("blafoo") << QStringLiteral("blafoo"); 0027 } 0028 0029 void NoteUtilsTest::testExtractNoteText() 0030 { 0031 QFETCH(QString, titleAddons); 0032 QFETCH(QString, noteText); 0033 QFETCH(QString, resultNoteTitle); 0034 QFETCH(QString, resultNoteText); 0035 0036 NoteShared::NoteUtils noteUtils; 0037 NoteShared::NoteUtils::NoteText result = noteUtils.extractNoteText(noteText, titleAddons); 0038 QCOMPARE(result.noteText, resultNoteText); 0039 QCOMPARE(result.noteTitle, resultNoteTitle); 0040 } 0041 0042 #include "moc_noteutilstest.cpp"