diff options
Diffstat (limited to 'sources/shiboken6/ApiExtractor/tests/testabstractmetatype.cpp')
-rw-r--r-- | sources/shiboken6/ApiExtractor/tests/testabstractmetatype.cpp | 79 |
1 files changed, 28 insertions, 51 deletions
diff --git a/sources/shiboken6/ApiExtractor/tests/testabstractmetatype.cpp b/sources/shiboken6/ApiExtractor/tests/testabstractmetatype.cpp index 980db2035..2c320c874 100644 --- a/sources/shiboken6/ApiExtractor/tests/testabstractmetatype.cpp +++ b/sources/shiboken6/ApiExtractor/tests/testabstractmetatype.cpp @@ -1,35 +1,12 @@ -/**************************************************************************** -** -** 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 "testutil.h" +#include <abstractmetaargument.h> #include <abstractmetafunction.h> #include <abstractmetalang.h> +#include <abstractmetatype.h> #include <typesystem.h> #include <parser/codemodel.h> #include <typeparser.h> @@ -71,13 +48,13 @@ 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(); @@ -98,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\ @@ -110,7 +87,7 @@ void TestAbstractMetaType::testApiVersionSupported() </typesystem>\n"; QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false, u"1.0"_s)); - QVERIFY(!builder.isNull()); + QVERIFY(builder); AbstractMetaClassList classes = builder->classes(); QCOMPARE(classes.size(), 2); @@ -122,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, u"0.1"_s)); - QVERIFY(!builder.isNull()); + QVERIFY(builder); AbstractMetaClassList classes = builder->classes(); QCOMPARE(classes.size(), 1); @@ -136,14 +113,14 @@ 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); @@ -170,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, u"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\ @@ -199,13 +176,13 @@ 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<B>)'/>\n\ </typesystem>\n"; QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode)); - QVERIFY(!builder.isNull()); + QVERIFY(builder); AbstractMetaClassList classes = builder->classes(); QCOMPARE(classes.size(), 1); @@ -216,25 +193,25 @@ void TestAbstractMetaType::testTypedefWithTemplates() QCOMPARE(args.size(), 1); const AbstractMetaArgument &arg = args.constFirst(); AbstractMetaType metaType = arg.type(); - QCOMPARE(metaType.cppSignature(), u"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, u"A"); + const auto classA = AbstractMetaClass::findClass(classes, "A"); QVERIFY(classA); const auto overloads = classA->queryFunctionsByName(u"method"_s); QCOMPARE(overloads.size(), 1); |