MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / test_map_get

Function test_map_get

cachedb/test/test_cachedb.c:502–537  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

500}
501
502static int test_map_get(cachedb_funcs *api, cachedb_con *con,
503 const cdb_dict_t *pairs1, const cdb_dict_t *pairs2)
504{
505 cdb_res_t res;
506 cdb_row_t *row;
507 struct list_head *_;
508 cdb_pair_t *pair1, *pair2;
509 cdb_key_t key1, key2;
510 int found = 0;
511
512 if (!ok(api->map_get(con, NULL, &res) == 0))
513 return 0;
514
515 key1.is_pk = 1;
516 init_str(&key1.name, "keyA");
517 key2.is_pk = 1;
518 init_str(&key2.name, "keyB");
519
520 list_for_each (_, &res.rows) {
521 row = list_entry(_, cdb_row_t, list);
522
523 pair1 = cdb_dict_fetch(&key1, &row->dict);
524 if (pair1 && dict_cmp(&pair1->val.val.dict, pairs1) == 0)
525 found++;
526 pair2 = cdb_dict_fetch(&key2, &row->dict);
527 if (pair2 && dict_cmp(&pair2->val.val.dict, pairs2) == 0)
528 found++;
529 }
530
531 cdb_free_rows(&res);
532
533 if (!ok(found == 2))
534 return 0;
535
536 return 1;
537}
538
539static int test_map_ops(cachedb_funcs *api, cachedb_con *con)
540{

Callers 1

test_map_opsFunction · 0.85

Calls 5

init_strFunction · 0.85
cdb_dict_fetchFunction · 0.85
dict_cmpFunction · 0.85
cdb_free_rowsFunction · 0.85
list_entryClass · 0.50

Tested by

no test coverage detected