diff options
author | Josh Blum | 2012-11-11 12:06:37 -0800 |
---|---|---|
committer | Josh Blum | 2012-11-11 12:06:37 -0800 |
commit | f1e85b43b0d76ff2f0c6b4432e4c318f5562ba08 (patch) | |
tree | 49ede4dd0503bbb9a916ea66ec046113f900b715 /tests | |
parent | 284205f5fb4e27583760785aabe97e865450689a (diff) | |
download | sandhi-f1e85b43b0d76ff2f0c6b4432e4c318f5562ba08.tar.gz sandhi-f1e85b43b0d76ff2f0c6b4432e4c318f5562ba08.tar.bz2 sandhi-f1e85b43b0d76ff2f0c6b4432e4c318f5562ba08.zip |
python unit test for readonly buffers
Diffstat (limited to 'tests')
-rw-r--r-- | tests/block_test.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/block_test.py b/tests/block_test.py index ff44a74..f7e18e4 100644 --- a/tests/block_test.py +++ b/tests/block_test.py @@ -54,5 +54,25 @@ class BlockTest(unittest.TestCase): tb = None self.assertEqual(sink.get_values(), values) + def test_ro_buffers(self): + class BadTouch(gras.Block): + def __init__(self, in_sig): + gras.Block.__init__(self, 'BadTouch', in_sig=[in_sig]) + + def work(self, ins, outs): + try: + ins[0][0] = 0 #assign to ro buffer should fail + raise Exception, 'ins should not be writeable!' + except: pass + self.consume(0, len(ins[0])) + + source = VectorSource(numpy.uint32, [0, 9, 8, 7, 6]) + sink = BadTouch(numpy.uint32) + + tb = gras.TopBlock() + tb.connect(source, sink) + tb.run() + tb = None + if __name__ == '__main__': unittest.main() |