How to write a unit test in Rust that checks that a function panics?
Hello everyone! I'm just starting to learn Rust and trying to write tests for my library. I have a function that should panic under certain conditions. For example, I wrote a simple calculator, and the division function should panic when attempting to divide by zero.
Here's my code:
```rust
fn divide(a: i32, b: i32) -> i32 {
if b == 0 {
panic!("Division by zero!");
}
a / b
}
```
I want to write a unit test that checks that calling `divide(10, 0)` actually panics. I tried using `#[should_panic]`, but I'm not sure I'm doing it correctly. Also, I've heard there are more advanced ways to check for panics with a message. Please advise how to properly write such tests in Rust? Are there any best practices or