ref: 6f22ed5c3c6b6d87c6f034b6f2f70e98b2211735
parent: efaeaf17c74bb4d4a28f92826a03fbc40e80efd5
author: Paul Brossier <piem@piem.org>
date: Thu Dec 20 14:16:32 EST 2018
[tests] test-source checks for undersized/oversized output
--- a/tests/src/io/base-source_custom.h
+++ b/tests/src/io/base-source_custom.h
@@ -93,10 +93,46 @@
aubio_source_custom_do(s, vec, &read);
if (read != hop_size) return 1;
+ // read again in undersized vector
+ del_fvec(vec);
+ vec = new_fvec(hop_size - 1);
+ aubio_source_custom_do(s, vec, &read);
+ if (read != hop_size - 1) return 1;
+
+ // read again in oversized vector
+ del_fvec(vec);
+ vec = new_fvec(hop_size + 1);
+ aubio_source_custom_do(s, vec, &read);
+ if (read != hop_size) return 1;
+
// seek to 0
if(aubio_source_custom_seek(s, 0)) return 1;
// read again as multiple channels
+ aubio_source_custom_do_multi(s, mat, &read);
+ if (read != hop_size) return 1;
+
+ // read again as multiple channels in an undersized matrix
+ del_fmat(mat);
+ mat = new_fmat(channels - 1, hop_size);
+ aubio_source_custom_do_multi(s, mat, &read);
+ if (read != hop_size) return 1;
+
+ // read again as multiple channels in an undersized matrix
+ del_fmat(mat);
+ mat = new_fmat(channels, hop_size - 1);
+ aubio_source_custom_do_multi(s, mat, &read);
+ if (read != hop_size - 1) return 1;
+
+ // read again as multiple channels in an oversized matrix
+ del_fmat(mat);
+ mat = new_fmat(channels + 1, hop_size);
+ aubio_source_custom_do_multi(s, mat, &read);
+ if (read != hop_size) return 1;
+
+ // read again as multiple channels in an oversized matrix
+ del_fmat(mat);
+ mat = new_fmat(channels, hop_size + 1);
aubio_source_custom_do_multi(s, mat, &read);
if (read != hop_size) return 1;
--- a/tests/src/io/test-source.c
+++ b/tests/src/io/test-source.c
@@ -89,10 +89,46 @@
aubio_source_do(s, vec, &read);
if (read != hop_size) return 1;
+ // read again in undersized vector
+ del_fvec(vec);
+ vec = new_fvec(hop_size - 1);
+ aubio_source_do(s, vec, &read);
+ if (read != hop_size - 1) return 1;
+
+ // read again in oversized vector
+ del_fvec(vec);
+ vec = new_fvec(hop_size + 1);
+ aubio_source_do(s, vec, &read);
+ if (read != hop_size) return 1;
+
// seek to 0
if(aubio_source_seek(s, 0)) return 1;
// read again as multiple channels
+ aubio_source_do_multi(s, mat, &read);
+ if (read != hop_size) return 1;
+
+ // read again as multiple channels in an undersized matrix
+ del_fmat(mat);
+ mat = new_fmat(channels - 1, hop_size);
+ aubio_source_do_multi(s, mat, &read);
+ if (read != hop_size) return 1;
+
+ // read again as multiple channels in an undersized matrix
+ del_fmat(mat);
+ mat = new_fmat(channels, hop_size - 1);
+ aubio_source_do_multi(s, mat, &read);
+ if (read != hop_size - 1) return 1;
+
+ // read again as multiple channels in an oversized matrix
+ del_fmat(mat);
+ mat = new_fmat(channels + 1, hop_size);
+ aubio_source_do_multi(s, mat, &read);
+ if (read != hop_size) return 1;
+
+ // read again as multiple channels in an oversized matrix
+ del_fmat(mat);
+ mat = new_fmat(channels, hop_size + 1);
aubio_source_do_multi(s, mat, &read);
if (read != hop_size) return 1;