test_BufferBase.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- Python -*-
3 
4 # \file test_BufferBase.py
5 # \brief Buffer abstract class
6 # \date $Date: 2007/09/12 $
7 # \author Shinji Kurihara
8 #
9 # Copyright (C) 2006
10 # Noriaki Ando
11 # Task-intelligence Research Group,
12 # Intelligent Systems Research Institute,
13 # National Institute of
14 # Advanced Industrial Science and Technology (AIST), Japan
15 # All rights reserved.
16 #
17 
18 import sys
19 sys.path.insert(1,"../")
20 
21 import unittest
22 import OpenRTM_aist
23 
24 from BufferBase import *
25 
26 class TestNullBuffer(unittest.TestCase):
27  def setUp(self):
28  self.nb = NullBuffer()
29  self.nb.init(100)
30 
31  def tearDown(self):
32  OpenRTM_aist.Manager.instance().shutdownManager()
33  return
34 
35  def test_length(self):
36  self.assertEqual(self.nb.length(),1)
37 
38 
39  def test_write(self):
40  data=[0]
41  # test long
42  self.assertEqual(self.nb.write(10000), True)
43  self.nb.read(data)
44  self.assertEqual(data[0], 10000)
45 
46  # test float
47  self.assertEqual(self.nb.write(1.2345), True)
48  self.nb.read(data)
49  self.assertEqual(data[0], 1.2345)
50 
51  # test string
52  self.assertEqual(self.nb.write("test"), True)
53  self.nb.read(data)
54  self.assertEqual(data[0], "test")
55 
56  # test list
57  self.assertEqual(self.nb.write([1,2,3]), True)
58  self.nb.read(data)
59  self.assertEqual(data[0], [1,2,3])
60 
61 
62  def test_isEmpty(self):
63  self.assertEqual(self.nb.isEmpty(),False)
64 
65 
66  def test_isNew(self):
67  data=[0]
68  self.assertEqual(self.nb.isNew(),False)
69  self.nb.read(data)
70  self.assertEqual(self.nb.isNew(),False)
71  self.assertEqual(self.nb.write(10000), True)
72  self.assertEqual(self.nb.isNew(),True)
73 
74 
75 ############### test #################
76 if __name__ == '__main__':
77  unittest.main()


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Thu Jun 6 2019 19:11:34