diff options
-rw-r--r-- | tests/libsample/overload.h | 17 | ||||
-rw-r--r-- | tests/samplebinding/overload_test.py | 30 |
2 files changed, 47 insertions, 0 deletions
diff --git a/tests/libsample/overload.h b/tests/libsample/overload.h index c170be4a4..a0682fe18 100644 --- a/tests/libsample/overload.h +++ b/tests/libsample/overload.h @@ -89,6 +89,23 @@ public: FunctionEnum drawText(const RectF& a0, const Str& a1, const Echo& a2 = Echo()) { return Function4; } FunctionEnum drawText(int a0, int a1, const Str& a2) { return Function5; } FunctionEnum drawText(int a0, int a1, int a2, int a3, int a4, const Str& a5) { return Function6; } + + // A variant of the one similar to QPainter::drawText(...) + FunctionEnum drawText2(const Point& a0, const Str& a1) { return Function0; } + FunctionEnum drawText2(const PointF& a0, const Str& a1) { return Function1; } + FunctionEnum drawText2(const Rect& a0, int a1, const Str& a2) { return Function2; } + FunctionEnum drawText2(const RectF& a0, int a1, const Str& a2) { return Function3; } + FunctionEnum drawText2(const RectF& a0, const Str& a1, const Echo& a2 = Echo()) { return Function4; } + FunctionEnum drawText2(int a0, int a1, const Str& a2) { return Function5; } + FunctionEnum drawText2(int a0, int a1, int a2, int a3 = 0, int a4 = 0, const Str& a5 = Str()) { return Function6; } + + // A simpler variant of the one similar to QPainter::drawText(...) + FunctionEnum drawText3(const Str& a0, const Str& a1, const Str& a2) { return Function0; } + FunctionEnum drawText3(int a0, int a1, int a2, int a3, int a4) { return Function1; } + + // Another simpler variant of the one similar to QPainter::drawText(...) + FunctionEnum drawText4(int a0, int a1, int a2) { return Function0; } + FunctionEnum drawText4(int a0, int a1, int a2, int a3, int a4) { return Function1; } }; class LIBSAMPLE_API Overload2 : public Overload diff --git a/tests/samplebinding/overload_test.py b/tests/samplebinding/overload_test.py index 14a30c88b..e165ef854 100644 --- a/tests/samplebinding/overload_test.py +++ b/tests/samplebinding/overload_test.py @@ -116,6 +116,36 @@ class OverloadTest(unittest.TestCase): self.assertEqual(overload.drawText(1, 2, 3, 4, 5, Str()), Overload.Function6) self.assertEqual(overload.drawText(1, 2, 3, 4, 5, ''), Overload.Function6) + def testDrawText2IntIntIntIntStr(self): + overload = Overload() + self.assertEqual(overload.drawText2(1, 2, 3, 4, 5, Str()), Overload.Function6) + self.assertEqual(overload.drawText2(1, 2, 3, 4, 5, ''), Overload.Function6) + self.assertEqual(overload.drawText2(1, 2, 3, 4, 5), Overload.Function6) + self.assertEqual(overload.drawText2(1, 2, 3, 4), Overload.Function6) + self.assertEqual(overload.drawText2(1, 2, 3), Overload.Function6) + + def testDrawText3(self): + overload = Overload() + self.assertEqual(overload.drawText3(Str(), Str(), Str()), Overload.Function0) + self.assertEqual(overload.drawText3('', '', ''), Overload.Function0) + self.assertEqual(overload.drawText3(1, 2, 3, 4, 5), Overload.Function1) + self.assertEqual(overload.drawText3(1, 2, 3, 4, 5), Overload.Function1) + + def testDrawText3Exception(self): + overload = Overload() + # NOTE: Using 'try' because assertRaisesRegexp is not available. + # to check the error text. + try: + overload.drawText3(Str(), Str(), Str(), 4, 5) + except Exception as err: + self.assertEqual(type(err), TypeError) + self.assertTrue('called with wrong argument types:' in str(err)) + + def testDrawText4(self): + overload = Overload() + self.assertEqual(overload.drawText4(1, 2, 3), Overload.Function0) + self.assertEqual(overload.drawText4(1, 2, 3, 4, 5), Overload.Function1) + if __name__ == '__main__': unittest.main() |