@@ -73,6 +73,39 @@ some content
73
73
UseCRLF : true ,
74
74
},
75
75
},
76
+ {
77
+ name : "mixed" ,
78
+ text : "comment1\n " +
79
+ "comment2\r \n " +
80
+ "-- file1 --\r \n " +
81
+ "File 1 text.\n " +
82
+ "-- foo ---\r \n " +
83
+ "More file 1 text.\r \n " +
84
+ "-- file 2 --\r \n " +
85
+ "File 2 text.\r \n " +
86
+ "-- file 3 --\r \n " +
87
+ "File 3 text.\r \n " +
88
+ "-- foo ---\r \n " +
89
+ "More file 3 text.\r \n " +
90
+ "-- empty --\r \n " +
91
+ "-- noNL --\r \n " +
92
+ "hello world\r \n " +
93
+ "-- empty filename line --\r \n " +
94
+ "some content\n " +
95
+ "-- --\n " ,
96
+ parsed : & Archive {
97
+ Comment : []byte ("comment1\n comment2\r \n " ),
98
+ Files : []File {
99
+ {"file1" , []byte ("File 1 text.\n -- foo ---\r \n More file 1 text.\r \n " )},
100
+ {"file 2" , []byte ("File 2 text.\r \n " )},
101
+ {"file 3" , []byte ("File 3 text.\r \n -- foo ---\r \n More file 3 text.\r \n " )},
102
+ {"empty" , []byte {}},
103
+ {"noNL" , []byte ("hello world\r \n " )},
104
+ {"empty filename line" , []byte ("some content\n -- --\n \r \n " )},
105
+ },
106
+ UseCRLF : true ,
107
+ },
108
+ },
76
109
}
77
110
for _ , tt := range tests {
78
111
t .Run (tt .name , func (t * testing.T ) {
@@ -144,6 +177,39 @@ hello world
144
177
"-- noNL --\r \n " +
145
178
"hello world\r \n " ,
146
179
},
180
+ {
181
+ name : "mixed" ,
182
+ input : & Archive {
183
+ Comment : []byte ("comment1\n comment2\r \n " ),
184
+ Files : []File {
185
+ {"file1" , []byte ("File 1 text.\n -- foo ---\r \n More file 1 text.\r \n " )},
186
+ {"file 2" , []byte ("File 2 text.\r \n " )},
187
+ {"file 3" , []byte ("File 3 text.\r \n -- foo ---\r \n More file 3 text.\r \n " )},
188
+ {"empty" , []byte {}},
189
+ {"noNL" , []byte ("hello world\r \n " )},
190
+ {"empty filename line" , []byte ("some content\r \n -- --\n " )},
191
+ },
192
+ UseCRLF : true ,
193
+ },
194
+ wanted : "comment1\n " +
195
+ "comment2\r \n " +
196
+ "-- file1 --\r \n " +
197
+ "File 1 text.\n " +
198
+ "-- foo ---\r \n " +
199
+ "More file 1 text.\r \n " +
200
+ "-- file 2 --\r \n " +
201
+ "File 2 text.\r \n " +
202
+ "-- file 3 --\r \n " +
203
+ "File 3 text.\r \n " +
204
+ "-- foo ---\r \n " +
205
+ "More file 3 text.\r \n " +
206
+ "-- empty --\r \n " +
207
+ "-- noNL --\r \n " +
208
+ "hello world\r \n " +
209
+ "-- empty filename line --\r \n " +
210
+ "some content\r \n " +
211
+ "-- --\n \r \n " ,
212
+ },
147
213
}
148
214
for _ , tt := range tests {
149
215
t .Run (tt .name , func (t * testing.T ) {
0 commit comments