use std::panic::{catch_unwind, set_hook};
use std::sync::atomic::{AtomicBool, Ordering::SeqCst};
use panic_message::*;
#[test]
fn panic_info() {
static CALLED: AtomicBool = AtomicBool::new(false);
set_hook(Box::new(|pi| {
assert_eq!("gus", panic_info_message(pi));
assert_eq!(Some("gus"), get_panic_info_message(pi));
CALLED.store(true, SeqCst);
}));
let payload = catch_unwind(|| {
panic!("gus");
})
.unwrap_err();
let msg = panic_message(&payload);
assert_eq!("gus", msg);
assert!(CALLED.load(SeqCst));
}