- 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);
+ struct bt_value *base_map = bt_value_map_create();
+ struct bt_value *extension_map = bt_value_map_create();
+ struct bt_value *extended_map = NULL;
+ struct bt_value *array = bt_value_array_create();
+ enum bt_value_status status;
+
+ BT_ASSERT(base_map);
+ BT_ASSERT(extension_map);
+ BT_ASSERT(array);
+ status = bt_value_map_insert_bool(base_map, "file", BT_TRUE);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_value_map_insert_bool(base_map, "edit", BT_FALSE);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_value_map_insert_integer(base_map, "selection", 17);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_value_map_insert_integer(base_map, "find", -34);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_value_map_insert_bool(extension_map, "edit", BT_TRUE);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_value_map_insert_integer(extension_map, "find", 101);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ status = bt_value_map_insert_float(extension_map, "project", -404);
+ BT_ASSERT(status == BT_VALUE_STATUS_OK);
+ extended_map = bt_value_map_extend(base_map, extension_map);
+ ok(extended_map, "bt_value_map_extend() succeeds");
+ ok(bt_value_map_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_PUT(array);
+ BT_PUT(base_map);
+ BT_PUT(extension_map);
+ BT_PUT(extended_map);