Skip to content

Commit

Permalink
Add test that {:p} prints the right address
Browse files Browse the repository at this point in the history
    thread 'test_pointer' panicked at tests/test_display.rs:265:5:
    assertion `left == right` failed
      left: "0x7fbbd7df10"
     right: "0x7fac000e30"
  • Loading branch information
dtolnay committed Nov 8, 2024
1 parent 5dfd2cc commit 46586dd
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,20 @@ fn test_nested_tuple_field() {
assert("0", Error(Inner(0)));
}

#[test]
fn test_pointer() {
#[derive(Error, Debug)]
#[error("{field:p}")]
pub struct Struct {
field: Box<i32>,
}

let s = Struct {
field: Box::new(-1),
};
assert_eq!(s.to_string(), format!("{:p}", s.field));
}

#[test]
fn test_macro_rules() {
// Regression test for https://github.com/dtolnay/thiserror/issues/86
Expand Down

0 comments on commit 46586dd

Please sign in to comment.