Rust Prova una funzione


fn to_test(output: bool) -> bool {

#[cfg(test)] // The module is only compiled when testing.
mod test {
    use super::to_test;

    // This function is a test function. It will be executed and
    // the test will succeed if the function exits cleanly.
    fn test_to_test_ok() {
        assert_eq!(to_test(true), true);

    // That test on the other hand will only succeed when the function
    // panics.
    fn test_to_test_fail() {
        assert_eq!(to_test(true), false);

( Link per il parco giochi )

Corri con cargo test .