Skip to content

Commit 20a5e96

Browse files
authored
Merge pull request uutils#6141 from BenWiederhake/dev-tr-space-class
tr: fix "space" class, test "blank" class for order
2 parents 8ae8de0 + e9045be commit 20a5e96

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/uu/tr/src/unicode_table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ pub static FF: u8 = 0xC;
1212
pub static CR: u8 = 0xD;
1313
pub static SPACE: u8 = 0x20;
1414
pub static SPACES: &[u8] = &[HT, LF, VT, FF, CR, SPACE];
15-
pub static BLANK: &[u8] = &[SPACE, HT];
15+
pub static BLANK: &[u8] = &[HT, SPACE];

tests/by-util/test_tr.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,3 +1283,33 @@ fn test_complement_flag_fails_with_more_than_two_operand() {
12831283
.fails()
12841284
.stderr_contains("extra operand 'c'");
12851285
}
1286+
1287+
#[test]
1288+
fn check_regression_class_space() {
1289+
// This invocation checks:
1290+
// 1. that the [:space:] class has exactly 6 characters,
1291+
// 2. that the [:space:] class contains at least the given 6 characters (and therefore no other characters), and
1292+
// 3. that the given characters occur in exactly this order.
1293+
new_ucmd!()
1294+
.args(&["[:space:][:upper:]", "123456[:lower:]"])
1295+
// 0x0B = "\v" ("VERTICAL TAB")
1296+
// 0x0C = "\f" ("FEED FORWARD")
1297+
.pipe_in("A\t\n\u{0B}\u{0C}\r B")
1298+
.succeeds()
1299+
.no_stderr()
1300+
.stdout_only("a123456b");
1301+
}
1302+
1303+
#[test]
1304+
fn check_regression_class_blank() {
1305+
// This invocation checks:
1306+
// 1. that the [:blank:] class has exactly 2 characters,
1307+
// 2. that the [:blank:] class contains at least the given 2 characters (and therefore no other characters), and
1308+
// 3. that the given characters occur in exactly this order.
1309+
new_ucmd!()
1310+
.args(&["[:blank:][:upper:]", "12[:lower:]"])
1311+
.pipe_in("A\t B")
1312+
.succeeds()
1313+
.no_stderr()
1314+
.stdout_only("a12b");
1315+
}

0 commit comments

Comments
 (0)