Skip to content

Commit 87bb02e

Browse files
committed
* added unit test for mixed line endings
1 parent 22283d2 commit 87bb02e

File tree

1 file changed

+55
-23
lines changed

1 file changed

+55
-23
lines changed

txtar/archive_test.go

Lines changed: 55 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,33 +33,33 @@ hello world
3333
-- empty filename line --
3434
some content
3535
-- --`,
36-
parsed: &Archive{
37-
Comment: []byte("comment1\ncomment2\n"),
38-
Files: []File{
39-
{"file1", []byte("File 1 text.\n-- foo ---\nMore file 1 text.\n")},
40-
{"file 2", []byte("File 2 text.\n")},
41-
{"empty", []byte{}},
42-
{"noNL", []byte("hello world\n")},
43-
{"empty filename line", []byte("some content\n-- --\n")},
44-
},
45-
},
36+
parsed: &Archive{
37+
Comment: []byte("comment1\ncomment2\n"),
38+
Files: []File{
39+
{"file1", []byte("File 1 text.\n-- foo ---\nMore file 1 text.\n")},
40+
{"file 2", []byte("File 2 text.\n")},
41+
{"empty", []byte{}},
42+
{"noNL", []byte("hello world\n")},
43+
{"empty filename line", []byte("some content\n-- --\n")},
44+
},
45+
},
4646
},
4747
{
4848
name: "basic CRLF",
4949
text: "comment1\r\n" +
50-
"comment2\r\n" +
51-
"-- file1 --\r\n" +
52-
"File 1 text.\r\n" +
53-
"-- foo ---\r\n" +
54-
"More file 1 text.\r\n" +
55-
"-- file 2 --\r\n" +
56-
"File 2 text.\r\n" +
57-
"-- empty --\r\n" +
58-
"-- noNL --\r\n" +
59-
"hello world\r\n" +
60-
"-- empty filename line --\r\n" +
61-
"some content\r\n" +
62-
"-- --\r\n",
50+
"comment2\r\n" +
51+
"-- file1 --\r\n" +
52+
"File 1 text.\r\n" +
53+
"-- foo ---\r\n" +
54+
"More file 1 text.\r\n" +
55+
"-- file 2 --\r\n" +
56+
"File 2 text.\r\n" +
57+
"-- empty --\r\n" +
58+
"-- noNL --\r\n" +
59+
"hello world\r\n" +
60+
"-- empty filename line --\r\n" +
61+
"some content\r\n" +
62+
"-- --\r\n",
6363
parsed: &Archive{
6464
Comment: []byte("comment1\r\ncomment2\r\n"),
6565
Files: []File{
@@ -71,6 +71,38 @@ some content
7171
},
7272
},
7373
},
74+
{
75+
name: "mixed",
76+
text: "comment1\n" +
77+
"comment2\r\n" +
78+
"-- file1 --\r\n" +
79+
"File 1 text.\n" +
80+
"-- foo ---\r\n" +
81+
"More file 1 text.\r\n" +
82+
"-- file 2 --\r\n" +
83+
"File 2 text.\r\n" +
84+
"-- file 3 --\r\n" +
85+
"File 3 text.\r\n" +
86+
"-- foo ---\r\n" +
87+
"More file 3 text.\r\n" +
88+
"-- empty --\r\n" +
89+
"-- noNL --\r\n" +
90+
"hello world\r\n" +
91+
"-- empty filename line --\r\n" +
92+
"some content\r\n" +
93+
"-- --\n",
94+
parsed: &Archive{
95+
Comment: []byte("comment1\ncomment2\r\n"),
96+
Files: []File{
97+
{"file1", []byte("File 1 text.\n-- foo ---\r\nMore file 1 text.\r\n")},
98+
{"file 2", []byte("File 2 text.\r\n")},
99+
{"file 3", []byte("File 3 text.\r\n-- foo ---\r\nMore file 3 text.\r\n")},
100+
{"empty", []byte{}},
101+
{"noNL", []byte("hello world\r\n")},
102+
{"empty filename line", []byte("some content\r\n-- --\n")},
103+
},
104+
},
105+
},
74106
}
75107
for _, tt := range tests {
76108
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)