Runs `print_welcome` against a console that is `console_width` in height and returns whether the narrow welcome message was printed or not, and the maximum width of all printed messages.
(console_width: u16)
| 305 | /// whether the narrow welcome message was printed or not, and the maximum width of all |
| 306 | /// printed messages. |
| 307 | fn check_is_narrow_welcome(console_width: u16) -> (bool, usize) { |
| 308 | let console = Rc::from(RefCell::from(MockConsole::default())); |
| 309 | console.borrow_mut().set_size_chars(CharsXY::new(console_width, 1)); |
| 310 | print_welcome(&mut *console.borrow_mut()).unwrap(); |
| 311 | |
| 312 | let mut console = console.borrow_mut(); |
| 313 | let mut found = false; |
| 314 | let mut max_length = 0; |
| 315 | for output in console.take_captured_out() { |
| 316 | match output { |
| 317 | CapturedOut::Print(msg) => { |
| 318 | if msg.contains("Type HELP") { |
| 319 | found = true; |
| 320 | max_length = std::cmp::max(max_length, msg.len()); |
| 321 | } |
| 322 | } |
| 323 | _ => panic!("Unexpected console operation: {:?}", output), |
| 324 | } |
| 325 | } |
| 326 | (!found, max_length) |
| 327 | } |
| 328 | |
| 329 | #[test] |
| 330 | fn test_print_welcome_wide_console() { |