From faa6a9bb9556bc754812c8323b7515407cc269a6 Mon Sep 17 00:00:00 2001 From: Phineas Jensen Date: Sat, 21 Jun 2025 21:57:40 -0600 Subject: [PATCH] tests/fold: add tests for non-utf8 streams --- tests/by-util/test_fold.rs | 27 +++++++++++++++++++ tests/fixtures/fold/non_utf8.expected | 2 ++ tests/fixtures/fold/non_utf8.input | 1 + tests/fixtures/fold/non_utf8_tab_stops.input | 11 ++++++++ .../fold/non_utf8_tab_stops_w16.expected | 13 +++++++++ .../fold/non_utf8_tab_stops_w8.expected | 17 ++++++++++++ 6 files changed, 71 insertions(+) create mode 100644 tests/fixtures/fold/non_utf8.expected create mode 100644 tests/fixtures/fold/non_utf8.input create mode 100644 tests/fixtures/fold/non_utf8_tab_stops.input create mode 100644 tests/fixtures/fold/non_utf8_tab_stops_w16.expected create mode 100644 tests/fixtures/fold/non_utf8_tab_stops_w8.expected diff --git a/tests/by-util/test_fold.rs b/tests/by-util/test_fold.rs index d916a9c77..8747528ad 100644 --- a/tests/by-util/test_fold.rs +++ b/tests/by-util/test_fold.rs @@ -554,3 +554,30 @@ fn test_obsolete_syntax() { .succeeds() .stdout_is("test1\n \ntest2\n \ntest3\n \ntest4\n \ntest5\n \ntest6\n "); } +#[test] +fn test_byte_break_at_non_utf8_character() { + new_ucmd!() + .arg("-b") + .arg("-s") + .arg("-w") + .arg("40") + .arg("non_utf8.input") + .succeeds() + .stdout_is_fixture_bytes("non_utf8.expected"); +} +#[test] +fn test_tab_advances_at_non_utf8_character() { + new_ucmd!() + .arg("-w8") + .arg("non_utf8_tab_stops.input") + .succeeds() + .stdout_is_fixture_bytes("non_utf8_tab_stops_w8.expected"); +} +#[test] +fn test_all_tab_advances_at_non_utf8_character() { + new_ucmd!() + .arg("-w16") + .arg("non_utf8_tab_stops.input") + .succeeds() + .stdout_is_fixture_bytes("non_utf8_tab_stops_w16.expected"); +} diff --git a/tests/fixtures/fold/non_utf8.expected b/tests/fixtures/fold/non_utf8.expected new file mode 100644 index 000000000..8f96c38f4 --- /dev/null +++ b/tests/fixtures/fold/non_utf8.expected @@ -0,0 +1,2 @@ +Alle Menschen sind frei und gleich an +Würde und Rechten geboren diff --git a/tests/fixtures/fold/non_utf8.input b/tests/fixtures/fold/non_utf8.input new file mode 100644 index 000000000..7b3ee01f3 --- /dev/null +++ b/tests/fixtures/fold/non_utf8.input @@ -0,0 +1 @@ +Alle Menschen sind frei und gleich an Würde und Rechten geboren diff --git a/tests/fixtures/fold/non_utf8_tab_stops.input b/tests/fixtures/fold/non_utf8_tab_stops.input new file mode 100644 index 000000000..b9e283564 --- /dev/null +++ b/tests/fixtures/fold/non_utf8_tab_stops.input @@ -0,0 +1,11 @@ +À +ÀÁ +ÀÁÂ +ÀÁÂÃ +ÀÁÂÃÄ +ÀÁÂÃÄÅ +ÀÁÂÃÄÅÆ +ÀÁÂÃÄÅÆÇ +ÀÁÂÃÄÅÆÇÈ +ÀÁÂÃÄÅÆÇ È +ÀÁÂÃÄÅÆÇ È É diff --git a/tests/fixtures/fold/non_utf8_tab_stops_w16.expected b/tests/fixtures/fold/non_utf8_tab_stops_w16.expected new file mode 100644 index 000000000..8ed3c8eaa --- /dev/null +++ b/tests/fixtures/fold/non_utf8_tab_stops_w16.expected @@ -0,0 +1,13 @@ +À +ÀÁ +ÀÁÂ +ÀÁÂÃ +ÀÁÂÃÄ +ÀÁÂÃÄÅ +ÀÁÂÃÄÅÆ +ÀÁÂÃÄÅÆÇ +ÀÁÂÃÄÅÆÇÈ +ÀÁÂÃÄÅÆÇ +È +ÀÁÂÃÄÅÆÇ +È É diff --git a/tests/fixtures/fold/non_utf8_tab_stops_w8.expected b/tests/fixtures/fold/non_utf8_tab_stops_w8.expected new file mode 100644 index 000000000..516dd43a4 --- /dev/null +++ b/tests/fixtures/fold/non_utf8_tab_stops_w8.expected @@ -0,0 +1,17 @@ +À +ÀÁ +ÀÁÂ +ÀÁÂÃ +ÀÁÂÃÄ +ÀÁÂÃÄÅ +ÀÁÂÃÄÅÆ +ÀÁÂÃÄÅÆÇ +ÀÁÂÃÄÅÆÇ +È +ÀÁÂÃÄÅÆÇ + +È +ÀÁÂÃÄÅÆÇ + +È +É