use inspect_rs::{Inspect, InspectCx, format_tree};
#[test]
fn test_tree_formatting_simple_struct() {
#[derive(Inspect)]
struct Point {
x: i32,
y: i32,
}
let point = Point { x: 10, y: 20 };
let mut cx = InspectCx::new();
let inspected = point.inspect(&mut cx);
let output = format_tree(&inspected);
assert!(output.contains("Point"));
assert!(output.contains("x"));
assert!(output.contains("y"));
assert!(output.contains("10"));
assert!(output.contains("20"));
}
#[test]
fn test_tree_formatting_vec() {
let value = vec![1, 2, 3];
let mut cx = InspectCx::new();
let inspected = value.inspect(&mut cx);
let output = format_tree(&inspected);
assert!(output.contains("Vec"));
}
#[test]
fn test_secret_redaction() {
#[derive(Inspect)]
struct Secret {
#[inspect(secret)]
password: String,
}
let value = Secret { password: "my-secret".to_string() };
let mut cx = InspectCx::new();
let inspected = value.inspect(&mut cx);
let output = format_tree(&inspected);
assert!(output.contains("[REDACTED]"));
assert!(!output.contains("my-secret"));
}