summaryrefslogtreecommitdiff
path: root/gr-blocks/python
diff options
context:
space:
mode:
authorJohnathan Corgan2012-06-25 06:25:04 -0700
committerJohnathan Corgan2012-06-25 06:25:04 -0700
commit31c61c16e2073f0c3f54a8d0523d8c4f10ca5dd2 (patch)
treebf81e2f6ba3a342f32cd9425dfcdfadecfb6d1d6 /gr-blocks/python
parent8c23d9f9ebfe04b60d59efc636c6d5b02baacc99 (diff)
downloadgnuradio-31c61c16e2073f0c3f54a8d0523d8c4f10ca5dd2.tar.gz
gnuradio-31c61c16e2073f0c3f54a8d0523d8c4f10ca5dd2.tar.bz2
gnuradio-31c61c16e2073f0c3f54a8d0523d8c4f10ca5dd2.zip
blocks: added gr::blocks::float_to_int
Diffstat (limited to 'gr-blocks/python')
-rwxr-xr-xgr-blocks/python/qa_type_conversions.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/gr-blocks/python/qa_type_conversions.py b/gr-blocks/python/qa_type_conversions.py
index 4daf5f602..fba38ab00 100755
--- a/gr-blocks/python/qa_type_conversions.py
+++ b/gr-blocks/python/qa_type_conversions.py
@@ -191,6 +191,26 @@ class test_type_conversions(gr_unittest.TestCase):
self.tb.run()
self.assertFloatTuplesAlmostEqual(expected_data, dst.data())
+ def test_float_to_int_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_int()
+ dst = gr.vector_sink_i()
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ self.assertEqual(expected_data, dst.data())
+
+ def test_float_to_int_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_int(1, 5)
+ dst = gr.vector_sink_i()
+ 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")