INNER CODE UNIT · Rust
test_normalize_stdout
sachaos/viddy · src/bytes.rs:92
fn test_normalize_stdout() {
assert_eq!(normalize_stdout(b"\t"), b" ");
// Make sure we don't miss any tabs in edge cases.
assert_eq!(normalize_stdout(b"\t\t\t\t\t"), b" ");
// Make sure tab is elastic (from 1 space to TAB_SIZE spaces).
assert_eq!(normalize_stdout(b"\t12345"), b" 12345");
assert_eq!(normalize_stdout(b"1\t2345"), b"1 2345");
assert_eq!(normalize_stdout(b"12\t345"), b"12 345");
assert_eq!(normalize_stdout(b"123\t45"), b"123 45");
assert_eq!(normalize_stdout(b"1234\t5"), b"1234 5");
// Make sure we reset alignment on new lines.
assert_eq!(normalize_stdout(b"123\t\n4\t5"), b"123 \n4 5");
assert_eq!(normalize_stdout(b"12\t3\n4\t5"), b"12 3\n4 5");
assert_eq!(normalize_stdout(b"1\t23\n4\t5"), b"1 23\n4 5");
assert_eq!(normalize_stdout(b"\t123\n4\t5"), b" 123\n4 5");
assert_eq!(
normalize_stdout("あ\tい\nう\tえ".as_bytes()),
"あ い\nう え".as_bytes()