Created
October 21, 2021 21:47
-
-
Save Shaun289/117027eca74be945f4a178716bea3123 to your computer and use it in GitHub Desktop.
rust study : unittest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The rust programming ko https://rinthel.github.io/rust-lang-book-ko/ch11-01-writing-tests.html | |
// compiled on https://play.rust-lang.org/ | |
/* result | |
running 2 tests | |
test tests::exploration ... ok | |
test tests::another ... FAILED | |
failures: | |
---- tests::another stdout ---- | |
thread 'tests::another' panicked at 'Make this test fail!', src/lib.rs:14:9 | |
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace | |
failures: | |
tests::another | |
test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s | |
*/ | |
#[cfg(test)] | |
mod tests { | |
#[test] | |
fn exploration() { | |
assert_eq!(2 + 2, 4); | |
} | |
#[test] | |
fn another() { | |
panic!("Make this test fail!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment