File indexing completed on 2024-03-24 15:24:28

0001 /*
0002     Copyright 2015-2016 Harald Sitter <sitter@kde.org>
0003 
0004     This library is free software; you can redistribute it and/or
0005     modify it under the terms of the GNU Lesser General Public
0006     License as published by the Free Software Foundation; either
0007     version 2.1 of the License, or (at your option) version 3, or any
0008     later version accepted by the membership of KDE e.V. (or its
0009     successor approved by the membership of KDE e.V.), which shall
0010     act as a proxy defined in Section 6 of version 3 of the license.
0011 
0012     This library is distributed in the hope that it will be useful,
0013     but WITHOUT ANY WARRANTY; without even the implied warranty of
0014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015     Lesser General Public License for more details.
0016 
0017     You should have received a copy of the GNU Lesser General Public
0018     License along with this library. If not, see <http://www.gnu.org/licenses/>.
0019 */
0020 
0021 #include <QDirIterator>
0022 #include <QObject>
0023 #include <QTest>
0024 
0025 #include "testhelpers.h"
0026 
0027 class NewlineTest : public QObject
0028 {
0029     Q_OBJECT
0030 
0031 private Q_SLOTS:
0032     // Files that contain a newline in their name
0033     void test_whitespace()
0034     {
0035         QList<QString> brokenFiles;
0036         QDirIterator it(PROJECT_SOURCE_DIR, QDir::Files | QDir::System, QDirIterator::Subdirectories);
0037         while (it.hasNext()) {
0038             it.next();
0039             if (it.fileName().simplified() != it.fileName()) {
0040                 brokenFiles << it.filePath();
0041             }
0042         }
0043         failListContent(brokenFiles, QStringLiteral("Found file with bad characters (http://doc.qt.io/qt-5/qstring.html#simplified):\n"));
0044     }
0045 };
0046 
0047 QTEST_GUILESS_MAIN(NewlineTest)
0048 
0049 #include "newlinetest.moc"