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

Function test_map_ops

cachedb/test/test_cachedb.c:539–593  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

537}
538
539static int test_map_ops(cachedb_funcs *api, cachedb_con *con)
540{
541 cdb_dict_t cols1, cols2;
542 str key1, key2, subkey;
543 cdb_key_t field;
544 cdb_pair_t *pair;
545
546 if (!ok(test_map_set(api, con, &cols1, &cols2), "test map set") ||
547 !ok(test_map_get(api, con, &cols1, &cols2), "test map get"))
548 return 0;
549
550 init_str(&subkey, "subkeyAB");
551
552 if (!ok(api->map_remove(con, NULL, &subkey) == 0))
553 return 0;
554
555 cdb_free_entries(&cols1, osips_pkg_free);
556 cdb_free_entries(&cols2, osips_pkg_free);
557
558 cdb_dict_init(&cols1);
559
560 init_str(&key1, "keyC");
561 init_str(&subkey, "subkeyCD");
562
563 cdb_key_init(&field, "field_str");
564 pair = cdb_mk_pair(&field, NULL);
565 pair->val.type = CDB_STR;
566 init_str(&pair->val.val.st, pkg_strdup("baz"));
567 cdb_dict_add(pair, &cols1);
568
569 api->map_set(con, &key1, &subkey, &cols1);
570
571 cdb_dict_init(&cols2);
572
573 init_str(&key2, "keyD");
574 init_str(&subkey, "subkeyCD");
575
576 cdb_key_init(&field, "field_str");
577 pair = cdb_mk_pair(&field, NULL);
578 pair->val.type = CDB_STR;
579 init_str(&pair->val.val.st, pkg_strdup("biz"));
580 cdb_dict_add(pair, &cols2);
581
582 api->map_set(con, &key2, &subkey, &cols2);
583
584 if (!ok(api->map_remove(con, &key1, &subkey) == 0))
585 return 0;
586 if (!ok(api->map_remove(con, &key2, &subkey) == 0))
587 return 0;
588
589 cdb_free_entries(&cols1, osips_pkg_free);
590 cdb_free_entries(&cols2, osips_pkg_free);
591
592 return 1;
593}
594
595static void test_cachedb_api(const char *cachedb_name, const char *group1,
596 const char *group2)

Callers 1

test_cachedb_apiFunction · 0.85

Calls 9

test_map_setFunction · 0.85
test_map_getFunction · 0.85
init_strFunction · 0.85
cdb_free_entriesFunction · 0.85
cdb_dict_initFunction · 0.85
cdb_key_initFunction · 0.85
cdb_mk_pairFunction · 0.85
pkg_strdupFunction · 0.85
cdb_dict_addFunction · 0.85

Tested by

no test coverage detected