How to Test for Expected Panics with #[should_panic]

Use the #[should_panic] attribute with an expected message string to verify that a function panics correctly.

Add the #[should_panic] attribute to your test function to verify that a specific code path panics.

#[test]
#[should_panic(expected = "less than or equal to 100")]
fn greater_than_100() {
    Guess::new(200);
}

The expected argument ensures the test only passes if the panic message contains the specified substring.