Mercurial > hg > audiodb
comparison libtests/0023/prog1.c @ 492:f6b126b018d8 api-inversion
Yet more audiodb_query() deletions.
Also delete the libtests/notes file, with its misleading and wrong
questions, to avoid further confusion.
author | mas01cr |
---|---|
date | Sat, 10 Jan 2009 15:33:07 +0000 |
parents | f4dc8e47ee37 |
children | c291e9201a3c |
comparison
equal
deleted
inserted
replaced
491:29d28cfe0222 | 492:f6b126b018d8 |
---|---|
1 #include "audioDB_API.h" | 1 #include "audioDB_API.h" |
2 #include "test_utils_lib.h" | 2 #include "test_utils_lib.h" |
3 | 3 |
4 int main(int argc, char **argv) { | |
5 adb_t *adb; | |
6 adb_insert_t batch[2]={{0},{0}}; | |
4 | 7 |
5 int main(int argc, char **argv){ | 8 clean_remove_db(TESTDB); |
9 if(!(adb = audiodb_create(TESTDB, 0, 0, 0))) | |
10 return 1; | |
6 | 11 |
7 int returnval=0; | 12 maketestfile("testfeature01", (int[1]){2}, (double[2]) {0, 1}, 2); |
8 adb_ptr mydbp={0}; | 13 maketestfile("testfeature10", (int[1]){2}, (double[2]) {1, 0}, 2); |
9 int ivals[10]; | |
10 double dvals[10]; | |
11 adb_insert_t myinsert={0}; | |
12 char * databasename="testdb"; | |
13 adb_query_t myadbquery={0}; | |
14 adb_queryresult_t myadbqueryresult={0}; | |
15 adb_query_t myadbquery2={0}; | |
16 adb_queryresult_t myadbqueryresult2={0}; | |
17 adb_query_t myadbquery3={0}; | |
18 adb_queryresult_t myadbqueryresult3={0}; | |
19 int size=0; | |
20 adb_insert_t ins1[2]={{0},{0}}; | |
21 | 14 |
22 /* remove old directory */ | 15 batch[0].features="testfeature01"; |
23 //if [ -f testdb ]; then rm -f testdb; fi | 16 batch[1].features="testfeature10"; |
24 clean_remove_db(databasename); | 17 if(audiodb_batchinsert(adb, batch, 2)) |
18 return 1; | |
19 if(audiodb_l2norm(adb)) | |
20 return 1; | |
25 | 21 |
26 /* create new db */ | 22 adb_datum_t query = {2, 2, "testquery", (double[4]) {0, 0.5, 0.5, 0}}; |
27 //${AUDIODB} -d testdb -N | 23 adb_query_id_t qid = {0}; |
28 mydbp=audiodb_create(databasename,0,0,0); | 24 qid.datum = &query; |
25 qid.sequence_length = 1; | |
26 qid.sequence_start = 0; | |
27 adb_query_parameters_t parms = | |
28 {ADB_ACCUMULATION_PER_TRACK, ADB_DISTANCE_EUCLIDEAN_NORMED, 10, 10}; | |
29 adb_query_refine_t refine = {0}; | |
30 refine.hopsize = 1; | |
29 | 31 |
30 //intstring 2 > testfeature01 | 32 adb_query_spec_t spec; |
31 //floatstring 0 1 >> testfeature01 | 33 spec.qid = qid; |
32 //intstring 2 > testfeature10 | 34 spec.params = parms; |
33 //floatstring 1 0 >> testfeature10 | 35 spec.refine = refine; |
34 ivals[0]=2; | 36 |
35 dvals[0]=0; dvals[1]=1; | 37 adb_query_results_t *results = audiodb_query_spec(adb, &spec); |
36 maketestfile("testfeature01",ivals,dvals,2); | 38 if(!results || results->nresults != 2) return 1; |
37 ivals[0]=2; | 39 result_present_or_fail(results, "testfeature01", 0, 0, 0); |
38 dvals[0]=1; dvals[1]=0; | 40 result_present_or_fail(results, "testfeature10", 2, 0, 0); |
39 maketestfile("testfeature10",ivals,dvals,2); | 41 audiodb_query_free_results(adb, &spec, results); |
40 | 42 |
41 //cat > testfeaturefiles <<EOF | 43 spec.params.ntracks = 1; |
42 //testfeature01 | 44 results = audiodb_query_spec(adb, &spec); |
43 //testfeature10 | 45 if(!results || results->nresults != 1) return 1; |
44 //EOF | 46 result_present_or_fail(results, "testfeature01", 0, 0, 0); |
45 ins1[0].features="testfeature01"; | 47 audiodb_query_free_results(adb, &spec, results); |
46 ins1[1].features="testfeature10"; | 48 |
49 spec.qid.sequence_start = 1; | |
50 spec.params.ntracks = 10; | |
51 results = audiodb_query_spec(adb, &spec); | |
52 if(!results || results->nresults != 2) return 1; | |
53 result_present_or_fail(results, "testfeature10", 0, 1, 0); | |
54 result_present_or_fail(results, "testfeature01", 2, 1, 0); | |
55 audiodb_query_free_results(adb, &spec, results); | |
47 | 56 |
48 //audioDB -B -d testdb -F tempfeatures | 57 spec.params.ntracks = 1; |
49 //${AUDIODB} -d testdb -B -F testfeaturefiles | 58 results = audiodb_query_spec(adb, &spec); |
50 if(audiodb_batchinsert(mydbp,ins1,2)){ | 59 if(!results || results->nresults != 1) return 1; |
51 returnval=-1; | 60 result_present_or_fail(results, "testfeature10", 0, 1, 0); |
52 }; | 61 audiodb_query_free_results(adb, &spec, results); |
53 | 62 |
54 //# sequence queries require L2NORM | 63 audiodb_close(adb); |
55 //${AUDIODB} -d testdb -L | |
56 if(audiodb_l2norm(mydbp)){ | |
57 returnval=-1; | |
58 }; | |
59 | 64 |
60 ////echo "query point (0.0,0.5)" | 65 return 104; |
61 ////intstring 2 > testquery | |
62 ////floatstring 0 0.5 >> testquery | |
63 ////floatstring 0.5 0 >> testquery | |
64 | |
65 ivals[0]=2; | |
66 dvals[0]=0; dvals[1]=0.5; | |
67 dvals[2]=0.5; dvals[3]=0; | |
68 maketestfile("testquery",ivals,dvals,4); | |
69 | |
70 | |
71 | |
72 //${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -p 0 > testoutput | |
73 //echo testfeature01 0 0 0 > test-expected-output | |
74 //echo testfeature10 2 0 0 >> test-expected-output | |
75 //cmp testoutput test-expected-output | |
76 myadbquery.querytype="sequence"; | |
77 myadbquery.feature="testquery"; | |
78 myadbquery.sequencelength="1"; | |
79 myadbquery.qpoint="0"; | |
80 audiodb_query(mydbp,&myadbquery,&myadbqueryresult); | |
81 size=myadbqueryresult.sizeRlist; | |
82 | |
83 //printf("size:%d\n",size); | |
84 | |
85 ///* check the test values */ | |
86 if (size != 2) {returnval = -1;}; | |
87 if (testoneresult(&myadbqueryresult,0,"testfeature01",0,0,0)) {returnval = -1;}; | |
88 if (testoneresult(&myadbqueryresult,1,"testfeature10",2,0,0)) {returnval = -1;}; | |
89 | |
90 | |
91 | |
92 //${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -r 1 -p 0 > testoutput | |
93 //echo testfeature01 0 0 0 > test-expected-output | |
94 //cmp testoutput test-expected-output | |
95 myadbquery2.querytype="sequence"; | |
96 myadbquery2.feature="testquery"; | |
97 myadbquery2.sequencelength="1"; | |
98 myadbquery2.resultlength="1"; | |
99 myadbquery2.qpoint="0"; | |
100 audiodb_query(mydbp,&myadbquery2,&myadbqueryresult2); | |
101 size=myadbqueryresult2.sizeRlist; | |
102 | |
103 ///* check the test values */ | |
104 if (size != 1) {returnval = -1;}; | |
105 if (testoneresult(&myadbqueryresult2,0,"testfeature01",0,0,0)) {returnval = -1;}; | |
106 | |
107 | |
108 //echo "query point (0.5,0.0)" | |
109 | |
110 //${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -p 1 > testoutput | |
111 //echo testfeature10 0 1 0 > test-expected-output | |
112 //echo testfeature01 2 1 0 >> test-expected-output | |
113 //cmp testoutput test-expected-output | |
114 myadbquery3.querytype="sequence"; | |
115 myadbquery3.feature="testquery"; | |
116 myadbquery3.sequencelength="1"; | |
117 myadbquery3.qpoint="1"; | |
118 audiodb_query(mydbp,&myadbquery3,&myadbqueryresult3); | |
119 size=myadbqueryresult3.sizeRlist; | |
120 | |
121 if (size != 2) {returnval = -1;}; | |
122 if (testoneresult(&myadbqueryresult3,0,"testfeature10",0,1,0)) {returnval = -1;}; | |
123 if (testoneresult(&myadbqueryresult3,1,"testfeature01",2,1,0)) {returnval = -1;}; | |
124 | |
125 | |
126 ////${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -r 1 -p 1 > testoutput | |
127 ////echo testfeature10 0 1 0 > test-expected-output | |
128 ////cmp testoutput test-expected-output | |
129 myadbquery2.querytype="sequence"; | |
130 myadbquery2.feature="testquery"; | |
131 myadbquery2.sequencelength="1"; | |
132 myadbquery2.qpoint="1"; | |
133 myadbquery2.resultlength="1"; | |
134 audiodb_query(mydbp,&myadbquery2,&myadbqueryresult2); | |
135 size=myadbqueryresult2.sizeRlist; | |
136 | |
137 if (size != 1) {returnval = -1;}; | |
138 if (testoneresult(&myadbqueryresult2,0,"testfeature10",0,1,0)) {returnval = -1;}; | |
139 | |
140 | |
141 // printf("returnval:%d\n",returnval); | |
142 | |
143 return(returnval); | |
144 } | 66 } |
145 |