Changeset 9e2c1a1
- Timestamp:
- Dec 21, 2018, 12:44:46 PM (6 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/timestretch, fix/ffmpeg5, master
- Children:
- fce8496
- Parents:
- dfd520b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/src/test-lvec.c
rdfd520b r9e2c1a1 2 2 #include "utils_tests.h" 3 3 4 void assert_lvec_all_equal(lvec_t *vec, lsmp_t scalar) 5 { 6 uint_t i; 7 for (i = 0; i < vec->length; i++) { 8 assert(vec->data[i] == scalar); 9 } 10 } 11 4 12 int main (void) 5 13 { 6 uint_t win_s = 32; // window size 7 lvec_t * sp = new_lvec (win_s); // input buffer 8 lvec_set_sample (sp, 2./3., 0); 9 PRINT_MSG(AUBIO_LSMP_FMT "\n", lvec_get_sample (sp, 0)); 10 lvec_print (sp); 11 lvec_ones (sp); 12 lvec_print (sp); 13 lvec_set_all (sp, 3./5.); 14 lvec_print (sp); 15 del_lvec(sp); 14 uint_t length = 32; // window size 15 16 lvec_t * vec = new_lvec (length); // input buffer 17 18 assert(vec); 19 20 assert(vec->length == length); 21 22 lvec_set_sample (vec, 3., 0); 23 assert(lvec_get_sample(vec, 0) == 3.); 24 25 assert(lvec_get_data(vec) == vec->data); 26 27 lvec_print (vec); 28 // note AUBIO_LSMP_FMT can be used to print lsmp_t 29 PRINT_MSG(AUBIO_LSMP_FMT "\n", lvec_get_sample (vec, 0)); 30 31 lvec_set_all (vec, 2.); 32 assert_lvec_all_equal(vec, 2.); 33 34 lvec_ones (vec); 35 assert_lvec_all_equal(vec, 1.); 36 37 lvec_zeros (vec); 38 assert_lvec_all_equal(vec, 0.); 39 40 del_lvec(vec); 41 42 // wrong parameters 43 assert(new_lvec(0) == NULL); 44 assert(new_lvec(-1) == NULL); 45 16 46 return 0; 17 47 } 18
Note: See TracChangeset
for help on using the changeset viewer.