test_TimeValue.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -#- Python -#-
3 #
4 # \file test_TimeValue.py
5 # \brief test for TimeValue class
6 # \date $Date: $
7 # \author Shinji Kurihara
8 #
9 # Copyright (C) 2007
10 # Task-intelligence Research Group,
11 # Intelligent Systems Research Institute,
12 # National Institute of
13 # Advanced Industrial Science and Technology (AIST), Japan
14 # All rights reserved.
15 #
16 
17 import sys
18 sys.path.insert(1,"../")
19 
20 import unittest
21 import time
22 
23 from TimeValue import *
24 import OpenRTM_aist
25 
26 class TestTimeValue(unittest.TestCase):
27 
28  def setUp(self):
29  self.tm = TimeValue(usec=1000000)
30 
31 
32  def tearDown(self):
33  OpenRTM_aist.Manager.instance().shutdownManager()
34  pass
35 
36 
37  def test_set_time(self):
38  tm = time.time()
39  ret = self.tm.set_time(tm)
40 
41 
42  def test_toDouble(self):
43  self.test_set_time()
44  print self.tm.toDouble()
45 
46  def test_sec_usec(self):
47  tm = TimeValue(usec=1000000)
48  self.assertEqual(tm.sec(),1)
49  self.assertEqual(tm.usec(),0)
50 
51  def test_normalize(self):
52  tm = TimeValue(sec=0,usec=10000000)
53  tm.normalize()
54  self.assertEqual(tm.sec(),10)
55  self.assertEqual(tm.usec(),0)
56 
57  tm = TimeValue(sec=1,usec=1000000)
58  tm.normalize()
59  self.assertEqual(tm.sec(),2)
60  self.assertEqual(tm.usec(),0)
61 
62  tm = TimeValue(sec=1,usec=-100000)
63  tm.normalize()
64  self.assertEqual(tm.sec(),0)
65  self.assertEqual(tm.usec(),900000)
66 
67  def test__str__(self):
68  self.test_set_time()
69  print self.tm
70 
71 
72 if __name__ == '__main__':
73  unittest.main()


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Mon Feb 28 2022 23:01:07