Skip to content

Commit 6c4b08e

Browse files
committed
[Python] Unit test for overriding C++ function returning unsigned int
This covers #16197, and having a unit test is a prerequisite for merging the fix upstream in CPyCppyy.
1 parent 1ea62ff commit 6c4b08e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

bindings/pyroot/cppyy/cppyy/test/test_crossinheritance.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,6 +1819,25 @@ def __init__(self, x, y, z):
18191819
assert derived.s == "Hello"
18201820
assert derived.t == "World"
18211821

1822+
def test39_returning_multi_keyword_types(self):
1823+
"""Supporting dispatcher for functions return multi-keyword types like `unsigned int`"""
1824+
1825+
import cppyy
1826+
1827+
cppyy.cppdef("""
1828+
class MyUIntBaseClass {
1829+
public:
1830+
virtual ~MyUIntBaseClass() = default;
1831+
virtual unsigned int give_unsigned_int() const = 0;
1832+
};
1833+
1834+
""")
1835+
1836+
# Compiling the dispatcher for the overridden member function used to
1837+
# fail because of the `unsigned int` type, whose name has two keywords.
1838+
class MyUIntDerivedClass( ROOT.MyUIntBaseClass ):
1839+
def give_unsigned_int( self ):
1840+
return 1
18221841

18231842
if __name__ == "__main__":
18241843
exit(pytest.main(args=['-ra', __file__]))

0 commit comments

Comments
 (0)