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: void maketimesfile(char * filename); 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: 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: /* remove old directory */ mas01ik@355: //if [ -f testdb ]; then rm -f testdb; fi mas01ik@355: clean_remove_db(databasename); mas01ik@355: mas01ik@355: /* create new db */ mas01ik@355: //${AUDIODB} -d testdb -N mas01ik@355: mydbp=audiodb_create(databasename,0,0,0); mas01ik@355: mas01ik@355: //intstring 2 > testfeature mas01ik@355: //floatstring 0 0.5 >> testfeature mas01ik@355: //floatstring 0.5 0 >> testfeature mas01ik@355: ivals[0]=2; mas01ik@355: dvals[0]=0; dvals[1]=0.5; dvals[2]=0.5; dvals[3]=0; mas01ik@355: maketestfile("testfeature",ivals,dvals,4); mas01ik@355: mas01ik@355: mas01ik@355: //cat > testtimes < testquery mas01ik@355: //floatstring 0 0.5 >> testquery mas01ik@355: ivals[0]=2; mas01ik@355: dvals[0]=0; dvals[1]=0.5; mas01ik@355: maketestfile("testquery",ivals,dvals,2); mas01ik@355: mas01ik@355: //${AUDIODB} -d testdb -Q sequence -l 1 -f testquery > testoutput mas01ik@355: //echo testfeature 1 0 0 > test-expected-output mas01ik@355: //cmp testoutput test-expected-output mas01ik@355: myadbquery.querytype="sequence"; mas01ik@355: myadbquery.feature="testquery"; mas01ik@355: myadbquery.sequencelength="1"; 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 != 1) {returnval = -1;}; mas01ik@355: if (testoneresult(&myadbqueryresult,0,"testfeature",1,0,0)) {returnval = -1;}; mas01ik@355: mas01ik@355: mas01ik@355: ////${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -n 1 > testoutput mas01ik@355: ////echo testfeature 0 0 0 > test-expected-output mas01ik@355: ////cmp testoutput test-expected-output mas01ik@355: myadbquery.querytype="sequence"; mas01ik@355: myadbquery.feature="testquery"; mas01ik@355: myadbquery.sequencelength="1"; mas01ik@355: myadbquery.numpoints="1"; 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 != 1) {returnval = -1;}; mas01ik@355: if (testoneresult(&myadbqueryresult,0,"testfeature",0,0,0)) {returnval = -1;}; 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: ivals[0]=2; mas01ik@355: dvals[0]=0.5; dvals[1]=0.0; mas01ik@355: maketestfile("testquery",ivals,dvals,2); mas01ik@355: mas01ik@355: ////${AUDIODB} -d testdb -Q sequence -l 1 -f testquery > testoutput mas01ik@355: ////echo testfeature 1 0 1 > test-expected-output mas01ik@355: ////cmp testoutput test-expected-output mas01ik@355: myadbquery.querytype="sequence"; mas01ik@355: myadbquery.feature="testquery"; mas01ik@355: myadbquery.sequencelength="1"; mas01ik@355: myadbquery.numpoints=NULL; 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 != 1) {returnval = -1;}; mas01ik@355: if (testoneresult(&myadbqueryresult,0,"testfeature",1,0,1)) {returnval = -1;}; mas01ik@355: mas01ik@355: mas01ik@355: ////${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -n 1 > testoutput mas01ik@355: ////echo testfeature 0 0 1 > test-expected-output mas01ik@355: ////cmp testoutput test-expected-output mas01ik@355: myadbquery.querytype="sequence"; mas01ik@355: myadbquery.feature="testquery"; mas01ik@355: myadbquery.sequencelength="1"; mas01ik@355: myadbquery.numpoints="1"; 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 != 1) {returnval = -1;}; mas01ik@355: if (testoneresult(&myadbqueryresult,0,"testfeature",0,0,1)) {returnval = -1;}; mas01ik@355: mas01ik@355: mas01ik@355: mas01ik@355: //printf("returnval:%d\n",returnval); mas01ik@355: return(returnval); mas01ik@355: } mas01ik@355: mas01ik@355: void maketimesfile(char * filename){ mas01ik@355: mas01ik@355: FILE * myfile; mas01ik@355: mas01ik@355: myfile=fopen(filename,"w"); mas01ik@355: fprintf(myfile,"0\n"); mas01ik@355: fprintf(myfile,"1\n"); mas01ik@355: fprintf(myfile,"2\n"); mas01ik@355: fflush(myfile); mas01ik@355: fclose(myfile); mas01ik@355: mas01ik@355: }