From 529e942f6456d45c957fe8248e7621c956c5f2f1 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 23 Oct 2011 17:22:25 -0400 Subject: core: added a test for float_to_int overflow clipping. --- gnuradio-core/src/python/gnuradio/gr/qa_float_to_int.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_float_to_int.py b/gnuradio-core/src/python/gnuradio/gr/qa_float_to_int.py index 6eaf2e8f0..2f54d0329 100644 --- a/gnuradio-core/src/python/gnuradio/gr/qa_float_to_int.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_float_to_int.py @@ -44,6 +44,22 @@ class test_float_to_int (gr_unittest.TestCase): self.assertEqual(expected_result, result_data) + def test_002(self): + + src_data = ( 2147483647, 2147483648, 2200000000, + -2147483648, -2147483649, -2200000000) + expected_result = [2147483647, 2147483647, 2147483647, + -2147483648, -2147483648, -2147483648] + src = gr.vector_source_f(src_data) + op = gr.float_to_int() + dst = gr.vector_sink_i() + + self.tb.connect(src, op, dst) + self.tb.run() + result_data = list(dst.data()) + + self.assertEqual(expected_result, result_data) + if __name__ == '__main__': gr_unittest.run(test_float_to_int, "test_float_to_int.xml") -- cgit