test_vector.py
Go to the documentation of this file.
1 from test_msg import debug, info, error, warning
2 import traceback,sys
3 from test_import import test_import
5 from ROOT import geoalgo
6 
7 def test_vector():
8 
9  try:
10  debug('Testing default constructor')
11  k=geoalgo.Vector(5)
12  if not k.size() == 5: raise Exception
13 
14  debug('Testing copy ctor')
15  j=geoalgo.Vector(k)
16  for x in xrange(k.size()):
17  if not k[x] == j[x]: raise Exception
18 
19  for x in xrange(5):
20  k[x] = 1
21  j[x] = 1
22  debug('Testing multiplication')
23  k *= 2
24  for x in xrange(5):
25  if not k[x] == 2: raise Exception
26 
27  debug('Testing addition')
28  k += j
29  for x in xrange(5):
30  if not k[x] == 3: raise Exception
31 
32  debug('Testing division')
33  k /= 3.
34  for x in xrange(5):
35  if not k[x] == 1.: raise Exception
36 
37  debug('Testing dot product')
38  if not k * j == 5: raise Exception
39 
40  debug('Testing length')
41  for x in xrange(5):
42  k[x] = 0
43  k[0] = 1
44  if not k.Length() == 1: raise Exception
45 
46  debug('Testing compatibility check')
47  error=False
48  try:
49  k.compat(j)
50  except Exception:
51  pass
52  if error: raise Exception
53 
54  except Exception:
55  error('geoalgo::Vector unit test failed.')
56  print traceback.format_exception(*sys.exc_info())[2]
57  return 1
58 
59  info('geoalgo::Vector unit test complete.')
60  return 0
61 
62 if __name__ == '__main__':
63  test_vector()
64 
def test_vector()
Definition: test_vector.py:7
error
Definition: include.cc:26