From d402db5680452241a5b85f7a4fd7db9bcc9ddbb8 Mon Sep 17 00:00:00 2001 From: Lauro Neto Date: Thu, 29 Apr 2010 18:41:50 -0300 Subject: Adding test for #212 - Overloads with enums --- tests/libsample/objecttype.cpp | 7 +++++++ tests/libsample/objecttype.h | 3 +++ tests/samplebinding/enum_test.py | 14 +++++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/libsample/objecttype.cpp b/tests/libsample/objecttype.cpp index d5bdace14..5ff3c2f19 100644 --- a/tests/libsample/objecttype.cpp +++ b/tests/libsample/objecttype.cpp @@ -226,3 +226,10 @@ unsigned int objectTypeHash(const ObjectType* objectType) return reinterpret_cast(objectType); } +unsigned char ObjectType::callWithEnum(const Str& prefix, Event::EventType type, unsigned char value){ + return value*value; +} + +unsigned char ObjectType::callWithEnum(const Str& prefix, unsigned char value) { + return value; +} diff --git a/tests/libsample/objecttype.h b/tests/libsample/objecttype.h index 0515ecc98..8b9eda117 100644 --- a/tests/libsample/objecttype.h +++ b/tests/libsample/objecttype.h @@ -97,6 +97,9 @@ public: // This method should be reimplemented by ObjectTypeLayout. virtual bool isLayoutType() { return false; } + unsigned char callWithEnum(const Str& prefix, Event::EventType type, unsigned char value=80); + unsigned char callWithEnum(const Str& prefix, unsigned char value=0); + private: ObjectType(const ObjectType&); ObjectType& operator=(const ObjectType&); diff --git a/tests/samplebinding/enum_test.py b/tests/samplebinding/enum_test.py index a6c2e0421..0d4be2293 100755 --- a/tests/samplebinding/enum_test.py +++ b/tests/samplebinding/enum_test.py @@ -28,7 +28,7 @@ import unittest -from sample import SampleNamespace +from sample import SampleNamespace, ObjectType, Event class EnumTest(unittest.TestCase): '''Test case for Python representation of C++ enums.''' @@ -66,6 +66,18 @@ class EnumTest(unittest.TestCase): '''Calling the constructor of non-extensible enum with a string.''' self.assertRaises(TypeError, SampleNamespace.InValue, '1') + +class EnumOverloadTest(unittest.TestCase): + '''Test case for overloads involving enums''' + + def testWithInt(self): + '''Overload with Enums and ints with default value''' + o = ObjectType() + + self.assertEqual(o.callWithEnum('', Event.ANY_EVENT, 9), 81) + self.assertEqual(o.callWithEnum('', 9), 9) + + if __name__ == '__main__': unittest.main() -- cgit v1.2.3