feature/crepe_org
Last change
on this file since 18278232 was
9e2c1a1,
checked in by Paul Brossier <piem@piem.org>, 6 years ago
|
[tests] improve test-lvec
|
-
Property mode set to
100644
|
File size:
894 bytes
|
Line | |
---|
1 | #include "aubio.h" |
---|
2 | #include "utils_tests.h" |
---|
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 | |
---|
12 | int main (void) |
---|
13 | { |
---|
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 | |
---|
46 | return 0; |
---|
47 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.