aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/libsample/protected.h9
-rw-r--r--tests/samplebinding/CMakeLists.txt1
-rwxr-xr-xtests/samplebinding/protected_test.py13
-rw-r--r--tests/samplebinding/typesystem_sample.xml2
4 files changed, 24 insertions, 1 deletions
diff --git a/tests/libsample/protected.h b/tests/libsample/protected.h
index d8d55a40f..8ba4914f8 100644
--- a/tests/libsample/protected.h
+++ b/tests/libsample/protected.h
@@ -126,5 +126,14 @@ protected:
virtual PublicEnum publicEnumMethod(PublicEnum in) { return in; }
};
+
+class LIBSAMPLE_API ProtectedProperty
+{
+public:
+ ProtectedProperty() : protectedProperty(0) {}
+protected:
+ int protectedProperty;
+};
+
#endif // PROTECTED_H
diff --git a/tests/samplebinding/CMakeLists.txt b/tests/samplebinding/CMakeLists.txt
index 8775802bf..8848212d1 100644
--- a/tests/samplebinding/CMakeLists.txt
+++ b/tests/samplebinding/CMakeLists.txt
@@ -52,6 +52,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/sample/protectednonpolymorphic_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/protectedpolymorphic_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/protectedpolymorphicdaughter_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/protectedpolymorphicgranddaughter_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/protectedproperty_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/protectedvirtualdestructor_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/reference_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/sample_module_wrapper.cpp
diff --git a/tests/samplebinding/protected_test.py b/tests/samplebinding/protected_test.py
index fa477c42c..356df1f7c 100755
--- a/tests/samplebinding/protected_test.py
+++ b/tests/samplebinding/protected_test.py
@@ -30,7 +30,7 @@ import unittest
from sample import ProtectedNonPolymorphic, ProtectedVirtualDestructor
from sample import ProtectedPolymorphic, ProtectedPolymorphicDaughter, ProtectedPolymorphicGrandDaughter
-from sample import ProtectedEnumClass
+from sample import ProtectedProperty, ProtectedEnumClass
from sample import PrivateDtor
from sample import Point
@@ -243,6 +243,17 @@ class ProtectedEnumTest(unittest.TestCase):
self.assertEqual(obj.callPublicEnumMethod(ProtectedEnumClass.PublicItem1), ProtectedEnumClass.PublicItem0)
+class ProtectedPropertyTest(unittest.TestCase):
+ '''Test cases for a class with a protected property (or field in C++).'''
+
+ def testProtectedProperty(self):
+ '''Writes and reads a protected property.'''
+ obj = ProtectedProperty()
+
+ obj.protectedProperty = 3
+ self.assertEqual(obj.protectedProperty, 3)
+
+
class PrivateDtorProtectedMethodTest(unittest.TestCase):
'''Test cases for classes with private destructors and protected methods.'''
diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml
index e53486fcc..a4e941079 100644
--- a/tests/samplebinding/typesystem_sample.xml
+++ b/tests/samplebinding/typesystem_sample.xml
@@ -284,6 +284,8 @@
<enum-type name="ProtectedEnumClass::ProtectedEnum" />
<enum-type name="ProtectedEnumClass::PublicEnum" />
+ <value-type name="ProtectedProperty" />
+
<template name="boolptr_at_end_fix_beginning">
bool __ok__;
%PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](