예제 #1
0
파일: qa_feval.py 프로젝트: atzengin/OCC
        f = my_add2_cc()
        src_data =        (0+1j, 2+3j, 4+5j, 6+7j)
        expected_result = (2-1j, 4+1j, 6+3j, 8+5j)
        # this is all in python...
        actual_result = tuple([f.eval(x) for x in src_data])
        self.assertEqual(expected_result, actual_result)

    def test_cc_2(self):
        f = my_add2_cc()
        src_data =        (0+1j, 2+3j, 4+5j, 6+7j)
        expected_result = (2-1j, 4+1j, 6+3j, 8+5j)
        # this is python -> C++ -> python and back again...
        actual_result = tuple([gr.feval_cc_example(f, x) for x in src_data])
        self.assertEqual(expected_result, actual_result)

    def test_void_1(self):
        # this is all in python
        f = my_feval()
        f.eval()
        self.assertEqual(True, f.fired)

    def test_void_2(self):
        # this is python -> C++ -> python and back again
        f = my_feval()
        gr.feval_example(f)
        self.assertEqual(True, f.fired)


if __name__ == '__main__':
    oc_unittest.run(test_feval, "test_feval.xml")
        self.assert_has_num_subscriptions(hier.output, "test", 1)
        self.assert_has_subscription(hier.output, "test", output, "test")
        self.tb.msg_disconnect(input, "test", hier, "test")
        self.tb.msg_disconnect(hier, "test", output, "test")
        self.assert_has_num_subscriptions(input, "test", 0)
        self.assert_has_num_subscriptions(hier.output, "test", 0)

    def test_multiple_connections(self):
        hier = hier_block_with_message_output()
        x = block_with_message_input()
        y = block_with_message_input()

        self.tb.msg_connect(hier, "test", x, "test")
        self.tb.msg_connect(hier, "test", y, "test")
        self.run_top_block()
        self.assert_has_num_subscriptions(hier, "test", 0)
        self.assert_has_num_subscriptions(hier.block, "test", 2)
        self.assert_has_subscription(hier.block, "test", x, "test")
        self.assert_has_subscription(hier.block, "test", y, "test")
        self.tb.msg_disconnect(hier, "test", y, "test")
        self.assert_has_num_subscriptions(hier, "test", 0)
        self.assert_has_num_subscriptions(hier.block, "test", 1)
        self.assert_has_subscription(hier.block, "test", x, "test")
        self.run_top_block()
        self.tb.msg_disconnect(hier, "test", x, "test")
        self.assert_has_num_subscriptions(hier.block, "test", 0)

if __name__ == '__main__':
    oc_unittest.run(test_hier_block2_message_connections,
                    "test_hier_block2_message_connections.xml")
예제 #3
0
try:
    import pmt_swig as pmt
except ImportError:
    import pmt

class test_tag_utils (oc_unittest.TestCase):

    def setUp (self):
        self.tb = gr.top_block ()


    def tearDown (self):
        self.tb = None

    def test_001(self):
        t = gr.tag_t()
        t.offset = 10
        t.key = pmt.string_to_symbol('key')
        t.value = pmt.from_long(23)
        t.srcid = pmt.from_bool(False)
        pt = gr.tag_to_python(t)
        self.assertEqual(pt.key, 'key')
        self.assertEqual(pt.value, 23)
        self.assertEqual(pt.offset, 10)


if __name__ == '__main__':
    print 'hi'
    oc_unittest.run(test_tag_utils, "test_tag_utils.xml")

예제 #4
0
# any later version.
#
# GNU Radio is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Radio; see the file COPYING.  If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#

from ocvc import gr, oc_unittest

class test_kludged_imports (oc_unittest.TestCase):

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_gru_import(self):
        # make sure that this somewhat magic import works
        from ocvc import gru


if __name__ == '__main__':
    oc_unittest.run(test_kludged_imports, "test_kludged_imports.xml")