mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2025-02-24 21:32:15 +08:00
21 lines
398 B
Rust
21 lines
398 B
Rust
|
pub fn greeting(name: &str) -> String {
|
||
|
String::from("Hello!")
|
||
|
}
|
||
|
|
||
|
#[cfg(test)]
|
||
|
mod tests {
|
||
|
use super::*;
|
||
|
|
||
|
// ANCHOR: here
|
||
|
#[test]
|
||
|
fn greeting_contains_name() {
|
||
|
let result = greeting("Carol");
|
||
|
assert!(
|
||
|
result.contains("Carol"),
|
||
|
"Greeting did not contain name, value was `{}`",
|
||
|
result
|
||
|
);
|
||
|
}
|
||
|
// ANCHOR_END: here
|
||
|
}
|