mas01ik@355: #include mas01ik@355: #include mas01ik@355: #include mas01ik@355: #include mas01ik@355: #include mas01ik@355: #include mas01ik@355: #include mas01ik@355: #include mas01ik@355: /* mas01ik@355: * * #define NDEBUG mas01ik@355: * * */ mas01ik@355: #include mas01ik@355: mas01ik@355: #include "../../audioDB_API.h" mas01ik@355: #include "../test_utils_lib.h" mas01ik@355: mas01ik@355: mas01ik@355: int main(int argc, char **argv){ mas01ik@355: mas01ik@355: int returnval=0; mas01ik@355: adb_ptr mydbp={0}; mas01ik@355: int ivals[10]; mas01ik@355: double dvals[10]; mas01ik@355: adb_insert_t myinsert={0}; mas01ik@355: unsigned int myerr=0; mas01ik@355: char * databasename="testdb"; mas01ik@355: adb_query_t myadbquery={0}; mas01ik@355: adb_queryresult_t myadbqueryresult={0}; mas01ik@355: int size=0; mas01ik@355: mas01ik@355: /* clean */ mas01ik@355: //if [ -f testdb ]; then rm -f testdb; fi mas01ik@355: clean_remove_db(databasename); mas01ik@355: mas01ik@355: /* new db */ mas01ik@355: //${AUDIODB} -d testdb -N mas01ik@355: mydbp=audiodb_create(databasename,0,0,0); mas01ik@355: mas01ik@355: /* test feature files */ mas01ik@355: //intstring 2 > testfeature01 mas01ik@355: //floatstring 0 1 >> testfeature01 mas01ik@355: ivals[0]=2; mas01ik@355: dvals[0]=0; dvals[1]=1; mas01ik@355: maketestfile("testfeature01",ivals,dvals,2); mas01ik@355: //intstring 2 > testfeature10 mas01ik@355: //floatstring 1 0 >> testfeature10 mas01ik@355: ivals[0]=2; mas01ik@355: dvals[0]=1; dvals[1]=0; mas01ik@355: maketestfile("testfeature10",ivals,dvals,2); mas01ik@355: mas01ik@355: /* inserts */ mas01ik@355: //${AUDIODB} -d testdb -I -f testfeature01 mas01ik@355: //${AUDIODB} -d testdb -I -f testfeature10 mas01ik@355: myinsert.features="testfeature01"; mas01ik@355: myerr=audiodb_insert(mydbp,&myinsert); mas01ik@355: myinsert.features="testfeature10"; mas01ik@355: myerr=audiodb_insert(mydbp,&myinsert); mas01ik@355: mas01ik@355: /* l2norm */ mas01ik@355: //# sequence queries require L2NORM mas01ik@355: //${AUDIODB} -d testdb -L mas01ik@355: audiodb_l2norm(mydbp); mas01ik@355: mas01ik@355: /* query 1 */ mas01ik@355: //echo "query point (0.0,0.5)" mas01ik@355: //intstring 2 > testquery mas01ik@355: //floatstring 0 0.5 >> testquery mas01ik@355: ivals[0]=2; mas01ik@355: dvals[0]=0; dvals[1]=0.5; dvals[2]=0; dvals[3]=0; mas01ik@355: maketestfile("testquery",ivals,dvals,2); mas01ik@355: mas01ik@355: //${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -R 5 > testoutput mas01ik@355: //echo testfeature01 1 > test-expected-output mas01ik@355: //echo testfeature10 1 >> test-expected-output mas01ik@355: //cmp testoutput test-expected-output mas01ik@355: mas01ik@355: myadbquery.querytype="sequence"; mas01ik@355: myadbquery.feature="testquery"; mas01ik@355: myadbquery.sequencelength="1"; mas01ik@355: myadbquery.radius="5"; mas01ik@355: audiodb_query(mydbp,&myadbquery,&myadbqueryresult); mas01ik@355: size=myadbqueryresult.sizeRlist; mas01ik@355: mas01ik@355: dump_query(&myadbquery,&myadbqueryresult); mas01ik@355: /* check the test values */ mas01ik@355: if (size != 2) {returnval = -1;}; mas01ik@355: //if (testoneresult(&myadbqueryresult,0,"testfeature",1,0,0)) {returnval = -1;}; mas01ik@355: //if (testoneresult(&myadbqueryresult,1,"testfeature",1,0,0)) {returnval = -1;}; mas01ik@355: mas01ik@355: mas01ik@355: /* query 2 */ mas01ik@355: //${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -r 1 -R 5 > testoutput mas01ik@355: //echo testfeature01 1 > test-expected-output mas01ik@355: //cmp testoutput test-expected-output mas01ik@355: // mas01ik@355: //echo "query point (0.5,0.0)" mas01ik@355: //intstring 2 > testquery mas01ik@355: //floatstring 0.5 0 >> testquery mas01ik@355: mas01ik@355: mas01ik@355: /* query 3 */ mas01ik@355: //# FIXME: because there's only one point in each track (and the query), mas01ik@355: //# the ordering is essentially database order. We need these test mas01ik@355: //# cases anyway because we need to test non-segfaulting, non-empty mas01ik@355: //# results... mas01ik@355: // mas01ik@355: //${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -R 5 > testoutput mas01ik@355: //echo testfeature01 1 > test-expected-output mas01ik@355: //echo testfeature10 1 >> test-expected-output mas01ik@355: //cmp testoutput test-expected-output mas01ik@355: mas01ik@355: mas01ik@355: mas01ik@355: /* query 4 */ mas01ik@355: //${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -r 1 -R 5 > testoutput mas01ik@355: //echo testfeature01 1 > test-expected-output mas01ik@355: //cmp testoutput test-expected-output mas01ik@355: mas01ik@355: mas01ik@355: printf("returnval:%d\n",returnval); mas01ik@355: //returnval=-1; mas01ik@355: mas01ik@355: return(returnval); mas01ik@355: } mas01ik@355: