[Rust]「Command-Line Rust」の「2. Test for Echo」をやった

May 3, 2022

↓の第2章をやった

Command-Line Rust: A Project-Based Primer for Writing Rust CLIs

echoらしくなっている。

1
2
3
4
$ echo hello   world  
hello world
$ echo "hello   world"
hello   world

テストもあって良い。

1
2
3
4
5
6
7
8
9
10
11
$ cargo test
    Finished test [unoptimized + debuginfo] target(s) in 0.25s
     Running unittests (target/debug/deps/echo-914d9b00f7bd0021)

running 4 tests
test tests::it_runs ... ok
test tests::it_runs_with_multiple_texts ... ok
test tests::it_runs_with_n ... ok
test tests::it_dies_with_no_args ... ok

test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

コード

https://github.com/tnantoka/my_rust_sandbox/tree/main/echo