Skip to content

Commit faa6a9b

Browse files
committed
tests/fold: add tests for non-utf8 streams
1 parent cad7d0f commit faa6a9b

File tree

6 files changed

+71
-0
lines changed

6 files changed

+71
-0
lines changed

tests/by-util/test_fold.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,3 +554,30 @@ fn test_obsolete_syntax() {
554554
.succeeds()
555555
.stdout_is("test1\n \ntest2\n \ntest3\n \ntest4\n \ntest5\n \ntest6\n ");
556556
}
557+
#[test]
558+
fn test_byte_break_at_non_utf8_character() {
559+
new_ucmd!()
560+
.arg("-b")
561+
.arg("-s")
562+
.arg("-w")
563+
.arg("40")
564+
.arg("non_utf8.input")
565+
.succeeds()
566+
.stdout_is_fixture_bytes("non_utf8.expected");
567+
}
568+
#[test]
569+
fn test_tab_advances_at_non_utf8_character() {
570+
new_ucmd!()
571+
.arg("-w8")
572+
.arg("non_utf8_tab_stops.input")
573+
.succeeds()
574+
.stdout_is_fixture_bytes("non_utf8_tab_stops_w8.expected");
575+
}
576+
#[test]
577+
fn test_all_tab_advances_at_non_utf8_character() {
578+
new_ucmd!()
579+
.arg("-w16")
580+
.arg("non_utf8_tab_stops.input")
581+
.succeeds()
582+
.stdout_is_fixture_bytes("non_utf8_tab_stops_w16.expected");
583+
}

tests/fixtures/fold/non_utf8.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Alle Menschen sind frei und gleich an
2+
W�rde und Rechten geboren

tests/fixtures/fold/non_utf8.input

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Alle Menschen sind frei und gleich an W�rde und Rechten geboren
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
��
3+
���
4+
����
5+
�����
6+
������
7+
�������
8+
��������
9+
���������
10+
�������� �
11+
�������� � �
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
��
3+
���
4+
����
5+
�����
6+
������
7+
�������
8+
��������
9+
���������
10+
��������
11+
12+
��������
13+
� �
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
��
3+
���
4+
����
5+
�����
6+
������
7+
�������
8+
��������
9+
��������
10+
11+
��������
12+
13+
14+
��������
15+
16+
17+

0 commit comments

Comments
 (0)