[tests] test-source checks for undersized/oversized output
authorPaul Brossier <piem@piem.org>
Thu, 20 Dec 2018 18:16:32 +0000 (19:16 +0100)
committerPaul Brossier <piem@piem.org>
Thu, 20 Dec 2018 18:16:32 +0000 (19:16 +0100)
tests/src/io/base-source_custom.h
tests/src/io/test-source.c

index cff2d3e..6f5b941 100644 (file)
@@ -93,6 +93,18 @@ int test_wrong_params(void)
   aubio_source_custom_do(s, vec, &read);
   if (read != hop_size) return 1;
 
   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;
 
   // seek to 0
   if(aubio_source_custom_seek(s, 0)) return 1;
 
@@ -100,6 +112,30 @@ int test_wrong_params(void)
   aubio_source_custom_do_multi(s, mat, &read);
   if (read != hop_size) return 1;
 
   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;
+
   // close the file (optional)
   aubio_source_custom_close(s);
   // test closing the file a second time
   // close the file (optional)
   aubio_source_custom_close(s);
   // test closing the file a second time
index 426bdc9..a3cad3e 100644 (file)
@@ -89,6 +89,18 @@ int test_wrong_params(void)
   aubio_source_do(s, vec, &read);
   if (read != hop_size) return 1;
 
   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;
 
   // seek to 0
   if(aubio_source_seek(s, 0)) return 1;
 
@@ -96,6 +108,30 @@ int test_wrong_params(void)
   aubio_source_do_multi(s, mat, &read);
   if (read != hop_size) return 1;
 
   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;
+
   // close the file (optional)
   aubio_source_close(s);
   // test closing the file a second time
   // close the file (optional)
   aubio_source_close(s);
   // test closing the file a second time