root / gnuradio-core / src / python / gnuradio / gr / qa_head.py @ 9e181064
History | View | Annotate | Download (1.5 kB)
| 1 | 5d69a524 | jcorgan | #!/usr/bin/env python
|
|---|---|---|---|
| 2 | 5d69a524 | jcorgan | #
|
| 3 | 2104a9d1 | Tom Rondeau | # Copyright 2004,2007,2010 Free Software Foundation, Inc.
|
| 4 | 5d69a524 | jcorgan | #
|
| 5 | 5d69a524 | jcorgan | # This file is part of GNU Radio
|
| 6 | 5d69a524 | jcorgan | #
|
| 7 | 5d69a524 | jcorgan | # GNU Radio is free software; you can redistribute it and/or modify
|
| 8 | 5d69a524 | jcorgan | # it under the terms of the GNU General Public License as published by
|
| 9 | 937b719d | eb | # the Free Software Foundation; either version 3, or (at your option)
|
| 10 | 5d69a524 | jcorgan | # any later version.
|
| 11 | 5d69a524 | jcorgan | #
|
| 12 | 5d69a524 | jcorgan | # GNU Radio is distributed in the hope that it will be useful,
|
| 13 | 5d69a524 | jcorgan | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 | 5d69a524 | jcorgan | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 | 5d69a524 | jcorgan | # GNU General Public License for more details.
|
| 16 | 5d69a524 | jcorgan | #
|
| 17 | 5d69a524 | jcorgan | # You should have received a copy of the GNU General Public License
|
| 18 | 5d69a524 | jcorgan | # along with GNU Radio; see the file COPYING. If not, write to
|
| 19 | 86f5c924 | eb | # the Free Software Foundation, Inc., 51 Franklin Street,
|
| 20 | 86f5c924 | eb | # Boston, MA 02110-1301, USA.
|
| 21 | 5d69a524 | jcorgan | #
|
| 22 | 5d69a524 | jcorgan | |
| 23 | 5d69a524 | jcorgan | from gnuradio import gr, gr_unittest |
| 24 | 5d69a524 | jcorgan | |
| 25 | 5d69a524 | jcorgan | class test_head (gr_unittest.TestCase): |
| 26 | 5d69a524 | jcorgan | |
| 27 | 5d69a524 | jcorgan | def setUp (self): |
| 28 | 3c443c0b | jcorgan | self.tb = gr.top_block ()
|
| 29 | 5d69a524 | jcorgan | |
| 30 | 5d69a524 | jcorgan | def tearDown (self): |
| 31 | 3c443c0b | jcorgan | self.tb = None |
| 32 | 5d69a524 | jcorgan | |
| 33 | 5d69a524 | jcorgan | def test_head (self): |
| 34 | 5d69a524 | jcorgan | src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) |
| 35 | 5d69a524 | jcorgan | expected_result = (1, 2, 3, 4) |
| 36 | 5d69a524 | jcorgan | src1 = gr.vector_source_i (src_data) |
| 37 | 5d69a524 | jcorgan | op = gr.head (gr.sizeof_int, 4)
|
| 38 | 5d69a524 | jcorgan | dst1 = gr.vector_sink_i () |
| 39 | 3c443c0b | jcorgan | self.tb.connect (src1, op)
|
| 40 | 3c443c0b | jcorgan | self.tb.connect (op, dst1)
|
| 41 | 3c443c0b | jcorgan | self.tb.run ()
|
| 42 | 5d69a524 | jcorgan | dst_data = dst1.data () |
| 43 | 5d69a524 | jcorgan | self.assertEqual (expected_result, dst_data)
|
| 44 | 5d69a524 | jcorgan | |
| 45 | 5d69a524 | jcorgan | |
| 46 | 5d69a524 | jcorgan | if __name__ == '__main__': |
| 47 | 2104a9d1 | Tom Rondeau | gr_unittest.run(test_head, "test_head.xml") |