summary refs log tree commit diff stats
path: root/rust/qemu-api/tests
diff options
context:
space:
mode:
Diffstat (limited to 'rust/qemu-api/tests')
-rw-r--r--rust/qemu-api/tests/tests.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/rust/qemu-api/tests/tests.rs b/rust/qemu-api/tests/tests.rs
index 5c3e75ed3d..5f6096a572 100644
--- a/rust/qemu-api/tests/tests.rs
+++ b/rust/qemu-api/tests/tests.rs
@@ -15,7 +15,7 @@ use qemu_api::{
     declare_properties, define_property,
     prelude::*,
     qdev::{DeviceClass, DeviceImpl, DeviceState, Property},
-    qom::{ClassInitImpl, ObjectImpl, ParentField},
+    qom::{ClassInitImpl, ObjectImpl, Owned, ParentField},
     vmstate::VMStateDescription,
     zeroable::Zeroable,
 };
@@ -139,6 +139,17 @@ fn test_object_new() {
 }
 
 #[test]
+#[allow(clippy::redundant_clone)]
+/// Create, clone and then drop an instance.
+fn test_clone() {
+    init_qom();
+    let p: *mut DummyState = unsafe { object_new(DummyState::TYPE_NAME.as_ptr()).cast() };
+    let p = unsafe { Owned::from_raw(p) };
+    assert_eq!(p.clone().typename(), "dummy");
+    drop(p);
+}
+
+#[test]
 /// Try invoking a method on an object.
 fn test_typename() {
     init_qom();