aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/data/tst_qmlcppcodegen_verify.cpp
blob: 02629ad7f64bd7d3ab966acb21b0d86a4153ebdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (C) 2023 The Qt Company Ltd.

#include <QtTest>
#include <QtCore/qobject.h>
#include <QtCore/qdir.h>
#include <QtCore/qfile.h>
#include <QtCore/qstring.h>
#include <QtCore/qbytearray.h>

class tst_QmlCppCodegenVerify : public QObject
{
    Q_OBJECT
private slots:
    void verifyGeneratedSources_data();
    void verifyGeneratedSources();
};

void tst_QmlCppCodegenVerify::verifyGeneratedSources_data()
{
    QTest::addColumn<QString>("file");

    QDir a(":/a");
    const QStringList entries =  a.entryList(QDir::Files);
    for (const QString &entry : entries)
        QTest::addRow("%s", entry.toUtf8().constData()) << entry;
}

void tst_QmlCppCodegenVerify::verifyGeneratedSources()
{
    QFETCH(QString, file);
    QFile a(":/a/" + file);
    QFile b(":/b/" + file.replace("codegen_test_module", "codegen_test_module_verify"));

    QVERIFY(a.open(QIODevice::ReadOnly));
    QVERIFY(b.open(QIODevice::ReadOnly));

    const QByteArray aData = a.readAll();
    const QByteArray bData = b.readAll()
                                     .replace("verify/TestTypes", "TestTypes")
                                     .replace("verify_TestTypes", "TestTypes");

    QCOMPARE(aData, bData);
}

QTEST_MAIN(tst_QmlCppCodegenVerify)

#include "tst_qmlcppcodegen_verify.moc"