shithub: aubio

Download patch

ref: cd5388875d11b8033e451b430cf7cefc9469d650
parent: 3bf80b9872d63282409dfc876e3dc29140c134ef
author: Paul Brossier <piem@piem.org>
date: Mon May 2 12:43:42 EDT 2016

python/tests/test_cvec.py: check input sizes

--- a/python/tests/test_cvec.py
+++ b/python/tests/test_cvec.py
@@ -2,7 +2,7 @@
 
 from numpy.testing import TestCase
 from numpy.testing import assert_equal, assert_almost_equal
-from aubio import cvec, float_type
+from aubio import cvec, fvec, float_type
 import numpy as np
 
 class aubio_cvec_test_case(TestCase):
@@ -77,6 +77,30 @@
         assert_equal(new_spec.norm, 0.)
         assert_equal(new_spec.phas, 0.)
         del new_spec
+
+    def test_assign_norm_too_large(self):
+        a = cvec(512)
+        b = fvec(512//2+1 + 4)
+        with self.assertRaises(ValueError):
+            a.norm = b
+
+    def test_assign_norm_too_small(self):
+        a = cvec(512)
+        b = fvec(512//2+1 - 4)
+        with self.assertRaises(ValueError):
+            a.norm = b
+
+    def test_assign_phas_too_large(self):
+        a = cvec(512)
+        b = fvec(512//2+1 + 4)
+        with self.assertRaises(ValueError):
+            a.phas = b
+
+    def test_assign_phas_too_small(self):
+        a = cvec(512)
+        b = fvec(512//2+1 - 4)
+        with self.assertRaises(ValueError):
+            a.phas = b
 
 if __name__ == '__main__':
     from nose2 import main