| 141 | 141 | | } |
| 142 | 142 | | |
| 143 | 143 | | /// The greeting for `name`. |
| 144 | | − | pub fn hail(name: &str) -> String { |
| 144 | + | pub fn greet(name: &str) -> String { |
| 145 | 145 | | greeting_in(name, Lang::En) |
| 146 | 146 | | } |
| 147 | 147 | | |
| ⋯ |
| 162 | 162 | | } |
| 163 | 163 | | |
| 164 | 164 | | /// The farewell for `name`. |
| 165 | | − | pub fn part(name: &str) -> String { |
| 165 | + | pub fn farewell(name: &str) -> String { |
| 166 | 166 | | let trimmed = name.trim(); |
| 167 | 167 | | let display_name = if trimmed.is_empty() { "world" } else { trimmed }; |
| 168 | 168 | | format!("Goodbye, {display_name}!") |
| ⋯ |
| 208 | 208 | | |
| 209 | 209 | | #[test] |
| 210 | 210 | | fn loud_uses_three_exclamation_marks() { |
| 211 | | − | assert_eq!(loud(&hail("Ada")), "Hi, Ada!!!"); |
| 211 | + | assert_eq!(loud(&greet("Ada")), "Hi, Ada!!!"); |
| 212 | 212 | | } |
| 213 | 213 | | |
| 214 | 214 | | #[test] |
| ⋯ |
| 339 | 339 | | |
| 340 | 340 | | #[test] |
| 341 | 341 | | fn shout_upper_cases_greeting() { |
| 342 | | − | assert_eq!(shout(&hail("Ada")), "HI, ADA!"); |
| 342 | + | assert_eq!(shout(&greet("Ada")), "HI, ADA!"); |
| 343 | 343 | | } |
| 344 | 344 | | |
| 345 | 345 | | #[test] |
| 346 | 346 | | fn whisper_lower_cases_and_trails_off() { |
| 347 | | − | assert_eq!(whisper(&hail("Ada")), "hi, ada..."); |
| 347 | + | assert_eq!(whisper(&greet("Ada")), "hi, ada..."); |
| 348 | 348 | | assert_eq!(whisper(&greeting_in("Luc", Lang::Fr)), "bonjour, luc..."); |
| 349 | 349 | | } |
| 350 | 350 | | |
| ⋯ |
| 366 | 366 | | |
| 367 | 367 | | #[test] |
| 368 | 368 | | fn reverse_spells_backwards() { |
| 369 | | − | assert_eq!(hail(&reverse("Ada")), "Hi, adA!"); |
| 369 | + | assert_eq!(greet(&reverse("Ada")), "Hi, adA!"); |
| 370 | 370 | | } |
| 371 | 371 | | |
| 372 | 372 | | #[test] |
| 373 | 373 | | fn greets_by_name() { |
| 374 | | − | assert_eq!(hail("Ada"), "Hi, Ada!"); |
| 374 | + | assert_eq!(greet("Ada"), "Hi, Ada!"); |
| 375 | 375 | | } |
| 376 | 376 | | |
| 377 | 377 | | #[test] |
| 378 | 378 | | fn greets_world_with_empty_string() { |
| 379 | | − | assert_eq!(hail(""), "Hi, world!"); |
| 379 | + | assert_eq!(greet(""), "Hi, world!"); |
| 380 | 380 | | } |
| 381 | 381 | | |
| 382 | 382 | | #[test] |
| 383 | 383 | | fn greets_world_with_whitespace_only() { |
| 384 | | − | assert_eq!(hail(" "), "Hi, world!"); |
| 384 | + | assert_eq!(greet(" "), "Hi, world!"); |
| 385 | 385 | | } |
| 386 | 386 | | |
| 387 | 387 | | #[test] |
| 388 | 388 | | fn trims_whitespace_from_name() { |
| 389 | | − | assert_eq!(hail(" Ada "), "Hi, Ada!"); |
| 389 | + | assert_eq!(greet(" Ada "), "Hi, Ada!"); |
| 390 | 390 | | } |
| 391 | 391 | | |
| 392 | 392 | | #[test] |
| 393 | 393 | | fn says_goodbye_by_name() { |
| 394 | | − | assert_eq!(part("Ada"), "Goodbye, Ada!"); |
| 394 | + | assert_eq!(farewell("Ada"), "Goodbye, Ada!"); |
| 395 | 395 | | } |
| 396 | 396 | | |
| 397 | 397 | | #[test] |
| 398 | 398 | | fn says_goodbye_to_world_when_blank() { |
| 399 | | − | assert_eq!(part(" "), "Goodbye, world!"); |
| 399 | + | assert_eq!(farewell(" "), "Goodbye, world!"); |
| 400 | 400 | | } |
| 401 | 401 | | |
| 402 | 402 | | #[test] |
| 403 | 403 | | fn farewell_trims_whitespace() { |
| 404 | | − | assert_eq!(part(" Ada "), "Goodbye, Ada!"); |
| 404 | + | assert_eq!(farewell(" Ada "), "Goodbye, Ada!"); |
| 405 | 405 | | } |
| 406 | 406 | | } |