Mercurial > hg > audiodb
comparison libtests/0037/prog1.c @ 413:9de6d0676907 api-inversion
Add a partial libtests/ implementation of tests/0037.
Partial because still no "nsequence", though I have a plan for that.
The audiodb_batchinsert is a little bit weird; I think I'd have used an
adb_insert_t*[] (array of pointers) rather than an array of structures
directly. I might think about that some more later.
author | mas01cr |
---|---|
date | Fri, 12 Dec 2008 15:37:17 +0000 |
parents | |
children | c26c5b7ef0d2 |
comparison
equal
deleted
inserted
replaced
412:223eda8408e1 | 413:9de6d0676907 |
---|---|
1 #include <stdio.h> | |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 #include <sysexits.h> | |
5 #include <fcntl.h> | |
6 #include <dirent.h> | |
7 #include <unistd.h> | |
8 #include <sys/stat.h> | |
9 /* | |
10 * * #define NDEBUG | |
11 * * */ | |
12 #include <assert.h> | |
13 | |
14 #include "../../audioDB_API.h" | |
15 #include "../test_utils_lib.h" | |
16 | |
17 int main(int argc, char *argv[]) { | |
18 char *dbname = "testdb"; | |
19 adb_t *adb; | |
20 adb_insert_t *batch = 0; | |
21 adb_status_t status; | |
22 adb_query_t query = {0}; | |
23 adb_queryresult_t result; | |
24 | |
25 clean_remove_db(dbname); | |
26 adb = audiodb_create("testdb", 0, 0, 0); | |
27 if(!adb) { | |
28 return 1; | |
29 } | |
30 | |
31 maketestfile("testfeature01", (int[1]) {2}, (double[4]) {0,1,1,0}, 4); | |
32 maketestfile("testfeature10", (int[1]) {2}, (double[4]) {1,0,0,1}, 4); | |
33 | |
34 batch = (adb_insert_t *) calloc(6, sizeof(adb_insert_t)); | |
35 if(!batch) { | |
36 return 1; | |
37 } | |
38 batch[0].features = "testfeature01"; | |
39 batch[1].features = "testfeature01"; | |
40 batch[2].features = "testfeature10"; | |
41 batch[3].features = "testfeature10"; | |
42 batch[4].features = "testfeature01"; | |
43 batch[5].features = "testfeature10"; | |
44 | |
45 audiodb_batchinsert(adb, batch, 6); | |
46 | |
47 if(audiodb_status(adb, &status)) { | |
48 return 1; | |
49 } | |
50 if(status.numFiles != 2) { | |
51 return 1; | |
52 } | |
53 | |
54 if(audiodb_l2norm(adb)) { | |
55 return 1; | |
56 } | |
57 | |
58 maketestfile("testquery", (int [1]) {2}, (double[2]) {0, 0.5}, 2); | |
59 return 14; | |
60 /* can't do nsequence yet */ | |
61 /* | |
62 query.querytype = "nsequence"; | |
63 query.sequencelength = "1"; | |
64 query.feature = "testquery"; | |
65 if(audiodb_query(adb, &query, &result)) { | |
66 return 1; | |
67 } | |
68 if(result.sizeRlist != 2) { | |
69 return 1; | |
70 } | |
71 if(testoneresult(&result, 0, "testfeature01" ...)); | |
72 return 104; | |
73 */ | |
74 } | |
75 |