Skip to content
Snippets Groups Projects
Commit c697083e authored by Enric Tejedor Saavedra's avatar Enric Tejedor Saavedra
Browse files

[Exp PyROOT] Test __getitem__ pythonisation of TVector3

parent 95e0c62a
No related branches found
No related tags found
No related merge requests found
......@@ -52,6 +52,7 @@ ROOT_ADD_PYUNITTEST(pyroot_pyz_tvectort_getitem tvectort_getitem.py)
# TVector3 pythonisations
ROOT_ADD_PYUNITTEST(pyroot_pyz_tvector3_len tvector3_len.py)
ROOT_ADD_PYUNITTEST(pyroot_pyz_tvector3_getitem tvector3_getitem.py)
# TString pythonisations
ROOT_ADD_PYUNITTEST(pyroot_pyz_tstring_len tstring_len.py)
......
import unittest
import ROOT
class TVector3GetItem(unittest.TestCase):
"""
Test for the pythonization that allows to: (i) get an item of a
TVector3 with boundary check for the index and (ii) iterate over
a TVector3.
"""
# Tests
def test_boundary_check(self):
v = ROOT.TVector3(1., 2., 3.)
# In range
self.assertEqual(v[0], v[0])
# Out of range
with self.assertRaises(IndexError):
v[-1]
# Out of range
with self.assertRaises(IndexError):
v[3]
def test_iterable(self):
v = ROOT.TVector3(1., 2., 3.)
self.assertEquals(list(v), [1., 2., 3.])
if __name__ == '__main__':
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment