int main(int argc, char *argv[]) { int i; odbc_use_version3 = 1; odbc_connect(); odbc_command("CREATE TABLE #odbc_test(i INT, t TEXT)"); for (i = 0; i < 10; ++i) { char buf[128]; sprintf(buf, "INSERT INTO #odbc_test(i, t) VALUES(%d, '%crow number %d')", i + 1, 'a' + i, i * 13); odbc_command(buf); } odbc_reset_statement(); test_query = "SELECT * FROM #odbc_test ORDER BY i"; printf("test line %d\n", __LINE__); query_test("S", "VVVVVVVVVV"); test_query = "SELECT * FROM #odbc_test WHERE i < 7 ORDER BY i"; printf("test line %d\n", __LINE__); query_test("S", "VVVVVV"); /* binding row */ test_query = "SELECT * FROM #odbc_test ORDER BY i"; record_bind = 1; printf("test line %d\n", __LINE__); query_test("S", "VVVVVVVVVV"); /* row and truncation */ trunc = 1; printf("test line %d\n", __LINE__); query_test("I", "!!!!!!!!!!"); /* TODO bind offset, SQLGetData, no bind, error */ odbc_disconnect(); printf("Success!.\n"); return 0; }
int main(int argc, char **argv) { std::vector<vector> points(LEN); gen_random(points); SpatialHash<vector> hash(10000.0f/LEN); TIME_IT(hash.insert(points)); #ifdef NOGUI TIME_IT(query_test(points, hash)); #else QApplication a(argc, argv); MainWindow w(&hash); w.show(); return a.exec(); #endif }
int main(int argc, char **argv) { std::map<std::string, int> m; const char *datafile; const char *queryfile; if(argc > 1) { datafile = argv[1]; } else { datafile = "/usr/share/dict/words"; } if(argc > 2) { queryfile = argv[2]; } else { queryfile = datafile; } std::cout << "Insert test\n"; insert_test(m, datafile); std::cout << "\n\nQuery test\n"; query_test(m, queryfile); return 0; }
DAAP_BLOCK *daap_response_songlist(char* metaStr, char* query) { DAAP_BLOCK *root; int g=1; DAAP_BLOCK *mlcl; DAAP_BLOCK *mlit; ENUMHANDLE henum; MP3FILE *current; MetaField_t meta; query_node_t* filter = 0; int songs = 0; DPRINTF(E_DBG,L_DAAP,"enter daap_response_songlist\n"); // if the meta tag is specified, encode it, if it's not specified // we're given the latitude to select our own subset, for // simplicity we just include everything. if(0 == metaStr) meta = (MetaField_t) -1ll; else meta = encodeMetaRequest(metaStr, gSongMetaDataMap); if(0 != query) { filter = query_build(query, song_fields); DPRINTF(E_INF,L_DAAP|L_QRY,"query: %s\n", query); if(err_debuglevel >= E_INF) /* this is broken */ query_dump(stderr,filter, 0); } DPRINTF(E_DBG,L_DAAP|L_DB,"Preparing to send db items\n"); henum=db_enum_begin(); if((!henum) && (db_get_song_count())) { DPRINTF(E_DBG,L_DAAP|L_DB,"Can't get enum handle - exiting daap_response_songlist\n"); return NULL; } root=daap_add_empty(NULL,"adbs"); if(root) { g = (int)daap_add_int(root,"mstt",200); g = g && daap_add_char(root,"muty",0); g = g && daap_add_int(root,"mtco",0); g = g && daap_add_int(root,"mrco",0); mlcl=daap_add_empty(root,"mlcl"); if(mlcl) { while(g && (current=db_enum(&henum))) { if(filter == 0 || query_test(filter, current)) { DPRINTF(E_DBG,L_DAAP|L_DB,"Got entry for %s\n",current->fname); // song entry generation extracted for usage with // playlists as well g = 0 != daap_add_song_entry(mlcl, current, meta); songs++; } } } else g=0; } db_enum_end(henum); if(filter != 0) query_free(filter); if(!g) { DPRINTF(E_DBG,L_DAAP|L_DB,"Error enumerating db - exiting daap_response_songlist\n"); daap_free(root); return NULL; } DPRINTF(E_DBG,L_DAAP|L_DB,"Successfully enumerated database - %d items\n",songs); daap_set_int(root, "mtco", songs); daap_set_int(root, "mrco", songs); DPRINTF(E_DBG,L_DAAP,"Exiting daap_response_songlist\n"); return root; }
int main(int argc, char *argv[]) { odbc_use_version3 = 1; odbc_connect(); if (odbc_db_is_microsoft()) { /* all successes */ test_query = T("INSERT INTO #tmp1 (id, value) VALUES (?, ?)"); multiply = 1; query_test(0, SQL_SUCCESS, "VVVVVVVVVV"); multiply = 1; query_test(1, SQL_SUCCESS, "VVVVVVVVVV"); /* all errors */ test_query = T("INSERT INTO #tmp1 (id, value) VALUES (?, ?)"); multiply = 257; query_test(0, SQL_ERROR, "!!!!!!!!!!"); multiply = 257; query_test(1, SQL_SUCCESS_WITH_INFO, "!!!!!!!!!!"); test_query = T("INSERT INTO #tmp1 (id, value) VALUES (?, ?)"); query_test(0, SQL_ERROR, "VV!!!!!!!!"); query_test(1, SQL_SUCCESS_WITH_INFO, "VV!!!!!!!!"); test_query = T("INSERT INTO #tmp1 (id, value) VALUES (900-?, ?)"); query_test(0, SQL_SUCCESS_WITH_INFO, "!!!!!!!VVV"); query_test(1, SQL_SUCCESS_WITH_INFO, "!!!!!!!VVV"); test_query = T("INSERT INTO #tmp1 (id) VALUES (?) UPDATE #tmp1 SET value = ?"); query_test(0, SQL_SUCCESS_WITH_INFO, "VVVV!V!V!V"); query_test(1, SQL_SUCCESS_WITH_INFO, "VV!!!!!!!!"); #ifdef ENABLE_DEVELOPING /* with result, see how SQLMoreResult work */ test_query = T("INSERT INTO #tmp1 (id) VALUES (?) SELECT * FROM #tmp1 UPDATE #tmp1 SET value = ?"); /* IMHO our driver is better here -- freddy77 */ query_test(0, SQL_SUCCESS, odbc_driver_is_freetds() ? "VVVVV!V!V!" : "VVVVVV!VVV"); query_test(1, SQL_SUCCESS, "VVVVVVVVVV"); #endif } else { /* Sybase test for conversions before executing */ test_query = T("INSERT INTO #tmp1 (id, value) VALUES (?/8, ?)"); query_test(0, SQL_SUCCESS, "VVVVVVVVVV"); } /* TODO record binding, array fetch, sqlputdata */ odbc_disconnect(); printf(failure ? "Failed :(\n" : "Success!\n"); return failure; }
main(int argc, char *argv[]) { int rval = -1, nsess = 8, nmedia = 2, nstreams = 3, level = 0; int cc = 0; extern char *optarg; extern int optind; char *uuid = NULL; char *label = NULL; hi op = BULL; progname = argv[0]; sesfile = "sessions"; ASSERT( argc > 1 ); mlog_init( argc, argv ); if (! inv_DEBUG_print(argc, argv)) return 0; optind = 1; optarg = 0; while( ( cc = getopt( argc, argv, GETOPT_CMDSTRING)) != EOF ) { switch ( cc ) { case 'w': op = WRI; break; case 'r': op = REC; break; case 'q': op = QUE; break; case 'd': op = DEL; break; case 'z': op = MP; break; case 'g': op = QUE2; break; case 'u': uuid = optarg; break; case 'L': label = optarg; break; case 's': nsess = atoi(optarg); break; case 'l': level = atoi(optarg); break; case 't': nstreams = atoi(optarg); break; case 'm': nmedia = atoi( optarg ); break; case 'v': break; case 'f': sesfile = optarg; break; default: usage(); break; } } if ( op == WRI ) rval = write_test( nsess, nstreams, nmedia, level ); else if ( op == QUE ) rval = query_test( level ); else if ( op == REC ) rval = recons_test( nsess ); else if ( op == DEL ) rval = delete_test( nsess ); else if ( op == MP ) rval = mp_test (nstreams); else if ( op == QUE2 ) { if (uuid) rval = sess_queries_byuuid(uuid); else if (label) rval = sess_queries_bylabel(label); } else usage(); if (rval < 0 ) printf( "aborted\n"); else printf( "done\n" ); }
static void test(const char * raw_query, int exp_error, struct expected exp[], int flags) { printf(" %-30s ", raw_query); printf("\r %s\n", query_test(raw_query, exp_error, exp, flags) ? "ERROR" : "OK"); }