[203c551] | 1 | import unittest |
---|
| 2 | |
---|
| 3 | from aubio.aubiowrapper import * |
---|
| 4 | |
---|
| 5 | buf_size = 2048 |
---|
| 6 | channels = 3 |
---|
| 7 | |
---|
| 8 | class cvec_test_case(unittest.TestCase): |
---|
| 9 | |
---|
| 10 | def setUp(self): |
---|
| 11 | self.vector = new_cvec(buf_size, channels) |
---|
| 12 | |
---|
| 13 | def tearDown(self): |
---|
| 14 | del_cvec(self.vector) |
---|
| 15 | |
---|
| 16 | def test_cvec(self): |
---|
| 17 | """ create and delete cvec """ |
---|
| 18 | pass |
---|
| 19 | |
---|
| 20 | def test_cvec_read_norm(self): |
---|
| 21 | """ check new cvec norm elements are set to 0. """ |
---|
| 22 | for index in range(buf_size/2+1): |
---|
| 23 | for channel in range(channels): |
---|
| 24 | self.assertEqual(cvec_read_norm(self.vector,channel,index),0.) |
---|
| 25 | |
---|
| 26 | def test_cvec_read_phas(self): |
---|
| 27 | """ check new cvec phas elements are set to 0. """ |
---|
| 28 | for index in range(buf_size/2+1): |
---|
| 29 | for channel in range(channels): |
---|
| 30 | self.assertEqual(cvec_read_phas(self.vector,channel,index),0.) |
---|
| 31 | |
---|
| 32 | def test_cvec_write_norm(self): |
---|
| 33 | """ check new cvec norm elements are set with cvec_write_norm """ |
---|
| 34 | for index in range(buf_size/2+1): |
---|
| 35 | for channel in range(channels): |
---|
| 36 | cvec_write_norm(self.vector,1.,channel,index) |
---|
| 37 | for index in range(buf_size/2+1): |
---|
| 38 | for channel in range(channels): |
---|
| 39 | self.assertEqual(cvec_read_norm(self.vector,channel,index),1.) |
---|
| 40 | |
---|
| 41 | def test_cvec_write_phas(self): |
---|
| 42 | """ check new cvec phas elements are set with cvec_write_phas """ |
---|
| 43 | for index in range(buf_size/2+1): |
---|
| 44 | for channel in range(channels): |
---|
| 45 | cvec_write_phas(self.vector,1.,channel,index) |
---|
| 46 | for index in range(buf_size/2+1): |
---|
| 47 | for channel in range(channels): |
---|
| 48 | self.assertEqual(cvec_read_phas(self.vector,channel,index),1.) |
---|
| 49 | |
---|
| 50 | if __name__ == '__main__': |
---|
| 51 | unittest.main() |
---|