trpl-zh-cn/listings/ch11-writing-automated-tests/no-listing-06-greeter-with-bug/src/lib.rs
2022-02-06 16:43:51 +08:00

17 lines
287 B
Rust
Executable File

// ANCHOR: here
pub fn greeting(name: &str) -> String {
String::from("Hello!")
}
// ANCHOR_END: here
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn greeting_contains_name() {
let result = greeting("Carol");
assert!(result.contains("Carol"));
}
}