use std::mem;
use allocative::Allocative;
use crate as allocative;
use crate::FlameGraphBuilder;
#[derive(Allocative)]
struct TestData {
data: Box<[u8]>,
b: u8,
}
#[test]
fn test_flamegraph() {
if mem::size_of::<usize>() != 8 {
return;
}
let mut fg = FlameGraphBuilder::default();
fg.visit_root(&TestData {
data: vec![0; 100].into_boxed_slice(),
b: 1,
});
assert_eq!(
"\
allocative::test_derive::with_flamegraph::TestData 7\n\
allocative::test_derive::with_flamegraph::TestData;b;u8 1\n\
allocative::test_derive::with_flamegraph::TestData;data;alloc::boxed::Box<[u8]>;ptr 16\n\
allocative::test_derive::with_flamegraph::TestData;data;alloc::boxed::Box<[u8]>;ptr;u8;data;u8 100\n\
",
fg.finish_and_write_flame_graph()
.replace("allocative_unittest::", "allocative::")
);
}