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]={0}; mas01ik@355: double dvals[10]={0.0}; mas01ik@355: adb_insert_t myinsert={0}; mas01ik@355: unsigned int myerr=0; mas01ik@355: adb_query_t myadbquery={0}; mas01ik@355: adb_queryresult_t myadbqueryresult={0}; mas01ik@355: char * databasename="testdb"; mas01ik@355: int size=0; mas01ik@355: mas01ik@355: mas01ik@355: /* remove old directory */ mas01ik@355: //if [ -f testdb ]; then rm -f testdb; fi mas01ik@355: // mas01ik@355: clean_remove_db(databasename); mas01ik@355: 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: /* turn on l2norm */ mas01ik@355: //# point query now implemented as sequence search mas01ik@355: //${AUDIODB} -d testdb -L mas01ik@355: audiodb_l2norm(mydbp); mas01ik@355: mas01ik@355: /* make a test file */ mas01ik@355: //# FIXME: endianness! mas01ik@355: //intstring 1 > testfeature mas01ik@355: //floatstring 1 >> testfeature mas01ik@355: ivals[0]=1; mas01ik@355: dvals[0]=1; mas01ik@355: maketestfile("testfeature",ivals,dvals,1); mas01ik@355: mas01ik@355: /* insert */ mas01ik@355: //${AUDIODB} -d testdb -I -f testfeature mas01ik@355: myinsert.features="testfeature"; mas01ik@355: myerr=audiodb_insert(mydbp,&myinsert); mas01ik@355: mas01ik@355: /* query */ mas01ik@355: //${AUDIODB} -d testdb -Q point -f testfeature > test-query-output mas01ik@355: myadbquery.querytype="point"; mas01ik@355: myadbquery.feature="testfeature"; mas01ik@355: audiodb_query(mydbp,&myadbquery,&myadbqueryresult); mas01ik@355: mas01ik@355: /* check the test values */ mas01ik@355: //echo testfeature 1 0 0 > test-expected-query-output mas01ik@355: //cmp test-query-output test-expected-query-output mas01ik@355: size=myadbqueryresult.sizeRlist; 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: //# mas01ik@355: //## failure cases mas01ik@355: //expect_clean_error_exit ${AUDIODB} -d testdb -I mas01ik@355: //expect_clean_error_exit ${AUDIODB} -d testdb -f testfeature mas01ik@355: //expect_clean_error_exit ${AUDIODB} -I -f testfeature mas01ik@355: //expect_clean_error_exit ${AUDIODB} -d testdb -Q notpoint -f testfeature mas01ik@355: //expect_clean_error_exit ${AUDIODB} -Q point -f testfeature mas01ik@355: /* all of these will fail at compile time because of API */ mas01ik@355: mas01ik@355: audiodb_close(mydbp); mas01ik@355: mas01ik@355: return(returnval); mas01ik@355: } mas01ik@355: mas01ik@355: mas01ik@355: mas01ik@355: mas01ik@355: