| 1 |
// Copyright (C) 2024 The Qt Company Ltd. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
#include <QtTest/QTest> |
| 4 |
#include <QtCore/qstring.h> |
| 5 |
|
| 6 |
using namespace Qt::StringLiterals; |
| 7 |
|
| 8 |
class tst_qsbdepfiles : public QObject |
| 9 |
{ |
| 10 |
Q_OBJECT |
| 11 |
private: |
| 12 |
void init(); |
| 13 |
private slots: |
| 14 |
void Depfiles_data(); |
| 15 |
void Depfiles(); |
| 16 |
}; |
| 17 |
|
| 18 |
void tst_qsbdepfiles::Depfiles_data() |
| 19 |
{ |
| 20 |
QTest::addColumn<QLatin1String>("filename"); |
| 21 |
|
| 22 |
QTest::newRow("WithoutInclude") << "tst.frag.qsb.d"_L1; |
| 23 |
QTest::newRow("WithInclude") << "tstinclude.frag.qsb.d"_L1; |
| 24 |
QTest::newRow("WithWhitespaces") << "tstincludewhitespaces.frag.qsb.d"_L1; |
| 25 |
QTest::newRow("WithRelativeInclude") << "tstincluderelative.frag.qsb.d"_L1; |
| 26 |
QTest::newRow("WithComment") << "tstincludecomment.frag.qsb.d"_L1; |
| 27 |
} |
| 28 |
|
| 29 |
void tst_qsbdepfiles::Depfiles() |
| 30 |
{ |
| 31 |
QFETCH(const QLatin1String, filename); |
| 32 |
QString resultFilePath = QFINDTESTDATA(QString(".qsb/shaders/%1").arg(filename)); |
| 33 |
QString expectedFilePath = QString(":/data/%1").arg(filename); |
| 34 |
|
| 35 |
QFile resultFile(resultFilePath); |
| 36 |
QFile expectedFile(expectedFilePath); |
| 37 |
|
| 38 |
QVERIFY(resultFile.open(QFile::ReadOnly)); |
| 39 |
QVERIFY(expectedFile.open(QFile::ReadOnly)); |
| 40 |
|
| 41 |
// We chop the one byte from expectedFile because of CMake issue. |
| 42 |
// See https://gitlab.kitware.com/cmake/cmake/-/issues/25164 |
| 43 |
QVERIFY(resultFile.readAll() == expectedFile.readAll().chopped(1)); |
| 44 |
} |
| 45 |
|
| 46 |
QTEST_MAIN(tst_qsbdepfiles) |
| 47 |
|
| 48 |
#include "tst_qsbdepfiles.moc" |