source: tests/src/test-fvec.c @ d013a93

feature/autosinkfeature/cnnfeature/crepefix/ffmpeg5
Last change on this file since d013a93 was 332487b, checked in by Paul Brossier <piem@piem.org>, 11 years ago

tests/src: clean up includes

  • Property mode set to 100644
File size: 849 bytes
RevLine 
[332487b]1#include "aubio.h"
2#include "utils_tests.h"
[4e9101e]3
[158e031]4int main (void)
[7e35b37]5{
6  uint_t vec_size = 10, i;
7  fvec_t * vec = new_fvec (vec_size);
[4e9101e]8
[7e35b37]9  // vec->length matches requested size
10  assert(vec->length == vec_size);
[c251b80]11
[7e35b37]12  // all elements are initialized to `0.`
13  for ( i = 0; i < vec->length; i++ ) {
14    assert(vec->data[i] == 0.);
15  }
[c251b80]16
[7e35b37]17  // all elements can be set to `0.`
18  fvec_zeros(vec);
19  for ( i = 0; i < vec->length; i++ ) {
20    assert(vec->data[i] == 0.);
21  }
22  fvec_print(vec);
[c251b80]23
[7e35b37]24  // all elements can be set to `1.`
25  fvec_ones(vec);
26  for ( i = 0; i < vec->length; i++ ) {
27    assert(vec->data[i] == 1.);
28  }
29  fvec_print(vec);
30
31  // each element can be accessed directly
32  for ( i = 0; i < vec->length; i++ ) {
33    vec->data[i] = i;
34    assert(vec->data[i] == i);
35  }
36  fvec_print(vec);
37
38  // now destroys the vector
39  del_fvec(vec);
[c251b80]40
41  return 0;
[4e9101e]42}
43
Note: See TracBrowser for help on using the repository browser.