aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor/tests/testabstractmetatype.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken6/ApiExtractor/tests/testabstractmetatype.cpp')
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testabstractmetatype.cpp112
1 files changed, 47 insertions, 65 deletions
diff --git a/sources/shiboken6/ApiExtractor/tests/testabstractmetatype.cpp b/sources/shiboken6/ApiExtractor/tests/testabstractmetatype.cpp
index 897940cd5..2c320c874 100644
--- a/sources/shiboken6/ApiExtractor/tests/testabstractmetatype.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testabstractmetatype.cpp
@@ -1,40 +1,22 @@
-/****************************************************************************
-**
-** 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 "testabstractmetatype.h"
-#include <QtTest/QTest>
#include "testutil.h"
+#include <abstractmetaargument.h>
#include <abstractmetafunction.h>
#include <abstractmetalang.h>
+#include <abstractmetatype.h>
#include <typesystem.h>
#include <parser/codemodel.h>
#include <typeparser.h>
+#include <qtcompat.h>
+
+#include <QtTest/QTest>
+
+using namespace Qt::StringLiterals;
+
void TestAbstractMetaType::parsing_data()
{
QTest::addColumn<QString>("input");
@@ -66,20 +48,20 @@ void TestAbstractMetaType::parsing()
void TestAbstractMetaType::testConstCharPtrType()
{
- const char* cppCode ="const char* justAtest();\n";
- const char* xmlCode = "<typesystem package=\"Foo\">\n\
+ const char cppCode[] = "const char* justAtest();\n";
+ const char xmlCode[] = "<typesystem package=\"Foo\">\n\
<primitive-type name='char'/>\n\
<function signature='justAtest()' />\n\
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
- QVERIFY(!builder.isNull());
+ QVERIFY(builder);
QCOMPARE(builder->globalFunctions().size(), 1);
const auto func = builder->globalFunctions().constFirst();
AbstractMetaType rtype = func->type();
// Test properties of const char*
QVERIFY(!rtype.isVoid());
- QCOMPARE(rtype.package(), QLatin1String("Foo"));
- QCOMPARE(rtype.name(), QLatin1String("char"));
+ QCOMPARE(rtype.package(), u"Foo");
+ QCOMPARE(rtype.name(), u"char");
QVERIFY(rtype.isConstant());
QVERIFY(!rtype.isArray());
QVERIFY(!rtype.isContainer());
@@ -93,9 +75,9 @@ void TestAbstractMetaType::testConstCharPtrType()
void TestAbstractMetaType::testApiVersionSupported()
{
- const char* cppCode ="class foo {}; class foo2 {};\n\
+ const char cppCode[] = "class foo {}; class foo2 {};\n\
void justAtest(); void justAtest3();\n";
- const char* xmlCode = "<typesystem package='Foo'>\n\
+ const char xmlCode[] = "<typesystem package='Foo'>\n\
<value-type name='foo' since='0.1'/>\n\
<value-type name='foo2' since='1.0'/>\n\
<value-type name='foo3' since='1.1'/>\n\
@@ -104,8 +86,8 @@ void TestAbstractMetaType::testApiVersionSupported()
<function signature='justAtest3()'/>\n\
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode,
- false, QLatin1String("1.0")));
- QVERIFY(!builder.isNull());
+ false, u"1.0"_s));
+ QVERIFY(builder);
AbstractMetaClassList classes = builder->classes();
QCOMPARE(classes.size(), 2);
@@ -117,13 +99,13 @@ void TestAbstractMetaType::testApiVersionSupported()
void TestAbstractMetaType::testApiVersionNotSupported()
{
- const char* cppCode ="class object {};\n";
- const char* xmlCode = "<typesystem package='Foo'>\n\
+ const char cppCode[] = "class object {};\n";
+ const char xmlCode[] = "<typesystem package='Foo'>\n\
<value-type name='object' since='0.1'/>\n\
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode,
- true, QLatin1String("0.1")));
- QVERIFY(!builder.isNull());
+ true, u"0.1"_s));
+ QVERIFY(builder);
AbstractMetaClassList classes = builder->classes();
QCOMPARE(classes.size(), 1);
@@ -131,18 +113,18 @@ void TestAbstractMetaType::testApiVersionNotSupported()
void TestAbstractMetaType::testCharType()
{
- const char* cppCode ="char justAtest(); class A {};\n";
- const char* xmlCode = "<typesystem package=\"Foo\">\n\
+ const char cppCode[] = "char justAtest(); class A {};\n";
+ const char xmlCode[] = "<typesystem package=\"Foo\">\n\
<primitive-type name='char'/>\n\
<value-type name='A'/>\n\
<function signature='justAtest()'/>\n\
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
- QVERIFY(!builder.isNull());
+ QVERIFY(builder);
AbstractMetaClassList classes = builder->classes();
QCOMPARE(classes.size(), 1);
- QCOMPARE(classes.constFirst()->package(), QLatin1String("Foo"));
+ QCOMPARE(classes.constFirst()->package(), u"Foo");
const auto functions = builder->globalFunctions();
QCOMPARE(functions.size(), 1);
@@ -150,8 +132,8 @@ void TestAbstractMetaType::testCharType()
AbstractMetaType rtype = func->type();
// Test properties of const char*
QVERIFY(!rtype.isVoid());
- QCOMPARE(rtype.package(), QLatin1String("Foo"));
- QCOMPARE(rtype.name(), QLatin1String("char"));
+ QCOMPARE(rtype.package(), u"Foo");
+ QCOMPARE(rtype.name(), u"char");
QVERIFY(!rtype.isConstant());
QVERIFY(!rtype.isArray());
QVERIFY(!rtype.isContainer());
@@ -165,28 +147,28 @@ void TestAbstractMetaType::testCharType()
void TestAbstractMetaType::testTypedef()
{
- const char* cppCode ="\
+ const char cppCode[] = "\
struct A {\n\
void someMethod();\n\
};\n\
typedef A B;\n\
typedef B C;\n";
- const char* xmlCode = "<typesystem package=\"Foo\">\n\
+ const char xmlCode[] = "<typesystem package=\"Foo\">\n\
<value-type name='C' />\n\
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
- QVERIFY(!builder.isNull());
+ QVERIFY(builder);
AbstractMetaClassList classes = builder->classes();
QCOMPARE(classes.size(), 1);
- const AbstractMetaClass *c = AbstractMetaClass::findClass(classes, QLatin1String("C"));
+ const auto c = AbstractMetaClass::findClass(classes, "C");
QVERIFY(c);
QVERIFY(c->isTypeDef());
}
void TestAbstractMetaType::testTypedefWithTemplates()
{
- const char* cppCode ="\
+ const char cppCode[] = "\
template<typename T>\n\
class A {};\n\
\n\
@@ -194,52 +176,52 @@ void TestAbstractMetaType::testTypedefWithTemplates()
typedef A<B> C;\n\
\n\
void func(C c);\n";
- const char* xmlCode = "<typesystem package=\"Foo\">\n\
+ const char xmlCode[] = "<typesystem package=\"Foo\">\n\
<container-type name='A' type='list'/>\n\
<value-type name='B' />\n\
<function signature='func(A&lt;B&gt;)'/>\n\
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
- QVERIFY(!builder.isNull());
+ QVERIFY(builder);
AbstractMetaClassList classes = builder->classes();
QCOMPARE(classes.size(), 1);
const auto functions = builder->globalFunctions();
- QCOMPARE(functions.count(), 1);
+ QCOMPARE(functions.size(), 1);
const auto function = functions.constFirst();
AbstractMetaArgumentList args = function->arguments();
- QCOMPARE(args.count(), 1);
+ QCOMPARE(args.size(), 1);
const AbstractMetaArgument &arg = args.constFirst();
AbstractMetaType metaType = arg.type();
- QCOMPARE(metaType.cppSignature(), QLatin1String("A<B >"));
+ QCOMPARE(metaType.cppSignature(), u"A<B>");
}
void TestAbstractMetaType::testObjectTypeUsedAsValue()
{
- const char* cppCode ="\
+ const char cppCode[] = "\
class A {\n\
void method(A);\n\
};\n";
- const char* xmlCode = "<typesystem package='Foo'>\n\
+ const char xmlCode[] = "<typesystem package='Foo'>\n\
<object-type name='A'/>\n\
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
- QVERIFY(!builder.isNull());
+ QVERIFY(builder);
AbstractMetaClassList classes = builder->classes();
QCOMPARE(classes.size(), 1);
- const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ const auto classA = AbstractMetaClass::findClass(classes, "A");
QVERIFY(classA);
- const auto overloads = classA->queryFunctionsByName(QLatin1String("method"));
- QCOMPARE(overloads.count(), 1);
+ const auto overloads = classA->queryFunctionsByName(u"method"_s);
+ QCOMPARE(overloads.size(), 1);
const auto method = overloads.constFirst();
QVERIFY(method);
AbstractMetaArgumentList args = method->arguments();
- QCOMPARE(args.count(), 1);
+ QCOMPARE(args.size(), 1);
const AbstractMetaArgument &arg = args.constFirst();
AbstractMetaType metaType = arg.type();
- QCOMPARE(metaType.cppSignature(), QLatin1String("A"));
+ QCOMPARE(metaType.cppSignature(), u"A");
QVERIFY(metaType.isValue());
QVERIFY(metaType.typeEntry()->isObject());
}