safelog: tests for BoxSensitive.

This commit is contained in:
Nick Mathewson 2022-12-06 10:28:53 -05:00
parent 993b4202c7
commit 417dda9547
1 changed files with 17 additions and 0 deletions

View File

@ -386,6 +386,23 @@ mod test {
assert_eq!(s2, expect);
}
#[test]
#[serial]
fn box_sensitive() {
let b: BoxSensitive<_> = "hello world".into();
assert_eq!(b.clone().into_inner(), "hello world");
let closure = || format!("{} {:?}", b, b);
assert_eq!(closure(), "[scrubbed] [scrubbed]");
assert_eq!(
with_safe_logging_suppressed(closure),
r#"hello world "hello world""#
);
assert_eq!(b.len(), 11);
}
#[test]
#[serial]
fn test_redacted() {