| 146 | 146 | | } |
| 147 | 147 | | |
| 148 | 148 | | /// The greeting for `name`. |
| 149 | | − | pub fn hail(name: &str) -> String { |
| 149 | + | pub fn greet(name: &str) -> String { |
| 150 | 150 | | greeting_in(name, Lang::En) |
| 151 | 151 | | } |
| 152 | 152 | | |
| ⋯ |
| 167 | 167 | | } |
| 168 | 168 | | |
| 169 | 169 | | /// The farewell for `name`. |
| 170 | | − | pub fn part(name: &str) -> String { |
| 170 | + | pub fn farewell(name: &str) -> String { |
| 171 | 171 | | let trimmed = name.trim(); |
| 172 | 172 | | let display_name = if trimmed.is_empty() { "world" } else { trimmed }; |
| 173 | 173 | | format!("Goodbye, {display_name}!") |
| ⋯ |
| 219 | 219 | | |
| 220 | 220 | | #[test] |
| 221 | 221 | | fn loud_uses_three_exclamation_marks() { |
| 222 | | − | assert_eq!(loud(&hail("Ada")), "Hi, Ada!!!"); |
| 222 | + | assert_eq!(loud(&greet("Ada")), "Hi, Ada!!!"); |
| 223 | 223 | | } |
| 224 | 224 | | |
| 225 | 225 | | #[test] |
| ⋯ |
| 350 | 350 | | |
| 351 | 351 | | #[test] |
| 352 | 352 | | fn shout_upper_cases_greeting() { |
| 353 | | − | assert_eq!(shout(&hail("Ada")), "HI, ADA!"); |
| 353 | + | assert_eq!(shout(&greet("Ada")), "HI, ADA!"); |
| 354 | 354 | | } |
| 355 | 355 | | |
| 356 | 356 | | #[test] |
| 357 | 357 | | fn whisper_lower_cases_and_trails_off() { |
| 358 | | − | assert_eq!(whisper(&hail("Ada")), "hi, ada..."); |
| 358 | + | assert_eq!(whisper(&greet("Ada")), "hi, ada..."); |
| 359 | 359 | | assert_eq!(whisper(&greeting_in("Luc", Lang::Fr)), "bonjour, luc..."); |
| 360 | 360 | | } |
| 361 | 361 | | |
| ⋯ |
| 377 | 377 | | |
| 378 | 378 | | #[test] |
| 379 | 379 | | fn reverse_spells_backwards() { |
| 380 | | − | assert_eq!(hail(&reverse("Ada")), "Hi, adA!"); |
| 380 | + | assert_eq!(greet(&reverse("Ada")), "Hi, adA!"); |
| 381 | 381 | | } |
| 382 | 382 | | |
| 383 | 383 | | #[test] |
| 384 | 384 | | fn greets_by_name() { |
| 385 | | − | assert_eq!(hail("Ada"), "Hi, Ada!"); |
| 385 | + | assert_eq!(greet("Ada"), "Hi, Ada!"); |
| 386 | 386 | | } |
| 387 | 387 | | |
| 388 | 388 | | #[test] |
| 389 | 389 | | fn greets_world_with_empty_string() { |
| 390 | | − | assert_eq!(hail(""), "Hi, world!"); |
| 390 | + | assert_eq!(greet(""), "Hi, world!"); |
| 391 | 391 | | } |
| 392 | 392 | | |
| 393 | 393 | | #[test] |
| 394 | 394 | | fn greets_world_with_whitespace_only() { |
| 395 | | − | assert_eq!(hail(" "), "Hi, world!"); |
| 395 | + | assert_eq!(greet(" "), "Hi, world!"); |
| 396 | 396 | | } |
| 397 | 397 | | |
| 398 | 398 | | #[test] |
| 399 | 399 | | fn trims_whitespace_from_name() { |
| 400 | | − | assert_eq!(hail(" Ada "), "Hi, Ada!"); |
| 400 | + | assert_eq!(greet(" Ada "), "Hi, Ada!"); |
| 401 | 401 | | } |
| 402 | 402 | | |
| 403 | 403 | | #[test] |
| 404 | 404 | | fn says_goodbye_by_name() { |
| 405 | | − | assert_eq!(part("Ada"), "Goodbye, Ada!"); |
| 405 | + | assert_eq!(farewell("Ada"), "Goodbye, Ada!"); |
| 406 | 406 | | } |
| 407 | 407 | | |
| 408 | 408 | | #[test] |
| 409 | 409 | | fn says_goodbye_to_world_when_blank() { |
| 410 | | − | assert_eq!(part(" "), "Goodbye, world!"); |
| 410 | + | assert_eq!(farewell(" "), "Goodbye, world!"); |
| 411 | 411 | | } |
| 412 | 412 | | |
| 413 | 413 | | #[test] |
| 414 | 414 | | fn farewell_trims_whitespace() { |
| 415 | | − | assert_eq!(part(" Ada "), "Goodbye, Ada!"); |
| 415 | + | assert_eq!(farewell(" Ada "), "Goodbye, Ada!"); |
| 416 | 416 | | } |
| 417 | 417 | | } |