mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2025-02-24 13:22:19 +08:00
21 lines
398 B
Rust
Executable File
21 lines
398 B
Rust
Executable File
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
|
|
}
|