File indexing completed on 2024-05-12 17:09:49

0001 /*
0002     SPDX-FileCopyrightText: 2022 Popov Eugene <popov895@ukr.net>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #include "../utils.h"
0008 
0009 #include <QObject>
0010 #include <QtTest>
0011 
0012 class UtilsTest : public QObject
0013 {
0014     Q_OBJECT
0015 
0016 private Q_SLOTS:
0017     void testSimplifiedText();
0018 };
0019 
0020 void UtilsTest::testSimplifiedText()
0021 {
0022     const QString text = QStringLiteral("   Some    text\n   to\t\ttest    ");
0023 
0024     QCOMPARE(Utils::simplifiedText(text, 1000), QStringLiteral("Some text to test"));
0025     QCOMPARE(Utils::simplifiedText(text, 17), QStringLiteral("Some text to test"));
0026     QCOMPARE(Utils::simplifiedText(text, 10), QStringLiteral("Some text"));
0027     QCOMPARE(Utils::simplifiedText(text, 0), QStringLiteral(""));
0028 }
0029 
0030 QTEST_MAIN(UtilsTest)
0031 #include "utilstest.moc"