annotate libtests/0023/prog1.c @ 369:6564be3109c5 gcc-4.3-cleanups

gcc-4.3 warning cleanups for lshlib.cpp (I do not believe that any of these changes contain significant copyrightable "intellectual property". However, to the extent that they do, the changes are hereby released into the Public Domain, and may be therefore be used by anyone for any purpose without need for consideration of any kind.)
author mas01cr
date Wed, 12 Nov 2008 15:23:32 +0000
parents 94c18f128ce8
children e072aa1611f5 342822c2d49a
rev   line source
mas01ik@355 1 #include <stdio.h>
mas01ik@355 2 #include <stdlib.h>
mas01ik@355 3 #include <string.h>
mas01ik@355 4 #include <sysexits.h>
mas01ik@355 5 #include <fcntl.h>
mas01ik@355 6 #include <dirent.h>
mas01ik@355 7 #include <unistd.h>
mas01ik@355 8 #include <sys/stat.h>
mas01ik@355 9 /*
mas01ik@355 10 * * #define NDEBUG
mas01ik@355 11 * * */
mas01ik@355 12 #include <assert.h>
mas01ik@355 13
mas01ik@355 14 #include "../../audioDB_API.h"
mas01ik@355 15 #include "../test_utils_lib.h"
mas01ik@355 16
mas01ik@355 17
mas01ik@355 18 int main(int argc, char **argv){
mas01ik@355 19
mas01ik@355 20 int returnval=0;
mas01ik@355 21 adb_ptr mydbp={0};
mas01ik@355 22 int ivals[10];
mas01ik@355 23 double dvals[10];
mas01ik@355 24 adb_insert_t myinsert={0};
mas01ik@355 25 char * databasename="testdb";
mas01ik@355 26 adb_query_t myadbquery={0};
mas01ik@355 27 adb_queryresult_t myadbqueryresult={0};
mas01ik@355 28 adb_query_t myadbquery2={0};
mas01ik@355 29 adb_queryresult_t myadbqueryresult2={0};
mas01ik@355 30 adb_query_t myadbquery3={0};
mas01ik@355 31 adb_queryresult_t myadbqueryresult3={0};
mas01ik@355 32 int size=0;
mas01ik@355 33 adb_insert_t ins1[2]={{0},{0}};
mas01ik@355 34
mas01ik@355 35 /* remove old directory */
mas01ik@355 36 //if [ -f testdb ]; then rm -f testdb; fi
mas01ik@355 37 clean_remove_db(databasename);
mas01ik@355 38
mas01ik@355 39 /* create new db */
mas01ik@355 40 //${AUDIODB} -d testdb -N
mas01ik@355 41 mydbp=audiodb_create(databasename,0,0,0);
mas01ik@355 42
mas01ik@355 43 //intstring 2 > testfeature01
mas01ik@355 44 //floatstring 0 1 >> testfeature01
mas01ik@355 45 //intstring 2 > testfeature10
mas01ik@355 46 //floatstring 1 0 >> testfeature10
mas01ik@355 47 ivals[0]=2;
mas01ik@355 48 dvals[0]=0; dvals[1]=1;
mas01ik@355 49 maketestfile("testfeature01",ivals,dvals,2);
mas01ik@355 50 ivals[0]=2;
mas01ik@355 51 dvals[0]=1; dvals[1]=0;
mas01ik@355 52 maketestfile("testfeature10",ivals,dvals,2);
mas01ik@355 53
mas01ik@355 54 //cat > testfeaturefiles <<EOF
mas01ik@355 55 //testfeature01
mas01ik@355 56 //testfeature10
mas01ik@355 57 //EOF
mas01ik@355 58 ins1[0].features="testfeature01";
mas01ik@355 59 ins1[1].features="testfeature10";
mas01ik@355 60
mas01ik@355 61 //audioDB -B -d testdb -F tempfeatures
mas01ik@355 62 //${AUDIODB} -d testdb -B -F testfeaturefiles
mas01ik@355 63 if(audiodb_batchinsert(mydbp,ins1,2)){
mas01ik@355 64 returnval=-1;
mas01ik@355 65 };
mas01ik@355 66
mas01ik@355 67 //# sequence queries require L2NORM
mas01ik@355 68 //${AUDIODB} -d testdb -L
mas01ik@355 69 if(audiodb_l2norm(mydbp)){
mas01ik@355 70 returnval=-1;
mas01ik@355 71 };
mas01ik@355 72
mas01ik@355 73 ////echo "query point (0.0,0.5)"
mas01ik@355 74 ////intstring 2 > testquery
mas01ik@355 75 ////floatstring 0 0.5 >> testquery
mas01ik@355 76 ////floatstring 0.5 0 >> testquery
mas01ik@355 77
mas01ik@355 78 ivals[0]=2;
mas01ik@355 79 dvals[0]=0; dvals[1]=0.5;
mas01ik@355 80 dvals[2]=0.5; dvals[3]=0;
mas01ik@355 81 maketestfile("testquery",ivals,dvals,4);
mas01ik@355 82
mas01ik@355 83
mas01ik@355 84
mas01ik@355 85 //${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -p 0 > testoutput
mas01ik@355 86 //echo testfeature01 0 0 0 > test-expected-output
mas01ik@355 87 //echo testfeature10 2 0 0 >> test-expected-output
mas01ik@355 88 //cmp testoutput test-expected-output
mas01ik@355 89 myadbquery.querytype="sequence";
mas01ik@355 90 myadbquery.feature="testquery";
mas01ik@355 91 myadbquery.sequencelength="1";
mas01ik@355 92 myadbquery.qpoint="0";
mas01ik@355 93 audiodb_query(mydbp,&myadbquery,&myadbqueryresult);
mas01ik@355 94 size=myadbqueryresult.sizeRlist;
mas01ik@355 95
mas01ik@355 96 //printf("size:%d\n",size);
mas01ik@355 97
mas01ik@355 98 //dump_query(&myadbquery,&myadbqueryresult);
mas01ik@355 99 ///* check the test values */
mas01ik@355 100 if (size != 2) {returnval = -1;};
mas01ik@355 101 if (testoneresult(&myadbqueryresult,0,"testfeature01",0,0,0)) {returnval = -1;};
mas01ik@355 102 if (testoneresult(&myadbqueryresult,1,"testfeature10",2,0,0)) {returnval = -1;};
mas01ik@355 103
mas01ik@355 104
mas01ik@355 105
mas01ik@355 106 //${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -r 1 -p 0 > testoutput
mas01ik@355 107 //echo testfeature01 0 0 0 > test-expected-output
mas01ik@355 108 //cmp testoutput test-expected-output
mas01ik@355 109 myadbquery2.querytype="sequence";
mas01ik@355 110 myadbquery2.feature="testquery";
mas01ik@355 111 myadbquery2.sequencelength="1";
mas01ik@355 112 myadbquery2.resultlength="1";
mas01ik@355 113 myadbquery2.qpoint="0";
mas01ik@355 114 audiodb_query(mydbp,&myadbquery2,&myadbqueryresult2);
mas01ik@355 115 size=myadbqueryresult2.sizeRlist;
mas01ik@355 116
mas01ik@355 117 ///* check the test values */
mas01ik@355 118 if (size != 1) {returnval = -1;};
mas01ik@355 119 if (testoneresult(&myadbqueryresult2,0,"testfeature01",0,0,0)) {returnval = -1;};
mas01ik@355 120
mas01ik@355 121
mas01ik@355 122 //echo "query point (0.5,0.0)"
mas01ik@355 123
mas01ik@355 124 //${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -p 1 > testoutput
mas01ik@355 125 //echo testfeature10 0 1 0 > test-expected-output
mas01ik@355 126 //echo testfeature01 2 1 0 >> test-expected-output
mas01ik@355 127 //cmp testoutput test-expected-output
mas01ik@355 128 myadbquery3.querytype="sequence";
mas01ik@355 129 myadbquery3.feature="testquery";
mas01ik@355 130 myadbquery3.sequencelength="1";
mas01ik@355 131 myadbquery3.qpoint="1";
mas01ik@355 132 audiodb_query(mydbp,&myadbquery3,&myadbqueryresult3);
mas01ik@355 133 size=myadbqueryresult3.sizeRlist;
mas01ik@355 134
mas01ik@355 135 // dump_query(&myadbquery3,&myadbqueryresult3);
mas01ik@355 136 if (size != 2) {returnval = -1;};
mas01ik@355 137 if (testoneresult(&myadbqueryresult3,0,"testfeature10",0,1,0)) {returnval = -1;};
mas01ik@355 138 if (testoneresult(&myadbqueryresult3,1,"testfeature01",2,1,0)) {returnval = -1;};
mas01ik@355 139
mas01ik@355 140
mas01ik@355 141 ////${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -r 1 -p 1 > testoutput
mas01ik@355 142 ////echo testfeature10 0 1 0 > test-expected-output
mas01ik@355 143 ////cmp testoutput test-expected-output
mas01ik@355 144 myadbquery2.querytype="sequence";
mas01ik@355 145 myadbquery2.feature="testquery";
mas01ik@355 146 myadbquery2.sequencelength="1";
mas01ik@355 147 myadbquery2.qpoint="1";
mas01ik@355 148 myadbquery2.resultlength="1";
mas01ik@355 149 audiodb_query(mydbp,&myadbquery2,&myadbqueryresult2);
mas01ik@355 150 size=myadbqueryresult2.sizeRlist;
mas01ik@355 151
mas01ik@355 152 if (size != 1) {returnval = -1;};
mas01ik@355 153 if (testoneresult(&myadbqueryresult2,0,"testfeature10",0,1,0)) {returnval = -1;};
mas01ik@355 154
mas01ik@355 155
mas01ik@355 156 // printf("returnval:%d\n",returnval);
mas01ik@355 157
mas01ik@355 158 return(returnval);
mas01ik@355 159 }
mas01ik@355 160