aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor/tests/testdroptypeentries.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken6/ApiExtractor/tests/testdroptypeentries.cpp')
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testdroptypeentries.cpp142
1 files changed, 61 insertions, 81 deletions
diff --git a/sources/shiboken6/ApiExtractor/tests/testdroptypeentries.cpp b/sources/shiboken6/ApiExtractor/tests/testdroptypeentries.cpp
index 303532b65..16f50e69d 100644
--- a/sources/shiboken6/ApiExtractor/tests/testdroptypeentries.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testdroptypeentries.cpp
@@ -1,40 +1,20 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of Qt for Python.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "testdroptypeentries.h"
-#include <QtTest/QTest>
#include "testutil.h"
#include <abstractmetaenum.h>
#include <abstractmetalang.h>
#include <typesystem.h>
#include <conditionalstreamreader.h>
-static const char* cppCode ="\
+#include <qtcompat.h>
+
+#include <QtTest/QTest>
+
+using namespace Qt::StringLiterals;
+
+static const char cppCode[] = "\
struct ValueA {};\n\
struct ValueB {};\n\
struct ObjectA {};\n\
@@ -49,7 +29,7 @@ static const char* cppCode ="\
void funcA();\n\
void funcB();\n";
-static const char* xmlCode = "\
+static const char xmlCode[] = "\
<typesystem package='Foo'>\n\
<value-type name='ValueA'/>\n\
<value-type name='ValueB'/>\n\
@@ -68,61 +48,61 @@ static const char* xmlCode = "\
void TestDropTypeEntries::testDropEntries()
{
- const QStringList droppedEntries{QLatin1String("Foo.ValueB"),
- QLatin1String("ObjectB"), // Check whether module can be omitted
- QLatin1String("Foo.NamespaceA.InnerClassA"),
- QLatin1String("Foo.NamespaceB"), QLatin1String("Foo.EnumB"),
- QLatin1String("Foo.funcB()"),
- QLatin1String("Foo.NamespaceA.InnerNamespaceA")};
+ const QStringList droppedEntries{u"Foo.ValueB"_s,
+ u"ObjectB"_s, // Check whether module can be omitted
+ u"Foo.NamespaceA.InnerClassA"_s,
+ u"Foo.NamespaceB"_s, u"Foo.EnumB"_s,
+ u"Foo.funcB()"_s,
+ u"Foo.NamespaceA.InnerNamespaceA"_s};
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false,
QString(), droppedEntries));
- QVERIFY(!builder.isNull());
+ QVERIFY(builder);
AbstractMetaClassList classes = builder->classes();
- QVERIFY(AbstractMetaClass::findClass(classes, QLatin1String("ValueA")));
- QVERIFY(!AbstractMetaClass::findClass(classes, QLatin1String("ValueB")));
- QVERIFY(AbstractMetaClass::findClass(classes, QLatin1String("ObjectA")));
- QVERIFY(!AbstractMetaClass::findClass(classes, QLatin1String("ObjectB")));
- QVERIFY(AbstractMetaClass::findClass(classes, QLatin1String("NamespaceA")));
- QVERIFY(!AbstractMetaClass::findClass(classes, QLatin1String("NamespaceA::InnerClassA")));
- QVERIFY(!AbstractMetaClass::findClass(classes, QLatin1String("NamespaceB")));
+ QVERIFY(AbstractMetaClass::findClass(classes, "ValueA"));
+ QVERIFY(!AbstractMetaClass::findClass(classes, "ValueB"));
+ QVERIFY(AbstractMetaClass::findClass(classes, "ObjectA"));
+ QVERIFY(!AbstractMetaClass::findClass(classes, "ObjectB"));
+ QVERIFY(AbstractMetaClass::findClass(classes, "NamespaceA"));
+ QVERIFY(!AbstractMetaClass::findClass(classes, "NamespaceA::InnerClassA"));
+ QVERIFY(!AbstractMetaClass::findClass(classes, "NamespaceB"));
AbstractMetaEnumList globalEnums = builder->globalEnums();
- QCOMPARE(globalEnums.count(), 1);
- QCOMPARE(globalEnums.constFirst().name(), QLatin1String("EnumA"));
+ QCOMPARE(globalEnums.size(), 1);
+ QCOMPARE(globalEnums.constFirst().name(), u"EnumA");
- TypeDatabase* td = TypeDatabase::instance();
- QVERIFY(td->findType(QLatin1String("funcA")));
- QVERIFY(!td->findType(QLatin1String("funcB")));
+ auto *td = TypeDatabase::instance();
+ QVERIFY(td->findType(u"funcA"_s));
+ QVERIFY(!td->findType(u"funcB"_s));
}
void TestDropTypeEntries::testDontDropEntries()
{
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
- QVERIFY(!builder.isNull());
+ QVERIFY(builder);
AbstractMetaClassList classes = builder->classes();
- QVERIFY(AbstractMetaClass::findClass(classes, QLatin1String("ValueA")));
- QVERIFY(AbstractMetaClass::findClass(classes, QLatin1String("ValueB")));
- QVERIFY(AbstractMetaClass::findClass(classes, QLatin1String("ObjectA")));
- QVERIFY(AbstractMetaClass::findClass(classes, QLatin1String("ObjectB")));
- QVERIFY(AbstractMetaClass::findClass(classes, QLatin1String("NamespaceA")));
- QVERIFY(AbstractMetaClass::findClass(classes, QLatin1String("NamespaceA::InnerClassA")));
- QVERIFY(AbstractMetaClass::findClass(classes, QLatin1String("NamespaceB")));
+ QVERIFY(AbstractMetaClass::findClass(classes, "ValueA"));
+ QVERIFY(AbstractMetaClass::findClass(classes, "ValueB"));
+ QVERIFY(AbstractMetaClass::findClass(classes, "ObjectA"));
+ QVERIFY(AbstractMetaClass::findClass(classes, "ObjectB"));
+ QVERIFY(AbstractMetaClass::findClass(classes, "NamespaceA"));
+ QVERIFY(AbstractMetaClass::findClass(classes, "NamespaceA::InnerClassA"));
+ QVERIFY(AbstractMetaClass::findClass(classes, "NamespaceB"));
QCOMPARE(builder->globalEnums().size(), 2);
- TypeDatabase* td = TypeDatabase::instance();
- QVERIFY(td->findType(QLatin1String("funcA")));
- QVERIFY(td->findType(QLatin1String("funcB")));
+ auto *td = TypeDatabase::instance();
+ QVERIFY(td->findType(u"funcA"_s));
+ QVERIFY(td->findType(u"funcB"_s));
}
-static const char* cppCode2 ="\
+static const char cppCode2[] = "\
struct ValueA {\n\
void func();\n\
};\n";
-static const char* xmlCode2 = R"(
+static const char xmlCode2[] = R"(
<typesystem package='Foo'>
<value-type name='ValueA'>
<modify-function signature='func()' remove='all'/>
@@ -132,24 +112,24 @@ static const char* xmlCode2 = R"(
void TestDropTypeEntries::testDropEntryWithChildTags()
{
- QStringList droppedEntries(QLatin1String("Foo.ValueA"));
+ QStringList droppedEntries(u"Foo.ValueA"_s);
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode2, xmlCode2, false,
QString(), droppedEntries));
- QVERIFY(!builder.isNull());
- QVERIFY(!AbstractMetaClass::findClass(builder->classes(), QLatin1String("ValueA")));
+ QVERIFY(builder);
+ QVERIFY(!AbstractMetaClass::findClass(builder->classes(), "ValueA"));
}
void TestDropTypeEntries::testDontDropEntryWithChildTags()
{
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode2, xmlCode2, false));
- QVERIFY(!builder.isNull());
- QVERIFY(AbstractMetaClass::findClass(builder->classes(), QLatin1String("ValueA")));
+ QVERIFY(builder);
+ QVERIFY(AbstractMetaClass::findClass(builder->classes(), "ValueA"));
}
void TestDropTypeEntries::testConditionalParsing_data()
{
- const QString xml = QStringLiteral(R"(<?xml version="1.0" encoding="UTF-8"?>
+ const QString xml = R"(<?xml version="1.0" encoding="UTF-8"?>
<root>
<tag1>text</tag1>
<?if keyword1?>
@@ -165,17 +145,17 @@ void TestDropTypeEntries::testConditionalParsing_data()
<?if !keyword99?> <!-- Exclusion only -->
<tag6>text</tag6>
<?endif?>
-</root>)");
-
- const QString root = QStringLiteral("root");
- const QString tag1 = QStringLiteral("tag1");
- const QString tag2 = QStringLiteral("tag2");
- const QString tag3 = QStringLiteral("tag3");
- const QString tag4 = QStringLiteral("tag4");
- const QString tag5 = QStringLiteral("tag5");
- const QString tag6 = QStringLiteral("tag6");
- const QString keyword1 = QStringLiteral("keyword1");
- const QString keyword2 = QStringLiteral("keyword2");
+</root>)"_L1;
+
+ constexpr auto root = "root"_L1;
+ constexpr auto tag1 = "tag1"_L1;
+ constexpr auto tag2 = "tag2"_L1;
+ constexpr auto tag3 = "tag3"_L1;
+ constexpr auto tag4 = "tag4"_L1;
+ constexpr auto tag5 = "tag5"_L1;
+ constexpr auto tag6 = "tag6"_L1;
+ constexpr auto keyword1 = "keyword1"_L1;
+ constexpr auto keyword2 = "keyword2"_L1;
QTest::addColumn<QString>("xml");
QTest::addColumn<QStringList>("keywords");
@@ -224,11 +204,11 @@ void TestDropTypeEntries::testConditionalParsing()
void TestDropTypeEntries::testEntityParsing()
{
- const QString xml = QStringLiteral(R"(<?xml version="1.0" encoding="UTF-8"?>
+ const QString xml = R"(<?xml version="1.0" encoding="UTF-8"?>
<root>
<?entity testentity word1 word2?>
<text>bla &testentity;</text>
-</root>)");
+</root>)"_L1;
QString actual;
ConditionalStreamReader reader(xml);