test_CORBA_SeqUtil.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- Python -*-
3 
4 #
5 # \file CORBA_SeqUtil.py
6 # \brief test for CORBA sequence utility template functions
7 # \date $Date: 2007/09/03$
8 # \author Shinji Kurihara
9 #
10 # Copyright (C) 2006
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 import CORBA_SeqUtil
25 
26 class FunctorAdd:
27  def __init__(self, lists):
28  self._list = lists
29 
30  def __call__(self, obj):
31  self._list.append(obj)
32 
33 class Property:
34  def __init__(self,id_):
35  self.id =id_
36 
38  def __init__(self, id):
39  self._id = id
40 
41  def __call__(self, prof):
42  return self._id == prof.id
43 
44 
45 
46 class TestCORBA_SeqUtil(unittest.TestCase):
47  def setUp(self):
48  pass
49 
50  def tearDown(self):
51  OpenRTM_aist.Manager.instance().shutdownManager()
52  return
53 
54  def test_for_each(self):
55  list_ = [0,1,2]
56  func_ = FunctorAdd(list_)
57  add_ = [3,4,5,6,7]
58  CORBA_SeqUtil.for_each(add_,func_)
59  self.assertEqual(list_, [0,1,2,3,4,5,6,7])
60 
61 
62  def test_find(self):
63  prof = [Property(100),Property(200),Property(300)]
64  index = CORBA_SeqUtil.find(prof,FunctorFind(300))
65  self.assertEqual(index, 2)
66 
67  index = CORBA_SeqUtil.find(prof,FunctorFind(3000))
68  self.assertEqual(index, -1)
69 
70 
71  def test_push_back(self):
72  list_ = [0,1,2,3]
73  CORBA_SeqUtil.push_back(list_,100)
74  self.assertEqual(list_, [0,1,2,3,100])
75 
76 
78  list1 = [0,1,2]
79  list2 = [3,4,5,6,7]
80  CORBA_SeqUtil.push_back_list(list1,list2)
81  self.assertEqual(list1, [0,1,2,3,4,5,6,7])
82 
83 
84  def test_insert(self):
85  list_ = [0,1,2]
86  CORBA_SeqUtil.insert(list_, "INS", 1)
87  self.assertEqual(list_, [0,"INS",1,2])
88 
89  CORBA_SeqUtil.insert(list_, 10, 100)
90  self.assertEqual(list_, [0,"INS",1,2,10])
91 
92 
93  def test_front(self):
94  list_ = [3,4,5,6]
95  self.assertEqual(CORBA_SeqUtil.front(list_),3)
96 
97 
98  def test_back(self):
99  list_ = [3,4,5,6]
100  self.assertEqual(CORBA_SeqUtil.back(list_),6)
101 
102 
103  def test_erase(self):
104  list_ = [9,8,7,6]
105  CORBA_SeqUtil.erase(list_, 10)
106  self.assertEqual(list_, [9,8,7,6])
107 
108  CORBA_SeqUtil.erase(list_, 1)
109  self.assertEqual(list_, [9,7,6])
110 
111 
112  def test_erase_if(self):
113  prof = [Property(100),Property(200),Property(300)]
114  CORBA_SeqUtil.erase_if(prof,FunctorFind(999))
115  self.assertEqual(len(prof), 3)
116 
117  CORBA_SeqUtil.erase_if(prof,FunctorFind(200))
118  self.assertEqual(len(prof), 2)
119 
120 
121  def test_clear(self):
122  list_ = [0,1,2,3,4,5]
123  CORBA_SeqUtil.clear(list_)
124  self.assertEqual(list_,[])
125 
126 
127  def test_refToVstring(self):
128  pass
129 
130 
131 
132 if __name__ == '__main__':
133  unittest.main()
test_CORBA_SeqUtil.FunctorFind._id
_id
Definition: test_CORBA_SeqUtil.py:39
test_CORBA_SeqUtil.TestCORBA_SeqUtil.test_for_each
def test_for_each(self)
Definition: test_CORBA_SeqUtil.py:54
test_CORBA_SeqUtil.Property.id
id
Definition: test_CORBA_SeqUtil.py:35
test_CORBA_SeqUtil.FunctorAdd.__init__
def __init__(self, lists)
Definition: test_CORBA_SeqUtil.py:27
test_CORBA_SeqUtil.TestCORBA_SeqUtil.test_push_back
def test_push_back(self)
Definition: test_CORBA_SeqUtil.py:71
test_CORBA_SeqUtil.Property.__init__
def __init__(self, id_)
Definition: test_CORBA_SeqUtil.py:34
test_CORBA_SeqUtil.TestCORBA_SeqUtil.test_refToVstring
def test_refToVstring(self)
Definition: test_CORBA_SeqUtil.py:127
test_CORBA_SeqUtil.TestCORBA_SeqUtil.test_back
def test_back(self)
Definition: test_CORBA_SeqUtil.py:98
test_CORBA_SeqUtil.TestCORBA_SeqUtil.test_erase_if
def test_erase_if(self)
Definition: test_CORBA_SeqUtil.py:112
test_CORBA_SeqUtil.FunctorAdd._list
_list
Definition: test_CORBA_SeqUtil.py:28
test_CORBA_SeqUtil.TestCORBA_SeqUtil.test_push_back_list
def test_push_back_list(self)
Definition: test_CORBA_SeqUtil.py:77
test_CORBA_SeqUtil.Property
Definition: test_CORBA_SeqUtil.py:33
test_CORBA_SeqUtil.FunctorFind.__init__
def __init__(self, id)
Definition: test_CORBA_SeqUtil.py:38
test_CORBA_SeqUtil.TestCORBA_SeqUtil.tearDown
def tearDown(self)
Definition: test_CORBA_SeqUtil.py:50
test_CORBA_SeqUtil.FunctorAdd.__call__
def __call__(self, obj)
Definition: test_CORBA_SeqUtil.py:30
test_CORBA_SeqUtil.TestCORBA_SeqUtil.test_insert
def test_insert(self)
Definition: test_CORBA_SeqUtil.py:84
test_CORBA_SeqUtil.FunctorFind.__call__
def __call__(self, prof)
Definition: test_CORBA_SeqUtil.py:41
test_CORBA_SeqUtil.FunctorAdd
Definition: test_CORBA_SeqUtil.py:26
test_CORBA_SeqUtil.FunctorFind
Definition: test_CORBA_SeqUtil.py:37
test_CORBA_SeqUtil.TestCORBA_SeqUtil.setUp
def setUp(self)
Definition: test_CORBA_SeqUtil.py:47
test_CORBA_SeqUtil.TestCORBA_SeqUtil.test_front
def test_front(self)
Definition: test_CORBA_SeqUtil.py:93
test_CORBA_SeqUtil.TestCORBA_SeqUtil.test_clear
def test_clear(self)
Definition: test_CORBA_SeqUtil.py:121
test_CORBA_SeqUtil.TestCORBA_SeqUtil.test_erase
def test_erase(self)
Definition: test_CORBA_SeqUtil.py:103
test_CORBA_SeqUtil.TestCORBA_SeqUtil.test_find
def test_find(self)
Definition: test_CORBA_SeqUtil.py:62
test_CORBA_SeqUtil.TestCORBA_SeqUtil
Definition: test_CORBA_SeqUtil.py:46
OpenRTM_aist.NVUtil.append
def append(dest, src)
Definition: NVUtil.py:386


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Mon Apr 21 2025 02:45:06