From: Paul Brossier Date: Thu, 20 Dec 2018 18:16:32 +0000 (+0100) Subject: [tests] test-source checks for undersized/oversized output X-Git-Tag: 0.4.9~57 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=6f22ed5c3c6b6d87c6f034b6f2f70e98b2211735;p=aubio.git [tests] test-source checks for undersized/oversized output --- diff --git a/tests/src/io/base-source_custom.h b/tests/src/io/base-source_custom.h index cff2d3e4..6f5b941c 100644 --- a/tests/src/io/base-source_custom.h +++ b/tests/src/io/base-source_custom.h @@ -93,6 +93,18 @@ int test_wrong_params(void) 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; @@ -100,6 +112,30 @@ int test_wrong_params(void) 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 diff --git a/tests/src/io/test-source.c b/tests/src/io/test-source.c index 426bdc91..a3cad3ec 100644 --- a/tests/src/io/test-source.c +++ b/tests/src/io/test-source.c @@ -89,6 +89,18 @@ int test_wrong_params(void) 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; @@ -96,6 +108,30 @@ int test_wrong_params(void) 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