diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-08-02 15:17:01 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-08-29 13:46:31 +0000 |
commit | 1a3afc7549238463a35d374eaed96410cf76bfb8 (patch) | |
tree | 2dfd663e0062df7455408d2c516c8091f3f545f7 /sources/shiboken2/ApiExtractor/tests | |
parent | 31872c5c71bf48193744a547b3e2e753f83d5b0b (diff) |
FunctionModification: Make it possible to specify a regular expression
It should make it easier to specify the <array> modifications
for GL functions.
Task-number: PYSIDE-516
Change-Id: Ieb2e540f61785d13ee46a196a18d03b311d308e1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/tests')
-rw-r--r-- | sources/shiboken2/ApiExtractor/tests/testmodifyfunction.cpp | 18 | ||||
-rw-r--r-- | sources/shiboken2/ApiExtractor/tests/testmodifyfunction.h | 1 |
2 files changed, 16 insertions, 3 deletions
diff --git a/sources/shiboken2/ApiExtractor/tests/testmodifyfunction.cpp b/sources/shiboken2/ApiExtractor/tests/testmodifyfunction.cpp index 3d4ef9c89..dd82a0f14 100644 --- a/sources/shiboken2/ApiExtractor/tests/testmodifyfunction.cpp +++ b/sources/shiboken2/ApiExtractor/tests/testmodifyfunction.cpp @@ -32,24 +32,36 @@ #include <abstractmetalang.h> #include <typesystem.h> +void TestModifyFunction::testRenameArgument_data() +{ + QTest::addColumn<QByteArray>("pattern"); + QTest::newRow("fixed_string") << QByteArrayLiteral("method(int)"); + QTest::newRow("regular_expression") << QByteArrayLiteral("^method.*"); +} + void TestModifyFunction::testRenameArgument() { + QFETCH(QByteArray, pattern); + const char* cppCode ="\ struct A {\n\ void method(int=0);\n\ };\n"; - const char* xmlCode = "\ + const char xmlCode1[] = "\ <typesystem package='Foo'>\n\ <primitive-type name='int'/>\n\ <object-type name='A'>\n\ - <modify-function signature='method(int)'>\n\ + <modify-function signature='"; + const char xmlCode2[] = "'>\n\ <modify-argument index='1'>\n\ <rename to='otherArg'/>\n\ </modify-argument>\n\ </modify-function>\n\ </object-type>\n\ </typesystem>\n"; - QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false)); + + const QByteArray xmlCode = QByteArray(xmlCode1) + pattern + QByteArray(xmlCode2); + QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode.constData(), false)); QVERIFY(!builder.isNull()); AbstractMetaClassList classes = builder->classes(); const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A")); diff --git a/sources/shiboken2/ApiExtractor/tests/testmodifyfunction.h b/sources/shiboken2/ApiExtractor/tests/testmodifyfunction.h index fcaa0f9db..6bb62daf4 100644 --- a/sources/shiboken2/ApiExtractor/tests/testmodifyfunction.h +++ b/sources/shiboken2/ApiExtractor/tests/testmodifyfunction.h @@ -37,6 +37,7 @@ class TestModifyFunction : public QObject private slots: void testOwnershipTransfer(); void testWithApiVersion(); + void testRenameArgument_data(); void testRenameArgument(); void invalidateAfterUse(); void testGlobalFunctionModification(); |