Skip to content

Commit 7440e70

Browse files
tr: Add support for octal sequences
Also: fix string1 order bug
1 parent b8d4eac commit 7440e70

File tree

2 files changed

+605
-338
lines changed

2 files changed

+605
-338
lines changed

text/tests/tr/mod.rs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,15 +339,35 @@ fn tr_d_space_n() {
339339
546869732069732061207375697465206f6620527573742d6e617469766520636f726520636f6d6d616e64206c696e65207574696c74696573202863702c206d762c0a61776b2c206d616b652c2076692c202e2e2e29207573696e6720504f5349582e323032342061732074686520626173656c696e652073706563696669636174696f6e2e0a\
340340
";
341341

342-
tr_test(&["-d", r#" \n"#], input, output);
342+
tr_test(&["-d", r" \n"], input, output);
343343
}
344344

345345
#[test]
346346
fn tr_ignored_backslash() {
347-
tr_test(&["-d", r#"\z"#], "xyz", "xy");
347+
tr_test(&["-d", r"\z"], "xyz", "xy");
348348
}
349349

350350
#[test]
351351
fn tr_escaped_backslash() {
352-
tr_test(&["-d", r#"\\"#], r#"a\b\c"#, "abc");
352+
tr_test(&["-d", r"\\"], r"a\b\c", "abc");
353+
}
354+
355+
#[test]
356+
fn tr_octal_sequence() {
357+
tr_test(&["2", r"\44"], "123\n", "1$3\n");
358+
}
359+
360+
#[test]
361+
fn tr_octal_sequence_two() {
362+
tr_test(&["21", r"\44Z"], "123123\n", "Z$3Z$3\n");
363+
}
364+
365+
#[test]
366+
fn tr_reverse_order_simple() {
367+
tr_test(&["21", "AB"], "12\n", "BA\n");
368+
}
369+
370+
#[test]
371+
fn tr_duplicate_string1_character_precedence() {
372+
tr_test(&["AA", "CB"], "AAAA", "BBBB");
353373
}

0 commit comments

Comments
 (0)