summaryrefslogtreecommitdiffstats
path: root/tests/samplebinding/protected_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/samplebinding/protected_test.py')
-rwxr-xr-xtests/samplebinding/protected_test.py38
1 files changed, 37 insertions, 1 deletions
diff --git a/tests/samplebinding/protected_test.py b/tests/samplebinding/protected_test.py
index dd4175d8..6a5f732c 100755
--- a/tests/samplebinding/protected_test.py
+++ b/tests/samplebinding/protected_test.py
@@ -26,11 +26,11 @@
'''Test cases for protected methods.'''
-import os
import unittest
from sample import ProtectedNonPolymorphic, ProtectedVirtualDestructor
from sample import ProtectedPolymorphic, ProtectedPolymorphicDaughter, ProtectedPolymorphicGrandDaughter
+from sample import ProtectedEnumClass
from sample import Point
class ExtendedProtectedPolymorphic(ProtectedPolymorphic):
@@ -178,6 +178,42 @@ class ProtectedVirtualDtorTest(unittest.TestCase):
self.assertEqual(ExtendedProtectedVirtualDestructor.dtorCalled(), dtor_called + i)
+class ExtendedProtectedEnumClass(ProtectedEnumClass):
+ def __init__(self):
+ ProtectedEnumClass.__init__(self)
+ def protectedEnumMethod(self, value):
+ if value == ProtectedEnumClass.ProtectedItem0:
+ return ProtectedEnumClass.ProtectedItem1
+ return ProtectedEnumClass.ProtectedItem0
+
+class ProtectedEnumTest(unittest.TestCase):
+ '''Test cases for protected enum.'''
+
+ def testProtectedEnum(self):
+ '''Original protected method is being called.'''
+ obj = ProtectedEnumClass()
+
+ self.assertEqual(type(ProtectedEnumClass.ProtectedItem0), ProtectedEnumClass.ProtectedEnum)
+
+ self.assertEqual(obj.protectedEnumMethod(ProtectedEnumClass.ProtectedItem0), ProtectedEnumClass.ProtectedItem0)
+ self.assertEqual(obj.protectedEnumMethod(ProtectedEnumClass.ProtectedItem1), ProtectedEnumClass.ProtectedItem1)
+
+ self.assertEqual(obj.callProtectedEnumMethod(ProtectedEnumClass.ProtectedItem0), ProtectedEnumClass.ProtectedItem0)
+ self.assertEqual(obj.callProtectedEnumMethod(ProtectedEnumClass.ProtectedItem1), ProtectedEnumClass.ProtectedItem1)
+
+ def testProtectedEnumWithMethodOverride(self):
+ '''Overridden protected method is being called.'''
+ obj = ExtendedProtectedEnumClass()
+
+ self.assertEqual(obj.protectedEnumMethod(ProtectedEnumClass.ProtectedItem0), ProtectedEnumClass.ProtectedItem1)
+ self.assertEqual(obj.protectedEnumMethod(ProtectedEnumClass.ProtectedItem1), ProtectedEnumClass.ProtectedItem0)
+
+ self.assertEqual(ProtectedEnumClass.protectedEnumMethod(obj, ProtectedEnumClass.ProtectedItem0), ProtectedEnumClass.ProtectedItem0)
+ self.assertEqual(ProtectedEnumClass.protectedEnumMethod(obj, ProtectedEnumClass.ProtectedItem1), ProtectedEnumClass.ProtectedItem1)
+
+ self.assertEqual(obj.callProtectedEnumMethod(ProtectedEnumClass.ProtectedItem0), ProtectedEnumClass.ProtectedItem1)
+ self.assertEqual(obj.callProtectedEnumMethod(ProtectedEnumClass.ProtectedItem1), ProtectedEnumClass.ProtectedItem0)
+
if __name__ == '__main__':
unittest.main()