From 0f5f40bbd31550e8b1b8b3019c94fdf5c2a3dd20 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Sat, 24 Nov 2018 19:00:11 +0100 Subject: [PATCH] [tests] run some tests in onset if no arguments passed --- tests/src/onset/test-onset.c | 45 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/tests/src/onset/test-onset.c b/tests/src/onset/test-onset.c index d1476b04..ac17fbe7 100644 --- a/tests/src/onset/test-onset.c +++ b/tests/src/onset/test-onset.c @@ -1,13 +1,20 @@ #include #include "utils_tests.h" +int test_wrong_params(void); + int main (int argc, char **argv) { uint_t err = 0; if (argc < 2) { err = 2; - PRINT_ERR("not enough arguments\n"); - PRINT_MSG("read a wave file as a mono vector\n"); + PRINT_WRN("no arguments, running tests\n"); + if (test_wrong_params() != 0) { + PRINT_ERR("tests failed!\n"); + err = 1; + } else { + err = 0; + } PRINT_MSG("usage: %s [samplerate] [hop_size]\n", argv[0]); return err; } @@ -60,3 +67,37 @@ beach: return err; } + +int test_wrong_params(void) +{ + uint_t win_size = 1024; + uint_t hop_size = win_size / 2; + uint_t samplerate = 44100; + // hop_size < 1 + if (new_aubio_onset("default", 5, 0, samplerate)) + return 1; + // buf_size < 2 + if (new_aubio_onset("default", 1, 1, samplerate)) + return 1; + // buf_size < hop_size + if (new_aubio_onset("default", hop_size, win_size, samplerate)) + return 1; + // samplerate < 1 + if (new_aubio_onset("default", 1024, 512, 0)) + return 1; + + // specdesc creation failed + if (new_aubio_onset("abcd", win_size, win_size/2, samplerate)) + return 1; + // pv creation failed + if (new_aubio_onset("default", 5, 2, samplerate)) + return 1; + + aubio_onset_t *o; + o = new_aubio_onset("default", win_size, hop_size, samplerate); + if (!aubio_onset_set_default_parameters(o, "wrong_type")) + return 1; + del_aubio_onset(o); + + return 0; +} -- 2.11.0