eyre/tests/test_repr.rs
William D. Jones 769e26e4ab
Add must-install feature, so that a non-default handler can be the on… (#52)
* Add must-install feature, so that a non-default handler can be the only handler consuming .text.

* Provide a better panic message if `must-install` feature is enabled.

Co-authored-by: Jane Lusby <jlusby42@gmail.com>

* Bump version because new feature was added.

* Convert must-install feature to auto-install to avoid negative features.

* Add ability to manually install DefaultHandler (for when auto-install is disabled).

* Ensure doctests pass when auto-install feature is disabled.

* Integration tests now succeed without auto-install feature.

* Add integration test for when auto-install feature is disabled.

* Add auto-install feature testing to CI.

* cargo fmt.

Co-authored-by: Jane Lusby <jlusby42@gmail.com>
Co-authored-by: Jane Lusby <jlusby@yaah.dev>
2022-03-25 13:32:39 -07:00

37 lines
706 B
Rust

mod common;
mod drop;
use self::common::maybe_install_handler;
use self::drop::{DetectDrop, Flag};
use eyre::Report;
use std::marker::Unpin;
use std::mem;
#[test]
fn test_error_size() {
assert_eq!(mem::size_of::<Report>(), mem::size_of::<usize>());
}
#[test]
fn test_null_pointer_optimization() {
assert_eq!(
mem::size_of::<Result<(), Report>>(),
mem::size_of::<usize>()
);
}
#[test]
fn test_autotraits() {
fn assert<E: Unpin + Send + Sync + 'static>() {}
assert::<Report>();
}
#[test]
fn test_drop() {
maybe_install_handler().unwrap();
let has_dropped = Flag::new();
drop(Report::new(DetectDrop::new(&has_dropped)));
assert!(has_dropped.get());
}