File indexing completed on 2024-05-19 05:21:42
0001 /* 0002 SPDX-FileCopyrightText: 2011 Torgny Nyblom <nyblom@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #include "textutilstest.h" 0008 0009 #include "textutils.h" 0010 0011 #include "qtest.h" 0012 0013 using namespace KPIMTextEdit; 0014 0015 QTEST_GUILESS_MAIN(TextUtilsTest) 0016 #define lineLength 40 0017 0018 void TextUtilsTest::test_flowText() 0019 { 0020 QFETCH(QString, originalString); 0021 QFETCH(QString, quotedString); 0022 QFETCH(QString, indent); 0023 0024 QCOMPARE(TextUtils::flowText(originalString, indent, lineLength), quotedString); 0025 } 0026 0027 TextUtilsTest::TextUtilsTest(QObject *parent) 0028 : QObject(parent) 0029 { 0030 } 0031 0032 void TextUtilsTest::test_flowText_data() 0033 { 0034 QTest::addColumn<QString>("originalString"); 0035 QTest::addColumn<QString>("quotedString"); 0036 QTest::addColumn<QString>("indent"); 0037 0038 QTest::newRow("Empty string ") << "" 0039 << "" 0040 << ""; 0041 0042 QTest::newRow("Indent == Maxlenght ") << "A line" 0043 << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>A\n" 0044 ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" 0045 ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>l\n" 0046 ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>i\n" 0047 ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>n\n" 0048 ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>e" 0049 << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"; 0050 // 40 0051 // ↓ 0052 QTest::newRow("One non-wrapping line") << "A long line that is right on the border." 0053 << "A long line that is right on the border." 0054 << ""; 0055 QTest::newRow("Two non-wrapping lines") << "A long line that is right on the border.\n" 0056 "A long line that is right on the border." 0057 << "A long line that is right on the border.\n" 0058 "A long line that is right on the border." 0059 << ""; 0060 // 40 0061 // ↓ 0062 QTest::newRow("Two wrapping lines") << "A long line that is right over the border" 0063 << "A long line that is right over the\n" 0064 "border" 0065 << ""; 0066 } 0067 0068 #include "moc_textutilstest.cpp"