Skip to content

Commit

Permalink
Add regression test for root-project#17497
Browse files Browse the repository at this point in the history
  • Loading branch information
vepadulano committed Jan 27, 2025
1 parent f6a403c commit 195d6d9
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions bindings/pyroot/pythonizations/test/string_view.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os
import unittest
import ROOT
import cppyy
import platform


class StringView(unittest.TestCase):
Expand Down Expand Up @@ -28,6 +30,25 @@ def test_rdataframe(self):
str(df), "A data frame built on top of the tree dataset.")
os.remove(filename)

def test_17497(self):
"""Regression test for https://github.com/root-project/root/issues/17497"""
# See https://github.com/root-project/root/issues/7541 and
# https://bugs.llvm.org/show_bug.cgi?id=49692 :
# llvm JIT fails to catch exceptions on MacOS ARM, so we disable their testing
if platform.processor() != "arm" or platform.mac_ver()[0] == '':
ROOT.gInterpreter.Declare(r"""
void fun(std::string_view, std::string_view){throw std::runtime_error("std::string_view overload");}
void fun(std::string_view, const std::vector<std::string> &){throw std::runtime_error("const std::vector<std::string> & overload");}
""")
with self.assertRaises(cppyy.gbl.std.runtime_error):
ROOT.fun("", [])
with self.assertRaises(cppyy.gbl.std.runtime_error):
ROOT.fun(ROOT.std.string_view("hello world"),
ROOT.std.vector[ROOT.std.string]())
with self.assertRaises(cppyy.gbl.std.runtime_error):
ROOT.fun("", ROOT.std.vector[ROOT.std.string]())
with self.assertRaises(cppyy.gbl.std.runtime_error):
ROOT.fun(ROOT.std.string_view("hello world"), [])

if __name__ == '__main__':
unittest.main()

0 comments on commit 195d6d9

Please sign in to comment.