Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assert_panics! #31

Closed
aaronabramov opened this issue Jun 17, 2020 · 2 comments
Closed

assert_panics! #31

aaronabramov opened this issue Jun 17, 2020 · 2 comments

Comments

@aaronabramov
Copy link
Owner

aaronabramov commented Jun 17, 2020

// success if the closure inside panics, panics if the closure doesn't panic
assert_panics!(|| {
  panic!("sup y'all");
});

see https://doc.rust-lang.org/std/panic/fn.catch_unwind.html

@aaronabramov
Copy link
Owner Author

aaronabramov commented Jun 17, 2020

actually catching any panics is a pretty terrible idea.. i wonder if there's a way to get a hold of the panic message and match it with a regex.
so like

assert_panic_message_matches_regex!("unexpected error", || {
  panic!("some unexpected error occurred");
});

@TheWebDevel
Copy link
Contributor

Ha! Interesting. :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants