#author("2025-08-18T16:36:58+00:00","default:yoya","yoya")
#author("2025-08-18T16:38:41+00:00","default:yoya","yoya")
[[Rust]]


tests 以下に test_*.rs ファイルを作るとビルドし、
#[test], もしくは #[tokio::test(flavor = "multi_thread")] で修飾された関数を実行し、 assert_eq!(a, b) で成否の判断ができる。

* 標準出力 [#p8707c40]

cargo test は標準出力を横取りして、以下のは通常表示しない。
 println!("foo: {}!", foo);
cargo test -- --nocapture 
だと、println を表示する。なお、
 writeln!(&mut std::io::stderr(), "foo: {}", foo).unwrap();
だと cargo test で表示するが、消し忘れがあるかもしれないし、デバッグ用にコメントアウトしたり外したりするの面倒なので、println の方が良さそう?