sunface / rust-course

“连续六年成为全世界最受喜爱的语言,无 GC 也无需手动内存管理、极高的性能和安全性、过程/OO/函数式编程、优秀的包管理、JS 未来基石" — 工作之余的第二语言来试试 Rust 吧。<<Rust语言圣经>>拥有全面且深入的讲解、生动贴切的示例、德芙般丝滑的内容,甚至还有JS程序员关注的 WASM 和 Deno 等专题。这可能是目前最用心的 Rust 中文学习教程 / Book
https://course.rs
24.75k stars 2.13k forks source link

Update tests.md #1312

Open ShoreCN opened 10 months ago

ShoreCN commented 10 months ago

修复原文中的错误逻辑,此处测试用例必然失败

ShoreCN commented 10 months ago

额?不对吧。。。

我的理解是,从这一章节的描述来看,就是先书写一个注定失败的测试用例,然后再进行逐步实现完善。 当前此第一步骤目的就是“注定失败的测试用例”。

  1. 从实际执行结果来看,这个测试用例也是失败的。
    
    $ cargo test
    Compiling minigrep v0.1.0 (file:///projects/minigrep)
    Finished test [unoptimized + debuginfo] target(s) in 0.97s
     Running unittests src/lib.rs (target/debug/deps/minigrep-9cd200e5fac0fc94)

running 1 test test tests::one_result ... FAILED

failures:

---- tests::one_result stdout ---- thread 'main' panicked at 'assertion failed: (left == right) left: ["safe, fast, productive."], right: []', src/lib.rs:44:9 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

failures: tests::one_result

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

error: test failed, to rerun pass --lib



2. 从语言组织表达来说,原文的“成功通过“和”居心叵测“也未呈现结果转折的含义
> 先添加一个简单的 search 函数实现,非常简单粗暴的返回一个空的数组,**_显而易见测试用例将成功通过,真是一个居心叵测的测试用例!_**

不知我是否有理解偏差的地方。