- struct bt_value *obj;
-
- ok(bt_value_freeze(NULL) == BT_VALUE_STATUS_INVAL,
- "bt_value_freeze() fails with an value object set to NULL");
- ok(!bt_value_freeze(bt_value_null),
- "bt_value_freeze() succeeds with a null value object");
-
- ok(!bt_value_is_frozen(NULL), "NULL is not frozen");
- ok(bt_value_is_frozen(bt_value_null),
- "the null singleton is frozen");
- obj = bt_value_integer_create();
- assert(obj);
- ok(!bt_value_is_frozen(obj),
- "bt_value_is_frozen() returns false with a fresh value object");
- assert(!bt_value_freeze(obj));
- ok(!bt_value_freeze(obj),
- "bt_value_freeze() passes with a frozen value object");
- ok(bt_value_is_frozen(obj),
- "bt_value_is_frozen() returns true with a frozen value object");
-
- BT_PUT(obj);
+ bt_value *base_map = bt_value_map_create();
+ bt_value *extension_map = bt_value_map_create();
+ bt_value *extended_map = NULL;
+ bt_value *array = bt_value_array_create();
+ bt_value_map_insert_entry_status insert_status;
+ bt_value_map_extend_status extend_status;
+
+ BT_ASSERT(base_map);
+ BT_ASSERT(extension_map);
+ BT_ASSERT(array);
+ insert_status = bt_value_map_insert_bool_entry(base_map, "file",
+ BT_TRUE);
+ BT_ASSERT(insert_status == BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK);
+ insert_status = bt_value_map_insert_bool_entry(base_map, "edit",
+ BT_FALSE);
+ BT_ASSERT(insert_status == BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK);
+ insert_status = bt_value_map_insert_signed_integer_entry(base_map,
+ "selection", 17);
+ BT_ASSERT(insert_status == BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK);
+ insert_status = bt_value_map_insert_signed_integer_entry(base_map, "find",
+ -34);
+ BT_ASSERT(insert_status == BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK);
+ insert_status = bt_value_map_insert_bool_entry(extension_map, "edit",
+ BT_TRUE);
+ BT_ASSERT(insert_status == BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK);
+ insert_status = bt_value_map_insert_signed_integer_entry(extension_map,
+ "find", 101);
+ BT_ASSERT(insert_status == BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK);
+ insert_status = bt_value_map_insert_real_entry(extension_map,
+ "project", -404);
+ BT_ASSERT(insert_status == BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK);
+ extend_status = bt_value_map_extend(base_map, extension_map, &extended_map);
+ ok(extend_status == BT_VALUE_MAP_EXTEND_STATUS_OK &&
+ extended_map, "bt_value_map_extend() succeeds");
+ ok(bt_value_map_get_size(extended_map) == 5,
+ "bt_value_map_extend() returns a map object with the correct size");
+ ok(compare_map_elements(base_map,
+ extended_map, "file"),
+ "bt_value_map_extend() picks the appropriate element (file)");
+ ok(compare_map_elements(extension_map,
+ extended_map, "edit"),
+ "bt_value_map_extend() picks the appropriate element (edit)");
+ ok(compare_map_elements(base_map,
+ extended_map, "selection"),
+ "bt_value_map_extend() picks the appropriate element (selection)");
+ ok(compare_map_elements(extension_map,
+ extended_map, "find"),
+ "bt_value_map_extend() picks the appropriate element (find)");
+ ok(compare_map_elements(extension_map,
+ extended_map, "project"),
+ "bt_value_map_extend() picks the appropriate element (project)");
+
+ BT_VALUE_PUT_REF_AND_RESET(array);
+ BT_VALUE_PUT_REF_AND_RESET(base_map);
+ BT_VALUE_PUT_REF_AND_RESET(extension_map);
+ BT_VALUE_PUT_REF_AND_RESET(extended_map);