Skip to content

Commit dee2fb7

Browse files
committed
[python] Add regression test for #11854
1 parent cda3147 commit dee2fb7

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

bindings/pyroot/pythonizations/test/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,5 @@ if(NOT MSVC OR CMAKE_SIZEOF_VOID_P EQUAL 8 OR win_broken_tests)
191191
# https://github.com/root-project/root/issues/9809
192192
ROOT_ADD_PYUNITTEST(pyroot_array_numpy_views array_conversions.py PYTHON_DEPS numpy)
193193
endif()
194+
195+
ROOT_ADD_PYUNITTEST(gh_11854 gh_11854.py)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import unittest
2+
3+
import ROOT
4+
5+
6+
class GH11854(unittest.TestCase):
7+
"""Regression test for https://github.com/root-project/root/issues/11854"""
8+
9+
def test_gh_11854(self):
10+
11+
ROOT.gInterpreter.Declare(r"""
12+
#ifndef GH11854_HELPER
13+
#define GH11854_HELPER
14+
15+
template <typename T>
16+
struct GH11854Helper {
17+
18+
std::size_t operator() () const {
19+
const std::size_t res = 0;
20+
res = T{0, 0}.size();
21+
return res;
22+
}
23+
24+
};
25+
26+
template <typename H>
27+
std::size_t call_gh11854_helper(const H &helper) {
28+
return helper();
29+
}
30+
31+
#endif // GH11854_HELPER
32+
""")
33+
34+
helper = ROOT.GH11854Helper[ROOT.std.vector["double"]]()
35+
with self.assertRaisesRegex(TypeError, "cannot assign to variable 'res' with const-qualified type 'const std::size_t'"):
36+
ROOT.call_gh11854_helper(helper)
37+
38+
39+
if __name__ == '__main__':
40+
unittest.main()

0 commit comments

Comments
 (0)