added simple tests for fvec and cvec
authorPaul Brossier <piem@piem.org>
Mon, 17 Sep 2007 01:01:29 +0000 (03:01 +0200)
committerPaul Brossier <piem@piem.org>
Mon, 17 Sep 2007 01:01:29 +0000 (03:01 +0200)
python/test/all_tests.py
python/test/cvec.py [new file with mode: 0644]
python/test/fvec.py [new file with mode: 0644]

index 4024f3f60a35158f147b5793c0fec59a1d6c73a6..a066ca3afba8caf026baa3badd48817a1a1b1300 100755 (executable)
@@ -8,7 +8,7 @@ sys.path.append(os.path.join('..','aubio','.libs'))
 
 import unittest
 
-modules_to_test = ['aubiomodule']
+modules_to_test = ['aubiomodule', 'fvec', 'cvec']
 
 if __name__ == '__main__':
   for module in modules_to_test: exec('from %s import *' % module)
diff --git a/python/test/cvec.py b/python/test/cvec.py
new file mode 100644 (file)
index 0000000..f104300
--- /dev/null
@@ -0,0 +1,51 @@
+import unittest
+
+from aubio.aubiowrapper import *
+
+buf_size = 2048
+channels = 3
+
+class cvec_test_case(unittest.TestCase):
+
+  def setUp(self):
+    self.vector = new_cvec(buf_size, channels)
+
+  def tearDown(self):
+    del_cvec(self.vector)
+
+  def test_cvec(self):
+    """ create and delete cvec """
+    pass
+
+  def test_cvec_read_norm(self):
+    """ check new cvec norm elements are set to 0. """
+    for index in range(buf_size/2+1):
+      for channel in range(channels):
+        self.assertEqual(cvec_read_norm(self.vector,channel,index),0.)
+
+  def test_cvec_read_phas(self):
+    """ check new cvec phas elements are set to 0. """
+    for index in range(buf_size/2+1):
+      for channel in range(channels):
+        self.assertEqual(cvec_read_phas(self.vector,channel,index),0.)
+
+  def test_cvec_write_norm(self):
+    """ check new cvec norm elements are set with cvec_write_norm """
+    for index in range(buf_size/2+1):
+      for channel in range(channels):
+        cvec_write_norm(self.vector,1.,channel,index)
+    for index in range(buf_size/2+1):
+      for channel in range(channels):
+        self.assertEqual(cvec_read_norm(self.vector,channel,index),1.)
+
+  def test_cvec_write_phas(self):
+    """ check new cvec phas elements are set with cvec_write_phas """
+    for index in range(buf_size/2+1):
+      for channel in range(channels):
+        cvec_write_phas(self.vector,1.,channel,index)
+    for index in range(buf_size/2+1):
+      for channel in range(channels):
+        self.assertEqual(cvec_read_phas(self.vector,channel,index),1.)
+
+if __name__ == '__main__':
+  unittest.main()
diff --git a/python/test/fvec.py b/python/test/fvec.py
new file mode 100644 (file)
index 0000000..5159af9
--- /dev/null
@@ -0,0 +1,36 @@
+import unittest
+
+from aubio.aubiowrapper import *
+
+buf_size = 2048
+channels = 3
+
+class fvec_test_case(unittest.TestCase):
+
+  def setUp(self):
+    self.vector = new_fvec(buf_size, channels)
+
+  def tearDown(self):
+    del_fvec(self.vector)
+
+  def test_fvec(self):
+    """ create and delete fvec """
+    pass
+
+  def test_fvec_read_sample(self):
+    """ check new fvec elements are set to 0. """
+    for index in range(buf_size):
+      for channel in range(channels):
+        self.assertEqual(fvec_read_sample(self.vector,channel,index),0.)
+
+  def test_fvec_write_sample(self):
+    """ check new fvec elements are set with fvec_write_sample """
+    for index in range(buf_size):
+      for channel in range(channels):
+        fvec_write_sample(self.vector,1.,channel,index)
+    for index in range(buf_size):
+      for channel in range(channels):
+        self.assertEqual(fvec_read_sample(self.vector,channel,index),1.)
+
+if __name__ == '__main__':
+  unittest.main()