test_TimeValue.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -#- Python -#-
00003 #
00004 # \file test_TimeValue.py
00005 # \brief test for TimeValue class
00006 # \date $Date: $
00007 # \author Shinji Kurihara
00008 #
00009 # Copyright (C) 2007
00010 #     Task-intelligence Research Group,
00011 #     Intelligent Systems Research Institute,
00012 #     National Institute of
00013 #         Advanced Industrial Science and Technology (AIST), Japan
00014 #     All rights reserved.
00015 #
00016 
00017 import sys
00018 sys.path.insert(1,"../")
00019 
00020 import unittest
00021 import time
00022 
00023 from TimeValue import *
00024 import OpenRTM_aist
00025 
00026 class TestTimeValue(unittest.TestCase):
00027   
00028   def setUp(self):
00029     self.tm = TimeValue(usec=1000000)
00030 
00031 
00032   def tearDown(self):
00033     OpenRTM_aist.Manager.instance().shutdownManager()
00034     pass
00035 
00036 
00037   def test_set_time(self):
00038     tm = time.time()
00039     ret = self.tm.set_time(tm)
00040 
00041 
00042   def test_toDouble(self):
00043     self.test_set_time()
00044     print  self.tm.toDouble()
00045 
00046   def test_sec_usec(self):
00047     tm = TimeValue(usec=1000000)
00048     self.assertEqual(tm.sec(),1)
00049     self.assertEqual(tm.usec(),0)
00050 
00051   def test_normalize(self):
00052     tm = TimeValue(sec=0,usec=10000000)
00053     tm.normalize()
00054     self.assertEqual(tm.sec(),10)
00055     self.assertEqual(tm.usec(),0)
00056 
00057     tm = TimeValue(sec=1,usec=1000000)
00058     tm.normalize()
00059     self.assertEqual(tm.sec(),2)
00060     self.assertEqual(tm.usec(),0)
00061 
00062     tm = TimeValue(sec=1,usec=-100000)
00063     tm.normalize()
00064     self.assertEqual(tm.sec(),0)
00065     self.assertEqual(tm.usec(),900000)
00066 
00067   def test__str__(self):
00068     self.test_set_time()
00069     print self.tm
00070   
00071 ############### test #################
00072 if __name__ == '__main__':
00073         unittest.main()


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Thu Aug 27 2015 14:17:28