Cover metadata-only Debug output
This commit is contained in:
@@ -61,6 +61,37 @@ fn assert_guard_state<T>(guard: &ContentGuard<'_, T>, expected_len: usize) {
|
||||
);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn assert_debug_metadata(debug_output: &str, type_name: &str) {
|
||||
assert!(debug_output.starts_with(type_name));
|
||||
assert!(debug_output.contains("layout"));
|
||||
assert!(debug_output.contains("length"));
|
||||
assert!(debug_output.contains("capacity"));
|
||||
assert!(!debug_output.contains("vtable"));
|
||||
assert!(!debug_output.contains("0x"));
|
||||
assert!(!debug_output.contains("42"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_debug_implementations_expose_only_metadata() {
|
||||
let mut erased = TypeErasedVec::new(vec![42_u32]);
|
||||
assert_debug_metadata(&format!("{erased:?}"), "TypeErasedVec");
|
||||
|
||||
{
|
||||
let guard = unsafe { erased.cast_type::<u32>() };
|
||||
assert_debug_metadata(&format!("{guard:?}"), "ContentGuard");
|
||||
}
|
||||
|
||||
let send_erased = SendTypeErasedVec::new(vec![42_u32]);
|
||||
assert_debug_metadata(&format!("{send_erased:?}"), "SendTypeErasedVec");
|
||||
|
||||
let send_sync_erased = SendSyncTypeErasedVec::new(vec![42_u32]);
|
||||
assert_debug_metadata(
|
||||
&format!("{send_sync_erased:?}"),
|
||||
"SendSyncTypeErasedVec",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sendable_is_send_sync() {
|
||||
fn assert_send<T: Send>() {}
|
||||
|
||||
Reference in New Issue
Block a user