Skip to content

Commit

Permalink
Merge pull request #813 from Metaphorme/main
Browse files Browse the repository at this point in the history
修复ch11-01-writing-tests章节中无意义测试
  • Loading branch information
KaiserY authored Aug 29, 2024
2 parents 693598b + 6caa81b commit 7bdeafe
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 7bdeafe

Please sign in to comment.