swellaby / vscode-rust-test-adapter

Rust Test Explorer extension for VS Code
MIT License
56 stars 10 forks source link

Can work well with #[should_panic] #412

Open fallenleavesguy opened 7 months ago

fallenleavesguy commented 7 months ago

Can work well with #[should_panic]

pub struct Guess {
    value: i32,
}

impl Guess {
    pub fn new(value: i32) -> Guess {
        if value < 1 || value > 100 {
            panic!("Guess value must be between 1 and 100, got {}.", value);
        }

        Guess { value }
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    #[should_panic]
    fn greater_than_100() {
        // Guess::new(200);
    }
}

just pass

image