You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Create a long line that will exceed typical terminal width
471
420
let text = "This is a very long line that should definitely exceed the terminal width and therefore needs to be wrapped at appropriate word boundaries to ensure readability.";
472
421
let wrapped = wrap_text_to_terminal_width(text);
473
-
422
+
474
423
// Check that no line exceeds terminal width
475
424
for line in wrapped.lines(){
476
425
assert!(line.len() <= *TERMINAL_WIDTH,"Line too long: '{}'", line);
477
426
}
478
-
427
+
479
428
// Check that the text is preserved (all words should still be there)
480
429
let original_words:Vec<&str> = text.split_whitespace().collect();
481
430
let wrapped_words:Vec<&str> = wrapped.split_whitespace().collect();
@@ -486,12 +435,12 @@ mod tests {
486
435
fntest_wrap_text_multiple_lines(){
487
436
let text = "Short line.\nThis is a very long line that should definitely exceed the terminal width and therefore needs to be wrapped.\nAnother short line.";
488
437
let wrapped = wrap_text_to_terminal_width(text);
489
-
438
+
490
439
// Check that no line exceeds terminal width
491
440
for line in wrapped.lines(){
492
441
assert!(line.len() <= *TERMINAL_WIDTH,"Line too long: '{}'", line);
493
442
}
494
-
443
+
495
444
// Check that short lines are preserved
496
445
let lines:Vec<&str> = wrapped.lines().collect();
497
446
assert_eq!(lines[0],"Short line.");
@@ -502,7 +451,7 @@ mod tests {
502
451
fntest_wrap_text_preserve_empty_lines(){
503
452
let text = "First line.\n\nThird line.";
504
453
let wrapped = wrap_text_to_terminal_width(text);
505
-
454
+
506
455
let lines:Vec<&str> = wrapped.lines().collect();
507
456
assert_eq!(lines.len(),3);
508
457
assert_eq!(lines[0],"First line.");
@@ -515,12 +464,12 @@ mod tests {
515
464
// Create a single word that exceeds terminal width
516
465
let long_word = "a".repeat(*TERMINAL_WIDTH + 10);
517
466
let wrapped = wrap_text_to_terminal_width(&long_word);
518
-
467
+
519
468
// Should be split into chunks
520
469
for line in wrapped.lines(){
521
470
assert!(line.len() <= *TERMINAL_WIDTH,"Line too long: '{}'", line);
522
471
}
523
-
472
+
524
473
// All characters should be preserved
525
474
let wrapped_chars:String = wrapped.chars().filter(|&c| c != '\n').collect();
526
475
assert_eq!(wrapped_chars, long_word);
@@ -531,7 +480,7 @@ mod tests {
531
480
// Test that text parsing applies wrapping
532
481
let long_text = "This is a very long line that should definitely exceed the terminal width and therefore needs to be wrapped at appropriate word boundaries.";
0 commit comments