mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2024-11-09 00:43:59 +08:00
Merge pull request #813 from Metaphorme/main
修复ch11-01-writing-tests章节中无意义测试
This commit is contained in:
commit
7bdeafebba
@ -1,11 +1,21 @@
|
||||
pub fn add(left: usize, right: usize) -> usize {
|
||||
left + right
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
// ANCHOR: here
|
||||
#[test]
|
||||
fn it_works() -> Result<(), String> {
|
||||
if 2 + 2 == 4 {
|
||||
let result = add(2, 2);
|
||||
|
||||
if result == 4 {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(String::from("two plus two does not equal four"))
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: here
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user