From f5d9d86bae8ed97a43a4501236daa4a34d54dcc0 Mon Sep 17 00:00:00 2001
From: Maximilian Stiefel <stiefel.maximilian@online.de>
Date: Sat, 17 Mar 2018 13:46:07 +0100
Subject: Solved the issue without C++11 and introduced the proposed
 improvements. Fixes #1648

---
 .../digital/qa_ofdm_carrier_allocator_cvc.py       | 58 +++++++++++++---------
 1 file changed, 35 insertions(+), 23 deletions(-)

(limited to 'gr-digital/python/digital/qa_ofdm_carrier_allocator_cvc.py')

diff --git a/gr-digital/python/digital/qa_ofdm_carrier_allocator_cvc.py b/gr-digital/python/digital/qa_ofdm_carrier_allocator_cvc.py
index bd1dfb0915..bbf58c473f 100755
--- a/gr-digital/python/digital/qa_ofdm_carrier_allocator_cvc.py
+++ b/gr-digital/python/digital/qa_ofdm_carrier_allocator_cvc.py
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-# Copyright 2012-2018 Free Software Foundation, Inc.
+# Copyright 2012, 2018 Free Software Foundation, Inc.
 #
 # This file is part of GNU Radio
 #
@@ -208,32 +208,44 @@ class qa_digital_carrier_allocator_cvc (gr_unittest.TestCase):
                 self.assertEqual(correct_offsets[key], tag.offset)
         self.assertTrue(all(tags_found.values()))
 
-    @gr_unittest.unittest.skip("Skipping test with wrong input (caused SIGFPE earlier, now throws a simple std::invalid_argument with useful message)")
     def test_004_t (self):
         """
-        Provoking exception (earlier SIGFPE).
+        Provoking RuntimeError exceptions providing wrong user input (earlier invisible SIGFPE).
         """
         fft_len = 6
-        tx_symbols = (1, 2, 3)
-        pilot_symbols = ()
-        occupied_carriers = ((-1, 1, 2),)
-        pilot_carriers = ()
-        expected_result = (0, 0, 1, 0, 2, 3)
-        src = blocks.vector_source_c(tx_symbols, False, 1)
-        alloc = digital.ofdm_carrier_allocator_cvc(fft_len,
-                       occupied_carriers,
-                       pilot_carriers,
-                       pilot_symbols, (),
-                       self.tsb_key)
-        sink = blocks.tsb_vector_sink_c(fft_len)
-        self.tb.connect(
-                src,
-                blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, 1, len(tx_symbols), self.tsb_key),
-                alloc,
-                sink
-        )
-        self.tb.run ()
-        self.assertEqual(sink.data()[0], expected_result)
+
+        # Occupied carriers
+        with self.assertRaises(RuntimeError) as oc:
+          alloc = digital.ofdm_carrier_allocator_cvc(fft_len,
+                        (),
+                        ((),),
+                        ((),),
+                        (),
+                        self.tsb_key)
+
+        # Pilot carriers
+        with self.assertRaises(RuntimeError) as pc:
+          alloc = digital.ofdm_carrier_allocator_cvc(fft_len,
+                        ((),),
+                        (),
+                        ((),),
+                        (),
+                        self.tsb_key)
+
+        # Pilot carrier symbols
+        with self.assertRaises(RuntimeError) as ps:
+          alloc = digital.ofdm_carrier_allocator_cvc(fft_len,
+                        ((),),
+                        ((),),
+                        (),
+                        (),
+                        self.tsb_key)
+
+
+        self.assertEqual(str(oc.exception), "Occupied carriers must be of type vector of vector i.e. ((),).")
+        self.assertEqual(str(pc.exception), "Pilot carriers must be of type vector of vector i.e. ((),).")
+        self.assertEqual(str(ps.exception), "Pilot symbols must be of type vector of vector i.e. ((),).")
+
 
 if __name__ == '__main__':
     gr_unittest.run(qa_digital_carrier_allocator_cvc, "qa_digital_carrier_allocator_cvc.xml")
-- 
cgit v1.2.3