Skip to content

Commit 163e139

Browse files
committed
Add assert output to failures in gix-url baseline test
Depending on what `assert!` is used either a `&'static str` or a `String` is passed to `panic!`. So we have to check for both to have good failure messages.
1 parent fe5dbe1 commit 163e139

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

gix-url/tests/baseline/main.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,21 @@ fn get_baseline_test_cases() -> Vec<Trial> {
1818
std::panic::catch_unwind(|| {
1919
assert_urls_equal(expected, &gix_url::parse(url).expect("valid urls can be parsed"))
2020
})
21-
.map_err(|err| match err.downcast_ref::<&str>() {
22-
Some(panic_message) => panic_message.into(),
23-
None => Failed::without_message(),
21+
.map_err(|err| {
22+
// Succeeds whenever `panic!` was given a string literal (for example if
23+
// `assert!` is given a string literal).
24+
match err.downcast_ref::<&str>() {
25+
Some(panic_message) => panic_message.into(),
26+
None => {
27+
// Succeeds whenever `panic!` was given an owned String (for
28+
// example when using the `format!` syntax and always for
29+
// `assert_*!` macros).
30+
match err.downcast_ref::<String>() {
31+
Some(panic_message) => panic_message.into(),
32+
None => Failed::without_message(),
33+
}
34+
}
35+
}
2436
})
2537
},
2638
)

0 commit comments

Comments
 (0)