From 2e28b78885ae8826558c4469abd4213c93d33175 2009-05-16 09:02:42 From: florianlink Date: 2009-05-16 09:02:42 Subject: [PATCH] added test for overload of copy constructor and double constructor decorators git-svn-id: svn://svn.code.sf.net/p/pythonqt/code/trunk@78 ea8d5007-eb21-0410-b261-ccb3ea6e24a9 --- diff --git a/tests/PythonQtTests.cpp b/tests/PythonQtTests.cpp index 8543faf..66806e3 100644 --- a/tests/PythonQtTests.cpp +++ b/tests/PythonQtTests.cpp @@ -213,7 +213,7 @@ void PythonQtTestSlotCalling::testCppFactory() { PythonQtTestCppFactory* f = new PythonQtTestCppFactory; PythonQt::self()->addInstanceDecorators(new PQCppObjectDecorator); - PythonQt::self()->addInstanceDecorators(new PQCppObjectNoWrapDecorator); + PythonQt::self()->addDecorators(new PQCppObjectNoWrapDecorator); PythonQt::self()->addWrapperFactory(f); QVERIFY(_helper->runScript("if obj.createPQCppObject(12).getHeight()==12: obj.setPassed();\n")); @@ -226,6 +226,14 @@ void PythonQtTestSlotCalling::testCppFactory() )); QVERIFY(_helper->runScript("if obj.createPQCppObjectNoWrap(12).getH()==12: obj.setPassed();\n")); + + + // expect to get strict call to double overload + QVERIFY(_helper->runScript("obj.testNoArg()\nfrom PythonQt import PQCppObjectNoWrap\na = PQCppObjectNoWrap(22.2)\nif a.getH()==2: obj.setPassed();\n")); + // expect to get un-strict call to double overload + QVERIFY(_helper->runScript("obj.testNoArg()\nfrom PythonQt import PQCppObjectNoWrap\na = PQCppObjectNoWrap(22)\nif a.getH()==2: obj.setPassed();\n")); + // expect to get strict call to copy constructor overload + QVERIFY(_helper->runScript("obj.testNoArg()\nfrom PythonQt import PQCppObjectNoWrap\na = PQCppObjectNoWrap(PQCppObjectNoWrap())\nprint a.getH()\nif a.getH()==1: obj.setPassed();\n")); } diff --git a/tests/PythonQtTests.h b/tests/PythonQtTests.h index f163f77..d351eb3 100644 --- a/tests/PythonQtTests.h +++ b/tests/PythonQtTests.h @@ -224,6 +224,16 @@ private: class PQCppObjectNoWrapDecorator : public QObject { Q_OBJECT public slots: + PQCppObjectNoWrap* new_PQCppObjectNoWrap() { + return new PQCppObjectNoWrap(0); + } + PQCppObjectNoWrap* new_PQCppObjectNoWrap(const PQCppObjectNoWrap& other) { + return new PQCppObjectNoWrap(1); + } + PQCppObjectNoWrap* new_PQCppObjectNoWrap(double value) { + return new PQCppObjectNoWrap(2); + } + int getH(PQCppObjectNoWrap* obj) { return obj->getHeight(); } };