diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-11-06 09:20:29 +0100 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-11-09 15:49:19 +0000 |
| commit | 3428efa5f69d321bcacdd106b0e724ab99bb63ed (patch) | |
| tree | 2b53a24f83cefd95e2861e8594a0d37010dfe020 /sources/shiboken6/ApiExtractor/tests/testaddfunction.cpp | |
| parent | c2a9236fe970fc34fbb90757d4e8b562760cbc15 (diff) | |
shiboken6: Add a new parser for AddedFunction parameters
Observe' <' (templates), '{' (initializer lists), '[' (array dimensions)
and '(' (initialization, function pointers) when splitting the
parameter lists of added functions.
Add a test.
Change-Id: I8cdc135a2daceab5587c4b5545ed38f0a022b5f8
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken6/ApiExtractor/tests/testaddfunction.cpp')
| -rw-r--r-- | sources/shiboken6/ApiExtractor/tests/testaddfunction.cpp | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/sources/shiboken6/ApiExtractor/tests/testaddfunction.cpp b/sources/shiboken6/ApiExtractor/tests/testaddfunction.cpp index bacdd4906..ca10cbfc6 100644 --- a/sources/shiboken6/ApiExtractor/tests/testaddfunction.cpp +++ b/sources/shiboken6/ApiExtractor/tests/testaddfunction.cpp @@ -31,6 +31,7 @@ #include "testutil.h" #include <abstractmetafunction.h> #include <abstractmetalang.h> +#include <modifications_p.h> #include <typesystem.h> void TestAddFunction::testParsingFuncNameAndConstness() @@ -464,5 +465,44 @@ void TestAddFunction::testAddFunctionWithTemplateArg() QCOMPARE(arg.type().instantiations().count(), 1); } -QTEST_APPLESS_MAIN(TestAddFunction) +// Test splitting of <add-function> parameter lists. + +Q_DECLARE_METATYPE(AddedFunctionParser::Argument) + +using Arguments = AddedFunctionParser::Arguments; + +void TestAddFunction::testAddFunctionTypeParser_data() +{ + QTest::addColumn<QString>("parameterList"); + QTest::addColumn<Arguments>("expected"); + + QTest::newRow("empty") + << QString() << Arguments{}; + + QTest::newRow("1-arg") + << QString::fromLatin1("int @a@=42") + << Arguments{{QLatin1String("int"), QLatin1String("a"), QLatin1String("42")}}; + + QTest::newRow("2-args") + << QString::fromLatin1("double @d@, int @a@=42") + << Arguments{{QLatin1String("double"), QLatin1String("d"), {}}, + {QLatin1String("int"), QLatin1String("a"), QLatin1String("42")}}; + + 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("..."), {}, {}}}; +} +void TestAddFunction::testAddFunctionTypeParser() +{ + + QFETCH(QString, parameterList); + QFETCH(Arguments, expected); + + const auto actual = AddedFunctionParser::splitParameters(parameterList); + QCOMPARE(actual, expected); +} + +QTEST_APPLESS_MAIN(TestAddFunction) |
