3 # Copyright 2006,2007 Free Software Foundation, Inc.
5 # This file is part of GNU Radio
7 # GNU Radio is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3, or (at your option)
12 # GNU Radio is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Radio; see the file COPYING. If not, write to
19 # the Free Software Foundation, Inc., 51 Franklin Street,
20 # Boston, MA 02110-1301, USA.
23 from gnuradio import gr, gr_unittest
25 class my_add2_dd(gr.feval_dd):
29 class my_add2_ll(gr.feval_ll):
33 class my_add2_cc(gr.feval_cc):
37 class my_feval(gr.feval):
39 gr.feval.__init__(self)
44 class test_feval(gr_unittest.TestCase):
48 src_data = (0.0, 1.0, 2.0, 3.0, 4.0)
49 expected_result = (2.0, 3.0, 4.0, 5.0, 6.0)
50 # this is all in python...
51 actual_result = tuple([f.eval(x) for x in src_data])
52 self.assertEqual(expected_result, actual_result)
56 src_data = (0.0, 1.0, 2.0, 3.0, 4.0)
57 expected_result = (2.0, 3.0, 4.0, 5.0, 6.0)
58 # this is python -> C++ -> python and back again...
59 actual_result = tuple([gr.feval_dd_example(f, x) for x in src_data])
60 self.assertEqual(expected_result, actual_result)
65 src_data = (0, 1, 2, 3, 4)
66 expected_result = (2, 3, 4, 5, 6)
67 # this is all in python...
68 actual_result = tuple([f.eval(x) for x in src_data])
69 self.assertEqual(expected_result, actual_result)
73 src_data = (0, 1, 2, 3, 4)
74 expected_result = (2, 3, 4, 5, 6)
75 # this is python -> C++ -> python and back again...
76 actual_result = tuple([gr.feval_ll_example(f, x) for x in src_data])
77 self.assertEqual(expected_result, actual_result)
82 src_data = (0+1j, 2+3j, 4+5j, 6+7j)
83 expected_result = (2-1j, 4+1j, 6+3j, 8+5j)
84 # this is all in python...
85 actual_result = tuple([f.eval(x) for x in src_data])
86 self.assertEqual(expected_result, actual_result)
90 src_data = (0+1j, 2+3j, 4+5j, 6+7j)
91 expected_result = (2-1j, 4+1j, 6+3j, 8+5j)
92 # this is python -> C++ -> python and back again...
93 actual_result = tuple([gr.feval_cc_example(f, x) for x in src_data])
94 self.assertEqual(expected_result, actual_result)
96 def test_void_1(self):
97 # this is all in python
100 self.assertEqual(True, f.fired)
102 def test_void_2(self):
103 # this is python -> C++ -> python and back again
106 self.assertEqual(True, f.fired)
109 if __name__ == '__main__':