File indexing completed on 2025-01-05 04:55:03
0001 #include <QTest> 0002 #include <QDebug> 0003 #include <QTextDocument> 0004 #include <sink/test.h> 0005 0006 #include "partmodel.h" 0007 0008 class PartModelTest : public QObject 0009 { 0010 Q_OBJECT 0011 private slots: 0012 0013 void initTestCase() 0014 { 0015 Sink::Test::initTest(); 0016 } 0017 0018 void testTrim() 0019 { 0020 auto result = PartModel::trim(QLatin1String("<p>This is some funky test.</p>\n<p>-- <br>\nChristian Mollekopf<br>\nSenior Software")); 0021 QCOMPARE(result.second, true); 0022 QCOMPARE(result.first, QLatin1String("<p>This is some funky test.</p>\n")); 0023 } 0024 0025 void testTrimFromPlain() 0026 { 0027 //Qt::convertFromPlainText inserts non-breaking spaces 0028 auto result = PartModel::trim(Qt::convertFromPlainText(QLatin1String("This is some funky text.\n\n-- \nChristian Mollekopf\nSenior Software"))); 0029 QCOMPARE(result.second, true); 0030 //\u00A0 is a on-breaking space 0031 const auto expected = QString("<p>This is some funky text.</p>\n").replace(QChar(' '), QChar(0x00a0)); 0032 QCOMPARE(result.first, expected); 0033 } 0034 }; 0035 0036 QTEST_MAIN(PartModelTest) 0037 #include "partmodeltest.moc"