Skip to content

Commit 949da23

Browse files
committed
added test for overload of copy constructor and double constructor decorators
1 parent 1b209e6 commit 949da23

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

tests/PythonQtTests.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ void PythonQtTestSlotCalling::testCppFactory()
213213
{
214214
PythonQtTestCppFactory* f = new PythonQtTestCppFactory;
215215
PythonQt::self()->addInstanceDecorators(new PQCppObjectDecorator);
216-
PythonQt::self()->addInstanceDecorators(new PQCppObjectNoWrapDecorator);
216+
PythonQt::self()->addDecorators(new PQCppObjectNoWrapDecorator);
217217

218218
PythonQt::self()->addWrapperFactory(f);
219219
QVERIFY(_helper->runScript("if obj.createPQCppObject(12).getHeight()==12: obj.setPassed();\n"));
@@ -226,6 +226,14 @@ void PythonQtTestSlotCalling::testCppFactory()
226226
));
227227

228228
QVERIFY(_helper->runScript("if obj.createPQCppObjectNoWrap(12).getH()==12: obj.setPassed();\n"));
229+
230+
231+
// expect to get strict call to double overload
232+
QVERIFY(_helper->runScript("obj.testNoArg()\nfrom PythonQt import PQCppObjectNoWrap\na = PQCppObjectNoWrap(22.2)\nif a.getH()==2: obj.setPassed();\n"));
233+
// expect to get un-strict call to double overload
234+
QVERIFY(_helper->runScript("obj.testNoArg()\nfrom PythonQt import PQCppObjectNoWrap\na = PQCppObjectNoWrap(22)\nif a.getH()==2: obj.setPassed();\n"));
235+
// expect to get strict call to copy constructor overload
236+
QVERIFY(_helper->runScript("obj.testNoArg()\nfrom PythonQt import PQCppObjectNoWrap\na = PQCppObjectNoWrap(PQCppObjectNoWrap())\nprint a.getH()\nif a.getH()==1: obj.setPassed();\n"));
229237
}
230238

231239

tests/PythonQtTests.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,16 @@ class PQCppObjectNoWrap {
224224
class PQCppObjectNoWrapDecorator : public QObject {
225225
Q_OBJECT
226226
public slots:
227+
PQCppObjectNoWrap* new_PQCppObjectNoWrap() {
228+
return new PQCppObjectNoWrap(0);
229+
}
230+
PQCppObjectNoWrap* new_PQCppObjectNoWrap(const PQCppObjectNoWrap& other) {
231+
return new PQCppObjectNoWrap(1);
232+
}
233+
PQCppObjectNoWrap* new_PQCppObjectNoWrap(double value) {
234+
return new PQCppObjectNoWrap(2);
235+
}
236+
227237
int getH(PQCppObjectNoWrap* obj) { return obj->getHeight(); }
228238

229239
};

0 commit comments

Comments
 (0)