3 # Copyright 2004,2005,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 test_head (gr_unittest.TestCase):
28 self.tb = gr.top_block ()
33 def help_ii (self, src_data, exp_data, op):
34 for s in zip (range (len (src_data)), src_data):
35 src = gr.vector_source_i (s[1])
36 self.tb.connect (src, (op, s[0]))
37 dst = gr.vector_sink_i ()
38 self.tb.connect (op, dst)
40 result_data = dst.data ()
41 self.assertEqual (exp_data, result_data)
43 def help_ff (self, src_data, exp_data, op):
44 for s in zip (range (len (src_data)), src_data):
45 src = gr.vector_source_f (s[1])
46 self.tb.connect (src, (op, s[0]))
47 dst = gr.vector_sink_f ()
48 self.tb.connect (op, dst)
50 result_data = dst.data ()
51 self.assertEqual (exp_data, result_data)
53 def help_cc (self, src_data, exp_data, op):
54 for s in zip (range (len (src_data)), src_data):
55 src = gr.vector_source_c (s[1])
56 self.tb.connect (src, (op, s[0]))
57 dst = gr.vector_sink_c ()
58 self.tb.connect (op, dst)
60 result_data = dst.data ()
61 self.assertEqual (exp_data, result_data)
63 def test_unmute_ii(self):
64 src_data = (1, 2, 3, 4, 5)
65 expected_result = (1, 2, 3, 4, 5)
66 op = gr.mute_ii (False)
67 self.help_ii ((src_data,), expected_result, op)
69 def test_mute_ii(self):
70 src_data = (1, 2, 3, 4, 5)
71 expected_result = (0, 0, 0, 0, 0)
72 op = gr.mute_ii (True)
73 self.help_ii ((src_data,), expected_result, op)
75 def test_unmute_cc (self):
76 src_data = (1+5j, 2+5j, 3+5j, 4+5j, 5+5j)
77 expected_result = (1+5j, 2+5j, 3+5j, 4+5j, 5+5j)
78 op = gr.mute_cc (False)
79 self.help_cc ((src_data,), expected_result, op)
81 def test_unmute_cc (self):
82 src_data = (1+5j, 2+5j, 3+5j, 4+5j, 5+5j)
83 expected_result = (0+0j, 0+0j, 0+0j, 0+0j, 0+0j)
84 op = gr.mute_cc (True)
85 self.help_cc ((src_data,), expected_result, op)
88 if __name__ == '__main__':