@@ -223,6 +223,7 @@ func TestHardWrap(t *testing.T) {
223
223
false ,
224
224
"" ,
225
225
},
226
+ // If the text fits -> passing through
226
227
{
227
228
"[38;2;248;248;242m[38;2;249;38;114mtest[0m" ,
228
229
"[38;2;248;248;242m[38;2;249;38;114mtest[0m" ,
@@ -231,6 +232,7 @@ func TestHardWrap(t *testing.T) {
231
232
true ,
232
233
"" ,
233
234
},
235
+ // If requested preserve spaces, no matter how much.
234
236
{
235
237
" " ,
236
238
" \n \n \n \n \n \n \n \n \n " ,
@@ -239,6 +241,15 @@ func TestHardWrap(t *testing.T) {
239
241
true ,
240
242
"" ,
241
243
},
244
+ // If requested preserve spaces, no matter how much and wrap them accordingly
245
+ {
246
+ " " ,
247
+ " \n \n \n \n \n \n \n \n \n \n " ,
248
+ 4 ,
249
+ true ,
250
+ true ,
251
+ "" ,
252
+ },
242
253
}
243
254
for i , tc := range tt {
244
255
f := NewWriter (tc .Limit )
@@ -257,3 +268,18 @@ func TestHardWrap(t *testing.T) {
257
268
}
258
269
}
259
270
}
271
+
272
+ func TestHarWrapShort (t * testing.T ) {
273
+ testCase := "\x1B [38;2;249;38;114m(\x1B [0m\x1B [38;2;248;248;242mjust an\n other test\x1B [38;2;249;38;114m)\x1B [0m"
274
+ expected := `[38;2;249;38;114m([0m[38;2;248;248;242mju[0m
275
+ [38;2;248;248;242mst[0m
276
+ [38;2;248;248;242man[0m
277
+ [38;2;248;248;242moth[0m
278
+ [38;2;248;248;242mer[0m
279
+ [38;2;248;248;242mtes[0m
280
+ [38;2;248;248;242mt[38;2;249;38;114m)[0m`
281
+ out := HardWrap (testCase , 3 , " " )
282
+ if out != expected {
283
+ t .Errorf ("From input expected:\n \n `%s`\n \n Actual Output:\n \n `%s`" , expected , out )
284
+ }
285
+ }
0 commit comments