Merge pull request #813 from Metaphorme/main

修复ch11-01-writing-tests章节中无意义测试
pull/814/head
KaiserY 3 months ago committed by GitHub
commit 7bdeafebba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,11 +1,21 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
// ANCHOR: here
#[test] #[test]
fn it_works() -> Result<(), String> { fn it_works() -> Result<(), String> {
if 2 + 2 == 4 { let result = add(2, 2);
if result == 4 {
Ok(()) Ok(())
} else { } else {
Err(String::from("two plus two does not equal four")) Err(String::from("two plus two does not equal four"))
} }
} }
// ANCHOR_END: here
} }

Loading…
Cancel
Save