3 # Copyright 2004,2007,2008 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_ss (self, src_data, exp_data, op):
34 for s in zip (range (len (src_data)), src_data):
35 src = gr.vector_source_s (s[1])
36 self.tb.connect (src, (op, s[0]))
37 dst = gr.vector_sink_s ()
38 self.tb.connect (op, dst)
40 result_data = dst.data ()
41 self.assertEqual (exp_data, result_data)
43 def help_bb (self, src_data, exp_data, op):
44 for s in zip (range (len (src_data)), src_data):
45 src = gr.vector_source_b (s[1])
46 self.tb.connect (src, (op, s[0]))
47 dst = gr.vector_sink_b ()
48 self.tb.connect (op, dst)
50 result_data = dst.data ()
51 self.assertEqual (exp_data, result_data)
53 def help_ii (self, src_data, exp_data, op):
54 for s in zip (range (len (src_data)), src_data):
55 src = gr.vector_source_i (s[1])
56 self.tb.connect (src, (op, s[0]))
57 dst = gr.vector_sink_i ()
58 self.tb.connect (op, dst)
60 result_data = dst.data ()
61 self.assertEqual (exp_data, result_data)
63 def test_xor_ss (self):
64 src1_data = (1, 2, 3, 0x5004, 0x1150)
65 src2_data = (8, 2, 1 , 0x0508, 0x1105)
66 expected_result = (9, 0, 2, 0x550C, 0x0055)
68 self.help_ss ((src1_data, src2_data),
71 def test_xor_bb (self):
72 src1_data = (1, 2, 3, 4, 0x50)
73 src2_data = (8, 2, 1 , 8, 0x05)
74 expected_result = (9, 0, 2, 0xC, 0x55)
76 self.help_bb ((src1_data, src2_data),
80 def test_xor_ii (self):
81 src1_data = (1, 2, 3, 0x5000004, 0x11000050)
82 src2_data = (8, 2, 1 , 0x0500008, 0x11000005)
83 expected_result = (9, 0, 2, 0x550000C, 0x00000055)
85 self.help_ii ((src1_data, src2_data),
90 if __name__ == '__main__':