Mercurial > hg > audiodb
comparison libtests/0036/prog1.c @ 494:1327b5cf4cb5 api-inversion
Finish rewriting libtests.
author | mas01cr |
---|---|
date | Sat, 10 Jan 2009 15:33:16 +0000 |
parents | e072aa1611f5 |
children |
comparison
equal
deleted
inserted
replaced
493:1950d76be128 | 494:1327b5cf4cb5 |
---|---|
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; | |
4 | 6 |
5 int main(int argc, char **argv){ | 7 clean_remove_db(TESTDB); |
8 if(!(adb = audiodb_create(TESTDB, 0, 0, 0))) | |
9 return 1; | |
6 | 10 |
7 int returnval=0; | 11 adb_datum_t datum1 = {2, 2, "testfeature01", (double[4]) {0, 1, 1, 0}}; |
8 adb_ptr mydbp={0}; | 12 adb_datum_t datum2 = {2, 2, "testfeature10", (double[4]) {1, 0, 0, 1}}; |
9 int ivals[10]; | |
10 double dvals[10]; | |
11 adb_insert_t myinsert={0}; | |
12 unsigned int myerr=0; | |
13 char * databasename="testdb"; | |
14 adb_query_t myadbquery={0}; | |
15 adb_queryresult_t myadbqueryresult={0}; | |
16 adb_query_t myadbquery2={0}; | |
17 adb_queryresult_t myadbqueryresult2={0}; | |
18 int size=0; | |
19 | 13 |
14 if(audiodb_insert_datum(adb, &datum1)) | |
15 return 1; | |
16 if(audiodb_insert_datum(adb, &datum2)) | |
17 return 1; | |
18 if(audiodb_l2norm(adb)) | |
19 return 1; | |
20 | 20 |
21 return 14; | 21 adb_datum_t query = {1, 2, NULL, (double [2]){0, 0.5}, NULL, NULL}; |
22 adb_query_id_t qid = {0}; | |
23 qid.datum = &query; | |
24 qid.sequence_length = 1; | |
25 adb_query_parameters_t parms = | |
26 {ADB_ACCUMULATION_PER_TRACK, ADB_DISTANCE_EUCLIDEAN_NORMED, 10, 10}; | |
27 adb_query_refine_t refine = {0}; | |
28 refine.hopsize = 1; | |
22 | 29 |
23 //#! /bin/bash | 30 adb_query_spec_t spec; |
24 // | 31 spec.qid = qid; |
25 //. ../test-utils.sh | 32 spec.params = parms; |
26 // | 33 spec.refine = refine; |
27 //if [ -f testdb ]; then rm -f testdb; fi | |
28 // | |
29 //${AUDIODB} -d testdb -N | |
30 // | |
31 //intstring 2 > testfeature01 | |
32 //floatstring 0 1 >> testfeature01 | |
33 //floatstring 1 0 >> testfeature01 | |
34 //intstring 2 > testfeature10 | |
35 //floatstring 1 0 >> testfeature10 | |
36 //floatstring 0 1 >> testfeature10 | |
37 // | |
38 //cat > testfeaturefiles <<EOF | |
39 //testfeature01 | |
40 //testfeature10 | |
41 //EOF | |
42 // | |
43 //${AUDIODB} -d testdb -B -F testfeaturefiles | |
44 // | |
45 //# sequence queries require L2NORM | |
46 //${AUDIODB} -d testdb -L | |
47 // | |
48 //echo "query point (0.0,0.5)" | |
49 //intstring 2 > testquery | |
50 //floatstring 0 0.5 >> testquery | |
51 // | |
52 //${AUDIODB} -d testdb -Q nsequence -l 1 -f testquery > testoutput | |
53 //echo testfeature01 1 > test-expected-output | |
54 //echo 0 0 0 >> test-expected-output | |
55 //echo 2 0 1 >> test-expected-output | |
56 //echo testfeature10 1 >> test-expected-output | |
57 //echo 0 0 1 >> test-expected-output | |
58 //echo 2 0 0 >> test-expected-output | |
59 //cmp testoutput test-expected-output | |
60 // | |
61 //${AUDIODB} -d testdb -Q nsequence -l 1 -f testquery -n 2 > testoutput | |
62 //cmp testoutput test-expected-output | |
63 // | |
64 //${AUDIODB} -d testdb -Q nsequence -l 1 -f testquery -n 5 > testoutput | |
65 //cmp testoutput test-expected-output | |
66 // | |
67 //${AUDIODB} -d testdb -Q nsequence -l 1 -f testquery -n 1 > testoutput | |
68 //echo testfeature01 0 > test-expected-output | |
69 //echo 0 0 0 >> test-expected-output | |
70 //echo testfeature10 0 >> test-expected-output | |
71 //echo 0 0 1 >> test-expected-output | |
72 //cmp testoutput test-expected-output | |
73 // | |
74 //echo "query point (0.5,0.0)" | |
75 //intstring 2 > testquery | |
76 //floatstring 0.5 0 >> testquery | |
77 // | |
78 //${AUDIODB} -d testdb -Q nsequence -l 1 -f testquery > testoutput | |
79 //echo testfeature01 1 > test-expected-output | |
80 //echo 0 0 1 >> test-expected-output | |
81 //echo 2 0 0 >> test-expected-output | |
82 //echo testfeature10 1 >> test-expected-output | |
83 //echo 0 0 0 >> test-expected-output | |
84 //echo 2 0 1 >> test-expected-output | |
85 //cmp testoutput test-expected-output | |
86 // | |
87 //${AUDIODB} -d testdb -Q nsequence -l 1 -f testquery -n 2 > testoutput | |
88 //cmp testoutput test-expected-output | |
89 // | |
90 //${AUDIODB} -d testdb -Q nsequence -l 1 -f testquery -n 5 > testoutput | |
91 //cmp testoutput test-expected-output | |
92 // | |
93 //${AUDIODB} -d testdb -Q nsequence -l 1 -f testquery -n 1 > testoutput | |
94 //echo testfeature01 0 > test-expected-output | |
95 //echo 0 0 1 >> test-expected-output | |
96 //echo testfeature10 0 >> test-expected-output | |
97 //echo 0 0 0 >> test-expected-output | |
98 //cmp testoutput test-expected-output | |
99 // | |
100 //exit 104 | |
101 | 34 |
102 returnval=-1; | 35 adb_query_results_t *results = audiodb_query_spec(adb, &spec); |
103 | 36 |
104 return(returnval); | 37 if(!results || results->nresults != 4) return 1; |
38 result_present_or_fail(results, "testfeature01", 0, 0, 0); | |
39 result_present_or_fail(results, "testfeature01", 2, 0, 1); | |
40 result_present_or_fail(results, "testfeature10", 0, 0, 1); | |
41 result_present_or_fail(results, "testfeature10", 2, 0, 0); | |
42 audiodb_query_free_results(adb, &spec, results); | |
43 | |
44 spec.params.npoints = 2; | |
45 results = audiodb_query_spec(adb, &spec); | |
46 | |
47 if(!results || results->nresults != 4) return 1; | |
48 result_present_or_fail(results, "testfeature01", 0, 0, 0); | |
49 result_present_or_fail(results, "testfeature01", 2, 0, 1); | |
50 result_present_or_fail(results, "testfeature10", 0, 0, 1); | |
51 result_present_or_fail(results, "testfeature10", 2, 0, 0); | |
52 audiodb_query_free_results(adb, &spec, results); | |
53 | |
54 spec.params.npoints = 5; | |
55 results = audiodb_query_spec(adb, &spec); | |
56 | |
57 if(!results || results->nresults != 4) return 1; | |
58 result_present_or_fail(results, "testfeature01", 0, 0, 0); | |
59 result_present_or_fail(results, "testfeature01", 2, 0, 1); | |
60 result_present_or_fail(results, "testfeature10", 0, 0, 1); | |
61 result_present_or_fail(results, "testfeature10", 2, 0, 0); | |
62 audiodb_query_free_results(adb, &spec, results); | |
63 | |
64 spec.params.npoints = 1; | |
65 results = audiodb_query_spec(adb, &spec); | |
66 | |
67 if(!results || results->nresults != 2) return 1; | |
68 result_present_or_fail(results, "testfeature01", 0, 0, 0); | |
69 result_present_or_fail(results, "testfeature10", 0, 0, 1); | |
70 | |
71 audiodb_query_free_results(adb, &spec, results); | |
72 | |
73 spec.qid.datum->data = (double [2]) {0.5, 0}; | |
74 spec.params.npoints = 10; | |
75 results = audiodb_query_spec(adb, &spec); | |
76 | |
77 if(!results || results->nresults != 4) return 1; | |
78 result_present_or_fail(results, "testfeature01", 0, 0, 1); | |
79 result_present_or_fail(results, "testfeature01", 2, 0, 0); | |
80 result_present_or_fail(results, "testfeature10", 0, 0, 0); | |
81 result_present_or_fail(results, "testfeature10", 2, 0, 1); | |
82 audiodb_query_free_results(adb, &spec, results); | |
83 | |
84 spec.params.npoints = 2; | |
85 results = audiodb_query_spec(adb, &spec); | |
86 | |
87 if(!results || results->nresults != 4) return 1; | |
88 result_present_or_fail(results, "testfeature01", 0, 0, 1); | |
89 result_present_or_fail(results, "testfeature01", 2, 0, 0); | |
90 result_present_or_fail(results, "testfeature10", 0, 0, 0); | |
91 result_present_or_fail(results, "testfeature10", 2, 0, 1); | |
92 audiodb_query_free_results(adb, &spec, results); | |
93 | |
94 spec.params.npoints = 5; | |
95 results = audiodb_query_spec(adb, &spec); | |
96 | |
97 if(!results || results->nresults != 4) return 1; | |
98 result_present_or_fail(results, "testfeature01", 0, 0, 1); | |
99 result_present_or_fail(results, "testfeature01", 2, 0, 0); | |
100 result_present_or_fail(results, "testfeature10", 0, 0, 0); | |
101 result_present_or_fail(results, "testfeature10", 2, 0, 1); | |
102 audiodb_query_free_results(adb, &spec, results); | |
103 | |
104 spec.params.npoints = 1; | |
105 results = audiodb_query_spec(adb, &spec); | |
106 | |
107 if(!results || results->nresults != 2) return 1; | |
108 result_present_or_fail(results, "testfeature01", 0, 0, 1); | |
109 result_present_or_fail(results, "testfeature10", 0, 0, 0); | |
110 audiodb_query_free_results(adb, &spec, results); | |
111 | |
112 audiodb_close(adb); | |
113 | |
114 return 104; | |
105 } | 115 } |
106 |