aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor/tests/testaddfunction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken6/ApiExtractor/tests/testaddfunction.cpp')
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testaddfunction.cpp283
1 files changed, 133 insertions, 150 deletions
diff --git a/sources/shiboken6/ApiExtractor/tests/testaddfunction.cpp b/sources/shiboken6/ApiExtractor/tests/testaddfunction.cpp
index 1c5e31f35..a891e1e28 100644
--- a/sources/shiboken6/ApiExtractor/tests/testaddfunction.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testaddfunction.cpp
@@ -1,80 +1,67 @@
-/****************************************************************************
-**
-** 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 "testaddfunction.h"
-#include <QtTest/QTest>
#include "testutil.h"
+#include <abstractmetaargument.h>
#include <abstractmetafunction.h>
#include <abstractmetalang.h>
-#include <modifications.h>
-#include <modifications_p.h>
-#include <typesystem.h>
+#include <abstractmetatype.h>
+#include <codesnip.h>
+#include <addedfunction.h>
+#include <addedfunction_p.h>
+#include <complextypeentry.h>
+#include <primitivetypeentry.h>
+
+#include <qtcompat.h>
+
+#include <QtTest/QTest>
+
+using namespace Qt::StringLiterals;
+
+static constexpr auto voidT = "void"_L1;
void TestAddFunction::testParsingFuncNameAndConstness()
{
// generic test...
- const char sig1[] = "func(type1, const type2, const type3* const)";
+ static constexpr auto sig1 = "func(type1, const type2, const type3* const)"_L1;
QString errorMessage;
- auto f1 = AddedFunction::createAddedFunction(QLatin1String(sig1), QLatin1String("void"),
- &errorMessage);
- QVERIFY2(!f1.isNull(), qPrintable(errorMessage));
- QCOMPARE(f1->name(), QLatin1String("func"));
- QCOMPARE(f1->arguments().count(), 3);
+ auto f1 = AddedFunction::createAddedFunction(sig1, voidT, &errorMessage);
+ QVERIFY2(f1, qPrintable(errorMessage));
+ QCOMPARE(f1->name(), u"func");
+ QCOMPARE(f1->arguments().size(), 3);
TypeInfo retval = f1->returnType();
- QCOMPARE(retval.qualifiedName(), QStringList{QLatin1String("void")});
+ QCOMPARE(retval.qualifiedName(), QStringList{voidT});
QCOMPARE(retval.indirections(), 0);
QCOMPARE(retval.isConstant(), false);
QCOMPARE(retval.referenceType(), NoReference);
// test with a ugly template as argument and other ugly stuff
- const char sig2[] = " _fu__nc_ ( type1, const type2, const Abc<int& , C<char*> * > * *@my_name@, const type3* const ) const ";
- auto f2 = AddedFunction::createAddedFunction(QLatin1String(sig2),
- QLatin1String("const Abc<int& , C<char*> * > * *"),
+ static constexpr auto sig2 =
+ " _fu__nc_ ( type1, const type2, const Abc<int& , C<char*> * >"
+ " * *@my_name@, const type3* const ) const "_L1;
+ auto f2 = AddedFunction::createAddedFunction(sig2,
+ u"const Abc<int& , C<char*> * > * *"_s,
&errorMessage);
- QVERIFY2(!f2.isNull(), qPrintable(errorMessage));
- QCOMPARE(f2->name(), QLatin1String("_fu__nc_"));
+ QVERIFY2(f2, qPrintable(errorMessage));
+ QCOMPARE(f2->name(), u"_fu__nc_");
const auto &args = f2->arguments();
- QCOMPARE(args.count(), 4);
+ QCOMPARE(args.size(), 4);
retval = f2->returnType();
- QCOMPARE(retval.qualifiedName(), QStringList{QLatin1String("Abc")});
+ QCOMPARE(retval.qualifiedName(), QStringList{u"Abc"_s});
QCOMPARE(retval.instantiations().size(), 2);
- QCOMPARE(retval.toString(), QLatin1String("const Abc<int&, C<char*>*>**"));
+ QCOMPARE(retval.toString(), u"const Abc<int&, C<char*>*>**");
QCOMPARE(retval.indirections(), 2);
QCOMPARE(retval.isConstant(), true);
QCOMPARE(retval.referenceType(), NoReference);
QVERIFY(args.at(0).name.isEmpty());
QVERIFY(args.at(1).name.isEmpty());
- QCOMPARE(args.at(2).name, QLatin1String("my_name"));
+ QCOMPARE(args.at(2).name, u"my_name");
auto arg2Type = args.at(2).typeInfo;
- QCOMPARE(arg2Type.qualifiedName(), QStringList{QLatin1String("Abc")});
+ QCOMPARE(arg2Type.qualifiedName(), QStringList{u"Abc"_s});
QCOMPARE(arg2Type.instantiations().size(), 2);
- QCOMPARE(arg2Type.toString(), QLatin1String("const Abc<int&, C<char*>*>**"));
+ QCOMPARE(arg2Type.toString(), u"const Abc<int&, C<char*>*>**");
QCOMPARE(arg2Type.indirections(), 2);
QCOMPARE(arg2Type.isConstant(), true);
QCOMPARE(arg2Type.referenceType(), NoReference);
@@ -82,20 +69,17 @@ void TestAddFunction::testParsingFuncNameAndConstness()
QVERIFY(args.at(3).name.isEmpty());
// function with no args.
- const char sig3[] = "func()";
- auto f3 = AddedFunction::createAddedFunction(QLatin1String(sig3), QLatin1String("void"),
- &errorMessage);
- QVERIFY2(!f3.isNull(), qPrintable(errorMessage));
- QCOMPARE(f3->name(), QLatin1String("func"));
- QCOMPARE(f3->arguments().count(), 0);
+ auto f3 = AddedFunction::createAddedFunction("func()"_L1, voidT, &errorMessage);
+ QVERIFY2(f3, qPrintable(errorMessage));
+ QCOMPARE(f3->name(), u"func");
+ QCOMPARE(f3->arguments().size(), 0);
// const call operator
- const char sig4[] = "operator()(int)const";
- auto f4 = AddedFunction::createAddedFunction(QLatin1String(sig4), QLatin1String("int"),
- &errorMessage);
- QVERIFY2(!f4.isNull(), qPrintable(errorMessage));
- QCOMPARE(f4->name(), QLatin1String("operator()"));
- QCOMPARE(f4->arguments().count(), 1);
+ auto f4 = AddedFunction::createAddedFunction("operator()(int)const"_L1,
+ "int"_L1, &errorMessage);
+ QVERIFY2(f4, qPrintable(errorMessage));
+ QCOMPARE(f4->name(), u"operator()");
+ QCOMPARE(f4->arguments().size(), 1);
QVERIFY(f4->isConstant());
}
@@ -118,14 +102,15 @@ struct A {
</typesystem>)XML";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
- QVERIFY(!builder.isNull());
- TypeDatabase* typeDb = TypeDatabase::instance();
+ QVERIFY(builder);
+ auto *typeDb = TypeDatabase::instance();
AbstractMetaClassList classes = builder->classes();
- const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ const auto classA = AbstractMetaClass::findClass(classes, "A");
QVERIFY(classA);
- QCOMPARE(classA->functions().count(), 5); // default ctor, default copy ctor, func a() and the added functions
+ // default ctor, default copy ctor, func a() and the added functions
+ QCOMPARE(classA->functions().size(), 5);
- auto addedFunc = classA->findFunction(QLatin1String("b"));
+ auto addedFunc = classA->findFunction("b");
QVERIFY(addedFunc);
QCOMPARE(addedFunc->access(), Access::Protected);
QCOMPARE(addedFunc->functionType(), AbstractMetaFunction::NormalFunction);
@@ -139,14 +124,14 @@ struct A {
QVERIFY(!addedFunc->isStatic());
AbstractMetaType returnType = addedFunc->type();
- QCOMPARE(returnType.typeEntry(), typeDb->findPrimitiveType(QLatin1String("int")));
+ QCOMPARE(returnType.typeEntry(), typeDb->findPrimitiveType(u"int"_s));
const AbstractMetaArgumentList &args = addedFunc->arguments();
- QCOMPARE(args.count(), 3);
+ QCOMPARE(args.size(), 3);
QCOMPARE(args.at(0).type().typeEntry(), returnType.typeEntry());
- QCOMPARE(args.at(1).defaultValueExpression(), QLatin1String("4.6"));
- QCOMPARE(args.at(2).type().typeEntry(), typeDb->findType(QLatin1String("B")));
+ QCOMPARE(args.at(1).defaultValueExpression(), u"4.6");
+ QCOMPARE(args.at(2).type().typeEntry(), typeDb->findType(u"B"_s));
- auto addedCallOperator = classA->findFunction(QLatin1String("operator()"));
+ auto addedCallOperator = classA->findFunction("operator()");
QVERIFY(addedCallOperator);
}
@@ -161,11 +146,11 @@ void TestAddFunction::testAddFunctionConstructor()
</value-type>\n\
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
- QVERIFY(!builder.isNull());
+ QVERIFY(builder);
AbstractMetaClassList classes = builder->classes();
- const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ const auto classA = AbstractMetaClass::findClass(classes, "A");
QVERIFY(classA);
- QCOMPARE(classA->functions().count(), 3); // default and added ctors
+ QCOMPARE(classA->functions().size(), 3); // default and added ctors
const auto addedFunc = classA->functions().constLast();
QCOMPARE(addedFunc->access(), Access::Public);
QCOMPARE(addedFunc->functionType(), AbstractMetaFunction::ConstructorFunction);
@@ -184,11 +169,12 @@ void TestAddFunction::testAddFunctionTagDefaultValues()
</value-type>\n\
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
- QVERIFY(!builder.isNull());
+ QVERIFY(builder);
AbstractMetaClassList classes = builder->classes();
- const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ const auto classA = AbstractMetaClass::findClass(classes, "A");
QVERIFY(classA);
- QCOMPARE(classA->functions().count(), 3); // default ctor, default copy ctor and the added function
+ // default ctor, default copy ctor and the added function
+ QCOMPARE(classA->functions().size(), 3);
const auto addedFunc = classA->functions().constLast();
QCOMPARE(addedFunc->access(), Access::Public);
QCOMPARE(addedFunc->functionType(), AbstractMetaFunction::NormalFunction);
@@ -209,9 +195,9 @@ void TestAddFunction::testAddFunctionCodeSnippets()
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
- QVERIFY(!builder.isNull());
+ QVERIFY(builder);
AbstractMetaClassList classes = builder->classes();
- const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ const auto classA = AbstractMetaClass::findClass(classes, "A");
QVERIFY(classA);
const auto addedFunc = classA->functions().constLast();
QVERIFY(addedFunc->hasInjectedCode());
@@ -219,13 +205,12 @@ void TestAddFunction::testAddFunctionCodeSnippets()
void TestAddFunction::testAddFunctionWithoutParenteses()
{
- const char sig1[] = "func";
+ static constexpr auto sig1 = "func"_L1;
QString errorMessage;
- auto f1 = AddedFunction::createAddedFunction(QLatin1String(sig1), QLatin1String("void"),
- &errorMessage);
- QVERIFY2(!f1.isNull(), qPrintable(errorMessage));
- QCOMPARE(f1->name(), QLatin1String("func"));
- QCOMPARE(f1->arguments().count(), 0);
+ auto f1 = AddedFunction::createAddedFunction(sig1, voidT, &errorMessage);
+ QVERIFY2(f1, qPrintable(errorMessage));
+ QCOMPARE(f1->name(), u"func");
+ QCOMPARE(f1->arguments().size(), 0);
QCOMPARE(f1->isConstant(), false);
const char cppCode[] = "struct A {};\n";
@@ -239,25 +224,26 @@ void TestAddFunction::testAddFunctionWithoutParenteses()
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
- QVERIFY(!builder.isNull());
+ QVERIFY(builder);
AbstractMetaClassList classes = builder->classes();
- const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ const auto classA = AbstractMetaClass::findClass(classes, "A");
QVERIFY(classA);
- const auto addedFunc = classA->findFunction(QLatin1String("func"));
- QVERIFY(!addedFunc.isNull());
+ const auto addedFunc = classA->findFunction(sig1);
+ QVERIFY(addedFunc);
QVERIFY(addedFunc->hasInjectedCode());
- QCOMPARE(addedFunc->injectedCodeSnips(TypeSystem::CodeSnipPositionAny, TypeSystem::TargetLangCode).count(), 1);
+ const auto snips = addedFunc->injectedCodeSnips(TypeSystem::CodeSnipPositionAny,
+ TypeSystem::TargetLangCode);
+ QCOMPARE(snips.size(), 1);
}
void TestAddFunction::testAddFunctionWithDefaultArgs()
{
- const char sig1[] = "func";
+ static constexpr auto sig1 = "func"_L1;
QString errorMessage;
- auto f1 = AddedFunction::createAddedFunction(QLatin1String(sig1), QLatin1String("void"),
- &errorMessage);
- QVERIFY2(!f1.isNull(), qPrintable(errorMessage));
- QCOMPARE(f1->name(), QLatin1String("func"));
- QCOMPARE(f1->arguments().count(), 0);
+ auto f1 = AddedFunction::createAddedFunction(sig1, voidT, &errorMessage);
+ QVERIFY2(f1, qPrintable(errorMessage));
+ QCOMPARE(f1->name(), u"func");
+ QCOMPARE(f1->arguments().size(), 0);
QCOMPARE(f1->isConstant(), false);
const char cppCode[] = "struct A { };\n";
@@ -274,14 +260,14 @@ void TestAddFunction::testAddFunctionWithDefaultArgs()
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
- QVERIFY(!builder.isNull());
+ QVERIFY(builder);
AbstractMetaClassList classes = builder->classes();
- const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ const auto classA = AbstractMetaClass::findClass(classes, "A");
QVERIFY(classA);
- const auto addedFunc = classA->findFunction(QLatin1String("func"));
- QVERIFY(!addedFunc.isNull());
+ const auto addedFunc = classA->findFunction(sig1);
+ QVERIFY(addedFunc);
const AbstractMetaArgument &arg = addedFunc->arguments().at(1);
- QCOMPARE(arg.defaultValueExpression(), QLatin1String("2"));
+ QCOMPARE(arg.defaultValueExpression(), u"2");
}
void TestAddFunction::testAddFunctionAtModuleLevel()
@@ -297,34 +283,33 @@ void TestAddFunction::testAddFunctionAtModuleLevel()
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
- QVERIFY(!builder.isNull());
+ QVERIFY(builder);
AbstractMetaClassList classes = builder->classes();
- const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ const auto classA = AbstractMetaClass::findClass(classes, "A");
QVERIFY(classA);
- TypeDatabase* typeDb = TypeDatabase::instance();
+ auto *typeDb = TypeDatabase::instance();
- AddedFunctionList addedFuncs = typeDb->findGlobalUserFunctions(QLatin1String("func"));
+ AddedFunctionList addedFuncs = typeDb->findGlobalUserFunctions(u"func"_s);
QCOMPARE(addedFuncs.size(), 1);
- const FunctionModificationList mods = addedFuncs.constFirst()->modifications;
+ auto &mods = addedFuncs.constFirst()->modifications();
QCOMPARE(mods.size(), 1);
QVERIFY(mods.constFirst().isCodeInjection());
CodeSnip snip = mods.constFirst().snips().constFirst();
- QCOMPARE(snip.code().trimmed(), QLatin1String("custom_code();"));
+ QCOMPARE(snip.code().trimmed(), u"custom_code();");
}
void TestAddFunction::testAddFunctionWithVarargs()
{
- const char sig1[] = "func(int,char,...)";
QString errorMessage;
- auto f1 = AddedFunction::createAddedFunction(QLatin1String(sig1), QLatin1String("void"),
+ auto f1 = AddedFunction::createAddedFunction("func(int,char,...)"_L1, voidT,
&errorMessage);
- QVERIFY2(!f1.isNull(), qPrintable(errorMessage));
- QCOMPARE(f1->name(), QLatin1String("func"));
- QCOMPARE(f1->arguments().count(), 3);
+ QVERIFY2(f1, qPrintable(errorMessage));
+ QCOMPARE(f1->name(), u"func");
+ QCOMPARE(f1->arguments().size(), 3);
QVERIFY(!f1->isConstant());
const char cppCode[] = "struct A {};\n";
@@ -338,12 +323,12 @@ void TestAddFunction::testAddFunctionWithVarargs()
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
- QVERIFY(!builder.isNull());
+ QVERIFY(builder);
AbstractMetaClassList classes = builder->classes();
- const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ const auto classA = AbstractMetaClass::findClass(classes, "A");
QVERIFY(classA);
- const auto addedFunc = classA->findFunction(QLatin1String("func"));
- QVERIFY(!addedFunc.isNull());
+ const auto addedFunc = classA->findFunction("func");
+ QVERIFY(addedFunc);
const AbstractMetaArgument &arg = addedFunc->arguments().constLast();
QVERIFY(arg.type().isVarargs());
QVERIFY(arg.type().typeEntry()->isVarargs());
@@ -362,12 +347,12 @@ void TestAddFunction::testAddStaticFunction()
</value-type>\n\
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
- QVERIFY(!builder.isNull());
+ QVERIFY(builder);
AbstractMetaClassList classes = builder->classes();
- const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
+ const auto classA = AbstractMetaClass::findClass(classes, "A");
QVERIFY(classA);
- const auto addedFunc = classA->findFunction(QLatin1String("func"));
- QVERIFY(!addedFunc.isNull());
+ const auto addedFunc = classA->findFunction("func");
+ QVERIFY(addedFunc);
QVERIFY(addedFunc->isStatic());
}
@@ -387,13 +372,13 @@ void TestAddFunction::testAddGlobalFunction()
<value-type name='B'/>\n\
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
- QVERIFY(!builder.isNull());
+ QVERIFY(builder);
const auto globalFuncs = builder->globalFunctions();
- QCOMPARE(globalFuncs.count(), 2);
- const AbstractMetaClass *classB = AbstractMetaClass::findClass(builder->classes(), QLatin1String("B"));
+ QCOMPARE(globalFuncs.size(), 2);
+ const auto classB = AbstractMetaClass::findClass(builder->classes(), "B");
QVERIFY(classB);
- QVERIFY(!classB->findFunction(QLatin1String("globalFunc")));
- QVERIFY(!classB->findFunction(QLatin1String("globalFunc2")));
+ QVERIFY(!classB->findFunction("globalFunc"));
+ QVERIFY(!classB->findFunction("globalFunc2"));
QVERIFY(!globalFuncs[0]->injectedCodeSnips().isEmpty());
QVERIFY(!globalFuncs[1]->injectedCodeSnips().isEmpty());
}
@@ -412,10 +397,10 @@ void TestAddFunction::testAddFunctionWithApiVersion()
</add-function>\n\
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode,
- true, QLatin1String("0.1")));
- QVERIFY(!builder.isNull());
+ true, u"0.1"_s));
+ QVERIFY(builder);
const auto globalFuncs = builder->globalFunctions();
- QCOMPARE(globalFuncs.count(), 1);
+ QCOMPARE(globalFuncs.size(), 1);
}
void TestAddFunction::testModifyAddedFunction()
@@ -436,16 +421,16 @@ void TestAddFunction::testModifyAddedFunction()
</typesystem>
)";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
- QVERIFY(!builder.isNull());
+ QVERIFY(builder);
AbstractMetaClassList classes = builder->classes();
- AbstractMetaClass* foo = AbstractMetaClass::findClass(classes, QLatin1String("Foo"));
- const auto method = foo->findFunction(QLatin1String("method"));
- QVERIFY(!method.isNull());
+ const auto foo = AbstractMetaClass::findClass(classes, "Foo");
+ const auto method = foo->findFunction("method");
+ QVERIFY(method);
QCOMPARE(method->arguments().size(), 2);
const AbstractMetaArgument &arg = method->arguments().at(1);
- QCOMPARE(arg.defaultValueExpression(), QLatin1String("0"));
- QCOMPARE(arg.name(), QLatin1String("varName"));
- QCOMPARE(method->argumentName(2), QLatin1String("varName"));
+ QCOMPARE(arg.defaultValueExpression(), u"0");
+ QCOMPARE(arg.name(), u"varName");
+ QCOMPARE(method->argumentName(2), u"varName");
}
void TestAddFunction::testAddFunctionOnTypedef()
@@ -453,8 +438,6 @@ void TestAddFunction::testAddFunctionOnTypedef()
const char cppCode[] = "template<class T> class Foo { }; typedef Foo<int> FooInt;\n";
const char xmlCode[] = "\
<typesystem package='Package'>\n\
- <custom-type name='PySequence'/>\n\
- <primitive-type name='int'/>\n\
<value-type name='FooInt'>\n\
<add-function signature='FooInt(PySequence)'>\n\
<inject-code class='target' position='beginning'>custom_code();</inject-code>\n\
@@ -465,17 +448,17 @@ void TestAddFunction::testAddFunctionOnTypedef()
</value-type>\n\
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
- QVERIFY(!builder.isNull());
+ QVERIFY(builder);
AbstractMetaClassList classes = builder->classes();
- AbstractMetaClass* foo = AbstractMetaClass::findClass(classes, QLatin1String("FooInt"));
+ const auto foo = AbstractMetaClass::findClass(classes, "FooInt");
QVERIFY(foo);
QVERIFY(foo->hasNonPrivateConstructor());
- const auto &lst = foo->queryFunctions(FunctionQueryOption::Constructors);
+ const auto &lst = foo->queryFunctions(FunctionQueryOption::AnyConstructor);
for (const auto &f : lst)
QVERIFY(f->signature().startsWith(f->name()));
QCOMPARE(lst.size(), 2);
- const auto method = foo->findFunction(QLatin1String("method"));
- QVERIFY(!method.isNull());
+ const auto method = foo->findFunction("method");
+ QVERIFY(method);
}
void TestAddFunction::testAddFunctionWithTemplateArg()
@@ -489,11 +472,11 @@ void TestAddFunction::testAddFunctionWithTemplateArg()
</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();
const AbstractMetaArgument &arg = func->arguments().constFirst();
- QCOMPARE(arg.type().instantiations().count(), 1);
+ QCOMPARE(arg.type().instantiations().size(), 1);
}
// Test splitting of <add-function> parameter lists.
@@ -512,18 +495,18 @@ void TestAddFunction::testAddFunctionTypeParser_data()
QTest::newRow("1-arg")
<< QString::fromLatin1("int @a@=42")
- << Arguments{{QLatin1String("int"), QLatin1String("a"), QLatin1String("42")}};
+ << Arguments{{u"int"_s, u"a"_s, u"42"_s}};
QTest::newRow("2-args")
<< QString::fromLatin1("double @d@, int @a@=42")
- << Arguments{{QLatin1String("double"), QLatin1String("d"), {}},
- {QLatin1String("int"), QLatin1String("a"), QLatin1String("42")}};
+ << Arguments{{u"double"_s, u"d"_s, {}},
+ {u"int"_s, u"a"_s, u"42"_s}};
QTest::newRow("template-var_args")
<< QString::fromLatin1("const QList<X,Y> &@list@ = QList<X,Y>{1,2}, int @b@=5, ...")
- << Arguments{{QLatin1String("const QList<X,Y> &"), QLatin1String("list"), QLatin1String("QList<X,Y>{1,2}")},
- {QLatin1String("int"), QLatin1String("b"), QLatin1String("5")},
- {QLatin1String("..."), {}, {}}};
+ << Arguments{{u"const QList<X,Y> &"_s, u"list"_s, u"QList<X,Y>{1,2}"_s},
+ {u"int"_s, u"b"_s, u"5"_s},
+ {u"..."_s, {}, {}}};
}
void TestAddFunction::testAddFunctionTypeParser()