Mercurial > hg > audiodb
comparison libtests/0024/prog1.c @ 355:94c18f128ce8
First version of the API, committed to the main trunk. Thanks Christophe, for all the help!
author | mas01ik |
---|---|
date | Wed, 12 Nov 2008 10:21:06 +0000 |
parents | |
children | e072aa1611f5 342822c2d49a |
comparison
equal
deleted
inserted
replaced
354:4871a3ed9e36 | 355:94c18f128ce8 |
---|---|
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 | |
18 int main(int argc, char **argv){ | |
19 | |
20 int returnval=0; | |
21 adb_ptr mydbp={0}; | |
22 int ivals[10]; | |
23 double dvals[10]; | |
24 adb_insert_t myinsert={0}; | |
25 unsigned int myerr=0; | |
26 char * databasename="testdb"; | |
27 adb_query_t myadbquery={0}; | |
28 adb_queryresult_t myadbqueryresult={0}; | |
29 adb_query_t myadbquery2={0}; | |
30 adb_queryresult_t myadbqueryresult2={0}; | |
31 int size=0; | |
32 adb_insert_t ins1[2]={0}; | |
33 | |
34 /* remove old directory */ | |
35 //if [ -f testdb ]; then rm -f testdb; fi | |
36 clean_remove_db(databasename); | |
37 | |
38 /* create new db */ | |
39 //${AUDIODB} -d testdb -N | |
40 mydbp=audiodb_create(databasename,0,0,0); | |
41 | |
42 //intstring 2 > testfeature01 | |
43 //floatstring 0 1 >> testfeature01 | |
44 //intstring 2 > testfeature10 | |
45 //floatstring 1 0 >> testfeature10 | |
46 ivals[0]=2; | |
47 dvals[0]=0; dvals[1]=1; | |
48 maketestfile("testfeature01",ivals,dvals,2); | |
49 ivals[0]=2; | |
50 dvals[0]=1; dvals[1]=0; | |
51 maketestfile("testfeature10",ivals,dvals,2); | |
52 | |
53 //cat > testfeaturefiles <<EOF | |
54 //testfeature01 | |
55 //testfeature10 | |
56 //EOF | |
57 ins1[0].features="testfeature01"; | |
58 ins1[1].features="testfeature10"; | |
59 | |
60 | |
61 //${AUDIODB} -d testdb -B -F testfeaturefiles | |
62 returnval=audiodb_batchinsert(mydbp,ins1,2); | |
63 | |
64 //# sequence queries require L2NORM | |
65 //${AUDIODB} -d testdb -L | |
66 audiodb_l2norm(mydbp); | |
67 | |
68 //echo "exhaustive search" | |
69 //intstring 2 > testquery | |
70 //floatstring 0 0.5 >> testquery | |
71 //floatstring 0.5 0 >> testquery | |
72 ivals[0]=2; | |
73 dvals[0]=0; dvals[1]=0.5; | |
74 dvals[2]=0.5; dvals[3]=0; | |
75 maketestfile("testquery",ivals,dvals,4); | |
76 | |
77 //${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -e > testoutput | |
78 //echo testfeature01 1 0 0 > test-expected-output | |
79 //echo testfeature10 1 1 0 >> test-expected-output | |
80 //cmp testoutput test-expected-output | |
81 myadbquery.querytype="sequence"; | |
82 myadbquery.feature="testquery"; | |
83 myadbquery.sequencelength="1"; | |
84 myadbquery.exhaustive=1; | |
85 audiodb_query(mydbp,&myadbquery,&myadbqueryresult); | |
86 size=myadbqueryresult.sizeRlist; | |
87 | |
88 //printf("size:%d\n",size); | |
89 //dump_query(&myadbquery,&myadbqueryresult); | |
90 ///* check the test values */ | |
91 if (size != 2) {returnval = -1;}; | |
92 if (testoneresult(&myadbqueryresult,0,"testfeature01",1,0,0)) {returnval = -1;}; | |
93 if (testoneresult(&myadbqueryresult,1,"testfeature10",1,1,0)) {returnval = -1;}; | |
94 | |
95 //${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -n 1 -e > testoutput | |
96 //echo testfeature01 0 0 0 > test-expected-output | |
97 //echo testfeature10 0 1 0 >> test-expected-output | |
98 //cmp testoutput test-expected-output | |
99 myadbquery.querytype="sequence"; | |
100 myadbquery.feature="testquery"; | |
101 myadbquery.sequencelength="1"; | |
102 myadbquery.exhaustive=1; | |
103 myadbquery.numpoints="1"; | |
104 audiodb_query(mydbp,&myadbquery,&myadbqueryresult); | |
105 size=myadbqueryresult.sizeRlist; | |
106 | |
107 //printf("size:%d\n",size); | |
108 //dump_query(&myadbquery,&myadbqueryresult); | |
109 ///* check the test values */ | |
110 if (size != 2) {returnval = -1;}; | |
111 if (testoneresult(&myadbqueryresult,0,"testfeature01",0,0,0)) {returnval = -1;}; | |
112 if (testoneresult(&myadbqueryresult,1,"testfeature10",0,1,0)) {returnval = -1;}; | |
113 | |
114 | |
115 printf("returnval:%d\n",returnval); | |
116 return(returnval); | |
117 } | |
118 |