test_BufferBase.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- Python -*-
00003 
00004 # \file test_BufferBase.py
00005 # \brief Buffer abstract class
00006 # \date $Date: 2007/09/12 $
00007 # \author Shinji Kurihara
00008 #
00009 # Copyright (C) 2006
00010 #     Noriaki Ando
00011 #     Task-intelligence Research Group,
00012 #     Intelligent Systems Research Institute,
00013 #     National Institute of
00014 #         Advanced Industrial Science and Technology (AIST), Japan
00015 #     All rights reserved.
00016 #
00017   
00018 import sys
00019 sys.path.insert(1,"../")
00020 
00021 import unittest
00022 import OpenRTM_aist
00023 
00024 from BufferBase import *
00025 
00026 class TestNullBuffer(unittest.TestCase):
00027   def setUp(self):
00028     self.nb = NullBuffer()
00029     self.nb.init(100)
00030 
00031   def tearDown(self):
00032     OpenRTM_aist.Manager.instance().shutdownManager()
00033     return
00034 
00035   def test_length(self):
00036     self.assertEqual(self.nb.length(),1)
00037 
00038 
00039   def test_write(self):
00040     data=[0]
00041     # test long
00042     self.assertEqual(self.nb.write(10000), True)
00043     self.nb.read(data)
00044     self.assertEqual(data[0], 10000)
00045 
00046     # test float
00047     self.assertEqual(self.nb.write(1.2345), True)
00048     self.nb.read(data)
00049     self.assertEqual(data[0], 1.2345)
00050 
00051     # test string
00052     self.assertEqual(self.nb.write("test"), True)
00053     self.nb.read(data)
00054     self.assertEqual(data[0], "test")
00055     
00056     # test list
00057     self.assertEqual(self.nb.write([1,2,3]), True)
00058     self.nb.read(data)
00059     self.assertEqual(data[0], [1,2,3])
00060 
00061 
00062   def test_isEmpty(self):
00063     self.assertEqual(self.nb.isEmpty(),False)
00064 
00065 
00066   def test_isNew(self):
00067     data=[0]
00068     self.assertEqual(self.nb.isNew(),False)
00069     self.nb.read(data)
00070     self.assertEqual(self.nb.isNew(),False)
00071     self.assertEqual(self.nb.write(10000), True)
00072     self.assertEqual(self.nb.isNew(),True)
00073 
00074 
00075 ############### test #################
00076 if __name__ == '__main__':
00077         unittest.main()


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