summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2010-03-25 19:05:35 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2010-03-26 11:25:13 (GMT)
commitdf0e6759e8ebc1053f951d3a5398a41156e91913 (patch)
tree18396f0e4763f37ada5acc3b6f60fd151d26fbaf /tests
parente7eb7bdf63791ed03257f2f23b1f515e4d89e054 (diff)
downloadQt-df0e6759e8ebc1053f951d3a5398a41156e91913.zip
Qt-df0e6759e8ebc1053f951d3a5398a41156e91913.tar.gz
Qt-df0e6759e8ebc1053f951d3a5398a41156e91913.tar.bz2
QMetaObject::normalizeType: fix uses of const and template.
'const' was not removed from templated class This even fixes compilation errors if using const return templated types We can change the normalized signature in Qt 4.7 as it has already changed and we have code to check that if moc revision < 5 it will renormalize all the symbols cf commit b881d8fb99972f1bd04ab4c84843cc8d43ddbeed Task-number: QTBUG-7421 Reviewed-by: Brad Reviewed-by: Kent Hansen
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/moc/tst_moc.cpp11
-rw-r--r--tests/auto/qmetaobject/tst_qmetaobject.cpp6
-rw-r--r--tests/auto/qobject/tst_qobject.cpp20
3 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp
index 30c2721..8890a15 100644
--- a/tests/auto/moc/tst_moc.cpp
+++ b/tests/auto/moc/tst_moc.cpp
@@ -1302,6 +1302,17 @@ void tst_Moc::QTBUG5590_dummyProperty()
QCOMPARE(o.value2(), 82);
}
+class QTBUG7421_ReturnConstTemplate: public QObject
+{ Q_OBJECT
+public slots:
+ const QList<int> returnConstTemplate1() { return QList<int>(); }
+ QList<int> const returnConstTemplate2() { return QList<int>(); }
+ const int returnConstInt() { return 0; }
+ const QString returnConstString(const QString s) { return s; }
+ QString const returnConstString2( QString const s) { return s; }
+};
+
+
QTEST_APPLESS_MAIN(tst_Moc)
#include "tst_moc.moc"
diff --git a/tests/auto/qmetaobject/tst_qmetaobject.cpp b/tests/auto/qmetaobject/tst_qmetaobject.cpp
index bb4a0d2..e81607e 100644
--- a/tests/auto/qmetaobject/tst_qmetaobject.cpp
+++ b/tests/auto/qmetaobject/tst_qmetaobject.cpp
@@ -706,6 +706,12 @@ void tst_QMetaObject::normalizedSignature_data()
QTest::newRow("const6") << "void foo(QList<const int>)" << "void foo(QList<const int>)";
QTest::newRow("const7") << "void foo(QList<const int*>)" << "void foo(QList<const int*>)";
QTest::newRow("const8") << "void foo(QList<int const*>)" << "void foo(QList<const int*>)";
+ QTest::newRow("const9") << "void foo(const Foo<Bar>)" << "void foo(Foo<Bar>)";
+ QTest::newRow("const10") << "void foo(Foo<Bar>const)" << "void foo(Foo<Bar>)";
+ QTest::newRow("const11") << "void foo(Foo<Bar> *const)" << "void foo(Foo<Bar>*const)";
+ QTest::newRow("const12") << "void foo(Foo<Bar>const*const *const)" << "void foo(Foo<Bar>*const*const)";
+ QTest::newRow("const13") << "void foo(const Foo<Bar>&)" << "void foo(Foo<Bar>)";
+ QTest::newRow("const14") << "void foo(Foo<Bar>const&)" << "void foo(Foo<Bar>)";
}
void tst_QMetaObject::normalizedSignature()
diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp
index 8da3484..08b7c19 100644
--- a/tests/auto/qobject/tst_qobject.cpp
+++ b/tests/auto/qobject/tst_qobject.cpp
@@ -2088,6 +2088,9 @@ signals:
void typePointerConstRefSignal(Class * const &);
+ void constTemplateSignal1( Template<int > );
+ void constTemplateSignal2( Template< const int >);
+
public slots:
void uintPointerSlot(uint *) { }
void ulongPointerSlot(ulong *) { }
@@ -2124,6 +2127,10 @@ public slots:
void typeConstRefSlot(Template<Class const &> const &) {}
void typePointerConstRefSlot(Class * const &) {}
+
+ void constTemplateSlot1(Template<int > const) {}
+ void constTemplateSlot2(const Template<int > ) {}
+ void constTemplateSlot3(const Template< const int >) {}
};
#include "oldnormalizeobject.h"
@@ -2526,6 +2533,19 @@ void tst_QObject::normalize()
QVERIFY(object.connect(&object,
SIGNAL(typePointerConstRefSignal(Class*)),
SLOT(typePointerConstRefSlot(Class*))));
+
+ QVERIFY( connect(&object, SIGNAL(constTemplateSignal1(Template <int>)),
+ &object , SLOT(constTemplateSlot1 (Template<int > ) ) ));
+ QVERIFY( connect(&object, SIGNAL(constTemplateSignal1(Template <int>)),
+ &object , SLOT(constTemplateSlot2 (Template<int > ) ) ));
+ QVERIFY( connect(&object, SIGNAL(constTemplateSignal2(Template <const int>)),
+ &object , SLOT(constTemplateSlot3(Template<int const > ) ) ));
+
+ //type does not match
+ QTest::ignoreMessage(QtWarningMsg, "QObject::connect: Incompatible sender/receiver arguments\n"
+ " NormalizeObject::constTemplateSignal1(Template<int>) --> NormalizeObject::constTemplateSlot3(Template<const int>)");
+ QVERIFY(!connect(&object, SIGNAL(constTemplateSignal1(Template <int>)),
+ &object , SLOT(constTemplateSlot3(Template<int const> ) ) ));
}
class SiblingDeleter : public QObject