summaryrefslogtreecommitdiff
path: root/gr-blocks/python
diff options
context:
space:
mode:
authorJohnathan Corgan2012-06-24 11:20:03 -0700
committerJohnathan Corgan2012-06-24 11:20:03 -0700
commitb48716fe0b666cf2be605c0c7d79111c6caf96c5 (patch)
tree48e3e9461d34833c5d6dcdfe399cb9deeb7803be /gr-blocks/python
parent80aa560bbb59cad4d4d351a1e9c8c1fb56897397 (diff)
downloadgnuradio-b48716fe0b666cf2be605c0c7d79111c6caf96c5.tar.gz
gnuradio-b48716fe0b666cf2be605c0c7d79111c6caf96c5.tar.bz2
gnuradio-b48716fe0b666cf2be605c0c7d79111c6caf96c5.zip
blocks: added gr::blocks::float_to_char
Diffstat (limited to 'gr-blocks/python')
-rwxr-xr-xgr-blocks/python/qa_type_conversions.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/gr-blocks/python/qa_type_conversions.py b/gr-blocks/python/qa_type_conversions.py
index 579ce2246..2caa283d2 100755
--- a/gr-blocks/python/qa_type_conversions.py
+++ b/gr-blocks/python/qa_type_conversions.py
@@ -146,7 +146,26 @@ class test_type_conversions(gr_unittest.TestCase):
self.tb.connect(src, op, dst)
self.tb.run()
self.assertFloatTuplesAlmostEqual(expected_data, dst.data(), 2)
- print dst.data()
+
+ def test_float_to_char_identity(self):
+ src_data = (1.0, 2.0, 3.0, 4.0, 5.0)
+ expected_data = (1, 2, 3, 4, 5)
+ src = gr.vector_source_f(src_data)
+ op = blocks_swig.float_to_char()
+ dst = gr.vector_sink_b()
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ self.assertEqual(expected_data, dst.data())
+
+ def test_float_to_char_scale(self):
+ src_data = (1.0, 2.0, 3.0, 4.0, 5.0)
+ expected_data = (5, 10, 15, 20, 25)
+ src = gr.vector_source_f(src_data)
+ op = blocks_swig.float_to_char(1, 5)
+ dst = gr.vector_sink_b()
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ self.assertEqual(expected_data, dst.data())
if __name__ == '__main__':
gr_unittest.run(test_type_conversions, "test_type_conversions.xml")