hs-rust-learn 0.1.0

hs's rust test learn
Documentation
#[test]
pub fn test_abc() {
    let s = "abc";
    assert!(s == "abc");
    assert_eq!(s, "abc");
}

#[test]
#[should_panic(expected = "add_two(2) failed")]
fn test_zero() {
    assert_eq!(1024/1024, 1);
    // assert!(1024 == 1023, "nonono...");
    let s = "hello world";
    println!("...test output...");
    assert_eq!(add_two(add_two(2)), 5, "add_two(2) failed {s}");
}

#[ignore = "not ready yet"]
#[test]
fn test_result() -> Result<(), String> {
    if 2 + 2 == 4 {
        Ok(())
    } else {
        Err(String::from("2+2 != 4"))
    }
}

#[cfg(test)]
mod tests {
    #[test]
    fn it_test() {
        assert_eq!(2 + 2, 4);
    }
}

pub fn add_two(a: i32) -> i32 {
    a + 2
}

pub fn main () {

}