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: char * databasename="testdb"; mas01ik@355: adb_query_t myadbquery={0}; mas01ik@355: adb_queryresult_t myadbqueryresult={0}; mas01ik@355: adb_query_t myadbquery2={0}; mas01ik@355: adb_queryresult_t myadbqueryresult2={0}; mas01ik@355: adb_query_t myadbquery3={0}; mas01ik@355: adb_queryresult_t myadbqueryresult3={0}; mas01ik@355: int size=0; mas01ik@355: adb_insert_t ins1[2]={{0},{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 > testfeature01 mas01ik@355: //floatstring 0 1 >> testfeature01 mas01ik@355: //intstring 2 > testfeature10 mas01ik@355: //floatstring 1 0 >> testfeature10 mas01ik@355: ivals[0]=2; mas01ik@355: dvals[0]=0; dvals[1]=1; mas01ik@355: maketestfile("testfeature01",ivals,dvals,2); mas01ik@355: ivals[0]=2; mas01ik@355: dvals[0]=1; dvals[1]=0; mas01ik@355: maketestfile("testfeature10",ivals,dvals,2); mas01ik@355: mas01ik@355: //cat > testfeaturefiles < testquery mas01ik@355: ////floatstring 0 0.5 >> testquery mas01ik@355: ////floatstring 0.5 0 >> testquery mas01ik@355: mas01ik@355: ivals[0]=2; mas01ik@355: dvals[0]=0; dvals[1]=0.5; mas01ik@355: dvals[2]=0.5; dvals[3]=0; mas01ik@355: maketestfile("testquery",ivals,dvals,4); mas01ik@355: mas01ik@355: mas01ik@355: mas01ik@355: //${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -p 0 > testoutput mas01ik@355: //echo testfeature01 0 0 0 > test-expected-output mas01ik@355: //echo testfeature10 2 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.qpoint="0"; mas01ik@355: audiodb_query(mydbp,&myadbquery,&myadbqueryresult); mas01ik@355: size=myadbqueryresult.sizeRlist; mas01ik@355: mas01ik@355: //printf("size:%d\n",size); 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,"testfeature01",0,0,0)) {returnval = -1;}; mas01ik@355: if (testoneresult(&myadbqueryresult,1,"testfeature10",2,0,0)) {returnval = -1;}; mas01ik@355: mas01ik@355: mas01ik@355: mas01ik@355: //${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -r 1 -p 0 > testoutput mas01ik@355: //echo testfeature01 0 0 0 > test-expected-output mas01ik@355: //cmp testoutput test-expected-output mas01ik@355: myadbquery2.querytype="sequence"; mas01ik@355: myadbquery2.feature="testquery"; mas01ik@355: myadbquery2.sequencelength="1"; mas01ik@355: myadbquery2.resultlength="1"; mas01ik@355: myadbquery2.qpoint="0"; mas01ik@355: audiodb_query(mydbp,&myadbquery2,&myadbqueryresult2); mas01ik@355: size=myadbqueryresult2.sizeRlist; mas01ik@355: mas01ik@355: ///* check the test values */ mas01ik@355: if (size != 1) {returnval = -1;}; mas01ik@355: if (testoneresult(&myadbqueryresult2,0,"testfeature01",0,0,0)) {returnval = -1;}; mas01ik@355: mas01ik@355: mas01ik@355: //echo "query point (0.5,0.0)" mas01ik@355: mas01ik@355: //${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -p 1 > testoutput mas01ik@355: //echo testfeature10 0 1 0 > test-expected-output mas01ik@355: //echo testfeature01 2 1 0 >> test-expected-output mas01ik@355: //cmp testoutput test-expected-output mas01ik@355: myadbquery3.querytype="sequence"; mas01ik@355: myadbquery3.feature="testquery"; mas01ik@355: myadbquery3.sequencelength="1"; mas01ik@355: myadbquery3.qpoint="1"; mas01ik@355: audiodb_query(mydbp,&myadbquery3,&myadbqueryresult3); mas01ik@355: size=myadbqueryresult3.sizeRlist; mas01ik@355: mas01ik@355: // dump_query(&myadbquery3,&myadbqueryresult3); mas01ik@355: if (size != 2) {returnval = -1;}; mas01ik@355: if (testoneresult(&myadbqueryresult3,0,"testfeature10",0,1,0)) {returnval = -1;}; mas01ik@355: if (testoneresult(&myadbqueryresult3,1,"testfeature01",2,1,0)) {returnval = -1;}; mas01ik@355: mas01ik@355: mas01ik@355: ////${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -r 1 -p 1 > testoutput mas01ik@355: ////echo testfeature10 0 1 0 > test-expected-output mas01ik@355: ////cmp testoutput test-expected-output mas01ik@355: myadbquery2.querytype="sequence"; mas01ik@355: myadbquery2.feature="testquery"; mas01ik@355: myadbquery2.sequencelength="1"; mas01ik@355: myadbquery2.qpoint="1"; mas01ik@355: myadbquery2.resultlength="1"; mas01ik@355: audiodb_query(mydbp,&myadbquery2,&myadbqueryresult2); mas01ik@355: size=myadbqueryresult2.sizeRlist; mas01ik@355: mas01ik@355: if (size != 1) {returnval = -1;}; mas01ik@355: if (testoneresult(&myadbqueryresult2,0,"testfeature10",0,1,0)) {returnval = -1;}; mas01ik@355: mas01ik@355: mas01ik@355: // printf("returnval:%d\n",returnval); mas01ik@355: mas01ik@355: return(returnval); mas01ik@355: } mas01ik@355: