annotate accumulator_test.cpp @ 497:9d8aee621afb api-inversion

More libtests fixups. Include audiodb_close() calls everywhere (whoops). Add the facility to run tests under valgrind. Unfortunately the error-exitcode flag doesn't actually cause an error exit if the only thing wrong is memory leaks, but it will if there are actual memory errors, which is a start.
author mas01cr
date Sat, 10 Jan 2009 16:07:43 +0000
parents 166312a124bc
children
rev   line source
mas01cr@421 1 #include "audioDB.h"
mas01cr@421 2 extern "C" {
mas01cr@421 3 #include "audioDB_API.h"
mas01cr@421 4 }
mas01cr@421 5 #include "audioDB-internals.h"
mas01cr@421 6
mas01cr@420 7 #include "accumulators.h"
mas01cr@416 8
mas01cr@416 9 static NearestAccumulator<adb_result_dist_lt> *foo = new NearestAccumulator<adb_result_dist_lt>();
mas01cr@416 10
mas01cr@416 11 int main() {
mas01cr@416 12 adb_result_t r;
mas01cr@416 13 r.key = "hello";
mas01cr@416 14 r.ipos = 0;
mas01cr@416 15 r.qpos = 0;
mas01cr@416 16 r.dist = 3;
mas01cr@416 17 foo->add_point(&r);
mas01cr@416 18 r.ipos = 1;
mas01cr@416 19 r.dist = 2;
mas01cr@416 20 foo->add_point(&r);
mas01cr@416 21 r.qpos = 1;
mas01cr@416 22 foo->add_point(&r);
mas01cr@416 23
mas01cr@416 24 adb_query_results_t *rs;
mas01cr@416 25 rs = foo->get_points();
mas01cr@416 26 for (unsigned int k = 0; k < rs->nresults; k++) {
mas01cr@416 27 r = rs->results[k];
mas01cr@416 28 printf("%s: %f %u %u\n", r.key, r.dist, r.qpos, r.ipos);
mas01cr@416 29 }
mas01cr@416 30 free(rs->results);
mas01cr@416 31 free(rs);
mas01cr@416 32 delete foo;
mas01cr@416 33 return 1;
mas01cr@416 34 }