Skip to content

Commit 22b20a8

Browse files
committed
add test
1 parent 2572659 commit 22b20a8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/capture.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,3 +527,32 @@ mod serde_impls {
527527
}
528528
}
529529
}
530+
531+
#[cfg(test)]
532+
mod tests {
533+
use super::*;
534+
535+
#[test]
536+
fn test_frame_conversion() {
537+
// captures an original backtrace, and makes sure that the manual conversion
538+
// to frames yields the same results.
539+
let bt = Backtrace::new();
540+
let original_frames = bt.frames();
541+
let mut original = original_frames.iter();
542+
543+
let mut frames = 0;
544+
unsafe {
545+
crate::trace_unsynchronized(|frame| {
546+
// skip the first frame, that happens inside this function so won't match
547+
// the original backtrace
548+
if frames > 0 {
549+
let converted = BacktraceFrame::from(frame.clone());
550+
let og = original.next().unwrap();
551+
assert_eq!(converted.symbol_address(), og.symbol_address());
552+
}
553+
frames += 1;
554+
true
555+
});
556+
}
557+
}
558+
}

0 commit comments

Comments
 (0)