diff --git a/tests/test.rs b/tests/test.rs index 5c6ff16fe..cecfe4e30 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -11,11 +11,12 @@ clippy::unseparated_literal_suffix )] -use cxx::SharedPtr; +use cxx::{SharedPtr, UniquePtr}; use cxx_test_suite::module::ffi2; use cxx_test_suite::{cast, ffi, R}; use std::cell::Cell; use std::ffi::CStr; +use std::panic; thread_local! { static CORRECT: Cell = const { Cell::new(false) }; @@ -380,3 +381,10 @@ fn test_raw_ptr() { assert_eq!(2025, unsafe { ffi::c_take_const_ptr(c3) }); assert_eq!(2025, unsafe { ffi::c_take_mut_ptr(c3 as *mut ffi::C) }); // deletes c3 } + +#[test] +fn test_unwind_safe() { + fn inspect(_c: &ffi::C) {} + let _unwind_safe = |c: UniquePtr| panic::catch_unwind(|| drop(c)); + let _ref_unwind_safe = |c: &ffi::C| panic::catch_unwind(|| inspect(c)); +}