Skip to content

Commit

Permalink
join: add test for multibyte separators
Browse files Browse the repository at this point in the history
  • Loading branch information
jtracey committed Sep 25, 2024
1 parent a408847 commit 395c441
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
26 changes: 22 additions & 4 deletions tests/by-util/test_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ fn tab_multi_character() {
.arg("semicolon_fields_1.txt")
.arg("semicolon_fields_2.txt")
.arg("-t")
.arg("э")
.arg("ab")
.fails()
.stderr_is("join: multi-character tab э\n");
.stderr_is("join: multi-character tab ab\n");
}

#[test]
Expand Down Expand Up @@ -437,14 +437,22 @@ fn non_unicode() {

#[cfg(unix)]
{
let invalid_utf8: u8 = 167;
let non_utf8_byte: u8 = 167;
new_ucmd!()
.arg("-t")
.arg(OsStr::from_bytes(&[invalid_utf8]))
.arg(OsStr::from_bytes(&[non_utf8_byte]))
.arg("non-unicode_1.bin")
.arg("non-unicode_2.bin")
.succeeds()
.stdout_only_fixture("non-unicode_sep.expected");

new_ucmd!()
.arg("-t")
.arg(OsStr::from_bytes(&[non_utf8_byte, non_utf8_byte]))
.arg("non-unicode_1.bin")
.arg("non-unicode_2.bin")
.fails()
.stderr_is("join: non-UTF-8 multi-byte tab\n");
}

#[cfg(windows)]
Expand All @@ -462,6 +470,16 @@ fn non_unicode() {
}
}

#[test]
fn multibyte_sep() {
new_ucmd!()
.arg("-t§")
.arg("multibyte_sep_1.txt")
.arg("multibyte_sep_2.txt")
.succeeds()
.stdout_only_fixture("multibyte_sep.expected");
}

#[test]
fn null_field_separators() {
new_ucmd!()
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/join/multibyte_sep.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a§b§c
1 change: 1 addition & 0 deletions tests/fixtures/join/multibyte_sep_1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a§b
1 change: 1 addition & 0 deletions tests/fixtures/join/multibyte_sep_2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a§c

0 comments on commit 395c441

Please sign in to comment.