Statistics
| Branch: | Tag: | Revision:

root / gnuradio-core / src / python / gnuradio / gr / qa_skiphead.py @ c7dbfcc7

History | View | Annotate | Download (3.4 kB)

1
#!/usr/bin/env python
2
#
3
# Copyright 2007 Free Software Foundation, Inc.
4
# 
5
# This file is part of GNU Radio
6
# 
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 2, or (at your option)
10
# any later version.
11
# 
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.
16
# 
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.
21
# 
22
23
from gnuradio import gr, gr_unittest
24
25
class test_skiphead (gr_unittest.TestCase):
26
27
    def setUp(self):
28
        self.fg = gr.flow_graph ()
29
        self.src_data = [int(x) for x in range(65536)]
30
31
    def tearDown(self):
32
        self.fg = None
33
34
    def test_skip_0(self):
35
        skip_cnt = 0
36
        expected_result = tuple(self.src_data[skip_cnt:])
37
        src1 = gr.vector_source_i (self.src_data)
38
        op = gr.skiphead (gr.sizeof_int, skip_cnt)
39
        dst1 = gr.vector_sink_i ()
40
        self.fg.connect (src1, op, dst1)
41
        self.fg.run ()
42
        dst_data = dst1.data ()
43
        self.assertEqual (expected_result, dst_data)
44
    
45
    def test_skip_1(self):
46
        skip_cnt = 1
47
        expected_result = tuple(self.src_data[skip_cnt:])
48
        src1 = gr.vector_source_i (self.src_data)
49
        op = gr.skiphead (gr.sizeof_int, skip_cnt)
50
        dst1 = gr.vector_sink_i ()
51
        self.fg.connect (src1, op, dst1)
52
        self.fg.run ()
53
        dst_data = dst1.data ()
54
        self.assertEqual (expected_result, dst_data)
55
    
56
    def test_skip_1023(self):
57
        skip_cnt = 1023
58
        expected_result = tuple(self.src_data[skip_cnt:])
59
        src1 = gr.vector_source_i (self.src_data)
60
        op = gr.skiphead (gr.sizeof_int, skip_cnt)
61
        dst1 = gr.vector_sink_i ()
62
        self.fg.connect (src1, op, dst1)
63
        self.fg.run ()
64
        dst_data = dst1.data ()
65
        self.assertEqual (expected_result, dst_data)
66
    
67
    def test_skip_6339(self):
68
        skip_cnt = 6339
69
        expected_result = tuple(self.src_data[skip_cnt:])
70
        src1 = gr.vector_source_i (self.src_data)
71
        op = gr.skiphead (gr.sizeof_int, skip_cnt)
72
        dst1 = gr.vector_sink_i ()
73
        self.fg.connect (src1, op, dst1)
74
        self.fg.run ()
75
        dst_data = dst1.data ()
76
        self.assertEqual (expected_result, dst_data)
77
    
78
    def test_skip_12678(self):
79
        skip_cnt = 12678
80
        expected_result = tuple(self.src_data[skip_cnt:])
81
        src1 = gr.vector_source_i (self.src_data)
82
        op = gr.skiphead (gr.sizeof_int, skip_cnt)
83
        dst1 = gr.vector_sink_i ()
84
        self.fg.connect (src1, op, dst1)
85
        self.fg.run ()
86
        dst_data = dst1.data ()
87
        self.assertEqual (expected_result, dst_data)
88
89
    def test_skip_all(self):
90
        skip_cnt = len(self.src_data)
91
        expected_result = tuple(self.src_data[skip_cnt:])
92
        src1 = gr.vector_source_i (self.src_data)
93
        op = gr.skiphead (gr.sizeof_int, skip_cnt)
94
        dst1 = gr.vector_sink_i ()
95
        self.fg.connect (src1, op, dst1)
96
        self.fg.run ()
97
        dst_data = dst1.data ()
98
        self.assertEqual (expected_result, dst_data)
99
    
100
101
if __name__ == '__main__':
102
    gr_unittest.main ()