return head;
}
-static void search_ext(xbt_dict_t head, const char* key, const char* data)
+static void search_ext(const_xbt_dict_t head, const char* key, const char* data)
{
INFO("Search " << STR(key));
char* found = (char*)xbt_dict_get(head, key);
}
}
-static void search(xbt_dict_t head, const char* key)
+static void search(const_xbt_dict_t head, const char* key)
{
search_ext(head, key, key);
}
xbt_dict_remove(head, key);
}
-static void traverse(xbt_dict_t head)
+static void traverse(const_xbt_dict_t head)
{
xbt_dict_cursor_t cursor = nullptr;
char* key;
}
}
-static void search_not_found(xbt_dict_t head, const char* data)
+static void search_not_found(const_xbt_dict_t head, const char* data)
{
INFO("Search " << STR(data) << " (expected not to be found)");
REQUIRE_THROWS_AS(xbt_dict_get(head, data), std::out_of_range);
}
-static void count(xbt_dict_t dict, int length)
+static void count(const_xbt_dict_t dict, int length)
{
INFO("Count elements (expecting " << length << ")");
REQUIRE(xbt_dict_length(dict) == length); // Announced length differs
REQUIRE(effective == length); // Effective length differs
}
-static void count_check_get_key(xbt_dict_t dict, int length)
+static void count_check_get_key(const_xbt_dict_t dict, int length)
{
xbt_dict_cursor_t cursor;
char* key;
REQUIRE(effective == length); // Effective length differs
}
-static int countelems(xbt_dict_t head)
+static int countelems(const_xbt_dict_t head)
{
xbt_dict_cursor_t cursor;
char* key;
TEST_CASE("xbt::dict: dict data container", "dict")
{
-
SECTION("Basic usage: change, retrieve and traverse homogeneous dicts")
{
INFO("Traversal the null dictionary");
/* RETRIEVE */
INFO("Search 123");
- char* data = (char*)xbt_dict_get(head, "123");
+ const char* data = (char*)xbt_dict_get(head, "123");
REQUIRE((data && strcmp("123", data) == 0));
search_not_found(head, "Can't be found");
INFO("using 1000 elements with " << SIZEOFKEY << " chars long randomized keys.");
xbt_dict_t head = xbt_dict_new_homogeneous(free);
for (int j = 0; j < 1000; j++) {
- char* data = nullptr;
+ const char* data = nullptr;
char* key = (char*)xbt_malloc(SIZEOFKEY);
do {