diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/libsample/privatedtor.h | 3 | ||||
-rwxr-xr-x | tests/samplebinding/protected_test.py | 17 |
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/libsample/privatedtor.h b/tests/libsample/privatedtor.h index 2c206b263..73f7f4d84 100644 --- a/tests/libsample/privatedtor.h +++ b/tests/libsample/privatedtor.h @@ -52,6 +52,9 @@ public: return m_instanciations; } +protected: + int protectedInstanceCalls() { return m_instanciations; } + private: int m_instanciations; diff --git a/tests/samplebinding/protected_test.py b/tests/samplebinding/protected_test.py index efb0bedbf..fa477c42c 100755 --- a/tests/samplebinding/protected_test.py +++ b/tests/samplebinding/protected_test.py @@ -31,6 +31,7 @@ import unittest from sample import ProtectedNonPolymorphic, ProtectedVirtualDestructor from sample import ProtectedPolymorphic, ProtectedPolymorphicDaughter, ProtectedPolymorphicGrandDaughter from sample import ProtectedEnumClass +from sample import PrivateDtor from sample import Point class ExtendedProtectedPolymorphic(ProtectedPolymorphic): @@ -242,6 +243,22 @@ class ProtectedEnumTest(unittest.TestCase): self.assertEqual(obj.callPublicEnumMethod(ProtectedEnumClass.PublicItem1), ProtectedEnumClass.PublicItem0) +class PrivateDtorProtectedMethodTest(unittest.TestCase): + '''Test cases for classes with private destructors and protected methods.''' + + def testProtectedMethod(self): + '''Calls protected method of a class with a private destructor.''' + obj = PrivateDtor.instance() + + self.assertEqual(type(obj), PrivateDtor) + self.assertEqual(obj.instanceCalls(), 1) + self.assertEqual(obj.instanceCalls(), obj.protectedInstanceCalls()) + + obj = PrivateDtor.instance() + self.assertEqual(obj.instanceCalls(), 2) + self.assertEqual(obj.instanceCalls(), obj.protectedInstanceCalls()) + + if __name__ == '__main__': unittest.main() |