MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / test_bind_array

Function test_bind_array

tests/tools/cdb2bind.c:319–415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

317}
318
319void test_bind_array()
320{
321 cdb2_hndl_tp *hndl = NULL;
322 test_open(&hndl, db);
323
324 { // bind int32 array
325 int N = 2048;
326 int values[N];
327 for (int i = 0; i < N; i++) {
328 values[i] = i + 123;
329 }
330 cdb2_bind_array(hndl, "myintarr", CDB2_INTEGER, (const void *)values, N, sizeof(values[0]));
331 test_exec(hndl, "select * from carray(@myintarr) ");
332 for (int i = 0; i < N; i++) {
333 test_next_record(hndl);
334 int64_t *vala = cdb2_column_value(hndl, 0);
335 if (*vala != values[i]) {
336 fprintf(stderr, "%s:%d:error got:%"PRId64" expected:%d\n", __func__, __LINE__, *vala, values[i]);
337 exit(1);
338 }
339
340 //printf("TEST 05 RESP %"PRId64"\n", *vala);
341 }
342
343 cdb2_clearbindings(hndl);
344 }
345 { // bind int64 array
346 int N = 2048;
347 int64_t values[N];
348 for (int i = 0; i < N; i++) {
349 values[i] = i + 123;
350 }
351 cdb2_bind_array(hndl, "mylongintarr", CDB2_INTEGER, (const void *)values, N, sizeof(values[0]));
352 test_exec(hndl, "select * from carray(@mylongintarr) ");
353 for (int i = 0; i < N; i++) {
354 test_next_record(hndl);
355 int64_t *vala = cdb2_column_value(hndl, 0);
356 if (*vala != values[i]) {
357 fprintf(stderr, "%s:%d:error got:%"PRId64" expected:%"PRId64"\n", __func__, __LINE__, *vala, values[i]);
358 exit(1);
359 }
360
361 //printf("TEST 05 RESP %"PRId64"\n", *vala);
362 }
363
364 cdb2_clearbindings(hndl);
365 }
366
367 { // bind double array
368 int N = 2048;
369 double values[N];
370 for (int i = 0; i < N; i++) {
371 values[i] = i + 123;
372 }
373 cdb2_bind_array(hndl, "mydblarr", CDB2_REAL, (const void *)values, N, sizeof(values[0]));
374 test_exec(hndl, "select * from carray(@mydblarr) ");
375 for (int i = 0; i < N; i++) {
376 test_next_record(hndl);

Callers 1

mainFunction · 0.85

Calls 10

cdb2_bind_arrayFunction · 0.85
test_next_recordFunction · 0.85
cdb2_column_valueFunction · 0.85
exitFunction · 0.85
cdb2_clearbindingsFunction · 0.85
mallocFunction · 0.85
freeFunction · 0.85
test_closeFunction · 0.85
test_openFunction · 0.70
test_execFunction · 0.70

Tested by

no test coverage detected