-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwrapper_test.go
More file actions
627 lines (571 loc) Β· 19.2 KB
/
wrapper_test.go
File metadata and controls
627 lines (571 loc) Β· 19.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
package wrap_test
import (
"strings"
"testing"
"unicode/utf8"
"github.com/bbrks/wrap/v2"
)
// tests contains various line lengths to test our wrap functions.
var testLimits = []int{-5, 0, 5, 10, 25, 80, 120, 500}
// loremIpsums contains lorem ipsum of various line-lengths and word-lengths.
var loremIpsums = []string{
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vulputate quam nibh, et faucibus enim gravida vel. Integer bibendum lectus et erat semper fermentum quis a risus. Fusce dignissim tempus metus non pretium. Nunc sagittis magna nec purus porttitor mollis. Pellentesque feugiat quam eget laoreet aliquet. Donec gravida congue massa, et sollicitudin turpis lacinia a. Fusce non tortor magna. Cras vel finibus tellus.",
"Quisque facilisis dictum tellus vitae sagittis. Sed gravida nulla vel ultrices ultricies. Praesent vehicula ligula sit amet massa elementum, eget fringilla nunc ultricies. Fusce aliquet nunc ac lectus tempus sagittis. Phasellus molestie commodo leo, sit amet ultrices est. Integer vitae hendrerit neque, in pretium tellus. Nam egestas mauris id nunc sollicitudin ullamcorper. Integer eget accumsan nulla. Phasellus quis eros non leo condimentum fringilla quis sit amet tellus. Donec semper vulputate lacinia. In hac habitasse platea dictumst. Aliquam varius metus fringilla sapien cursus cursus.\n",
"Curabitur tellus libero, feugiat vel mauris et, consequat auctor ipsum. Praesent sed pharetra dolor, at convallis lectus. Vivamus at ullamcorper sem. Sed euismod vel massa a dignissim. Proin auctor nibh at pretium facilisis. Ut aliquam erat lacus. Integer sit amet magna urna. Maecenas bibendum pretium mauris convallis semper. Nunc arcu tortor, pulvinar quis eros ut, mattis placerat tortor. Sed et lacus magna. Proin ultrices fermentum sem et placerat. Donec eget sapien mi. Maecenas maximus justo sed vulputate pulvinar. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vestibulum accumsan, sapien sit amet suscipit dignissim, velit velit maximus elit, a cursus mi odio eu magna. Nunc nec fermentum nisi, non imperdiet purus.",
"Vestibulum convallis magna arcu, sagittis porta mi luctus sit amet. Nunc tellus magna, fermentum et mi vitae, consectetur vestibulum nulla. Fusce ornare, augue vitae tempor pellentesque, orci orci fringilla tortor, porta feugiat justo purus nec sem. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nulla pellentesque sed odio in aliquam. Fusce sed molestie velit. Curabitur id quam ac felis accumsan vehicula quis in ex.",
"\nDuis ac ornare erat. Nulla in odio eget ante tristique dignissim a non erat. Sed non nisi vitae arcu dapibus porta vitae dignissim ante. Cras et fringilla turpis. Maecenas arcu nibh, tempus euismod pretium eget, hendrerit vitae arcu. Sed vel dolor quam. Etiam consequat sed dolor ut elementum. Quisque dictum tempor pretium. Sed eu sollicitudin mi, in commodo ante.",
"£££ ££££££ £££££ ££££ ££££ ££ ££££ ££ £ ££ £££££££ ££ £££ £££££££££ ££ ££££ £££££ ££ ££££££££ £ ££££ £££\n",
"",
}
func TestWrapper_Wrap(t *testing.T) {
w, n := wrap.NewWrapper(), wrap.NewWrapper()
n.StripTrailingNewline = true
for _, l := range testLimits {
for _, s := range loremIpsums {
wrapped := w.Wrap(s, l)
stripped := n.Wrap(s, l)
for _, v := range strings.Split(wrapped, w.Newline) {
if !strings.Contains(v, " ") {
continue
}
if l < 1 {
if strings.Trim(s, "\n") != v {
t.Error("Wrapped value does not equal original")
}
continue
}
if utf8.RuneCountInString(v) > l {
t.Errorf("Line length greater than %d: %s", l, v)
}
}
if wrapped != stripped+"\n" {
t.Error("Wrapped value did not strip newline")
}
}
}
}
func TestWrapper_Wrap_CutLongWords(t *testing.T) {
tests := []struct {
name string
input string
limit int
expected string
}{
{"short word", "A short woooord", 8, "A short\nwoooord"},
{"perfect word", "A perfect wooooord", 8, "A\nperfect\nwooooord"},
{"long word", "A long wooooooooooooord", 8, "A long\nwooooooo\noooooord"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
w := wrap.NewWrapper()
w.CutLongWords = true
w.StripTrailingNewline = true
if got := w.Wrap(tt.input, tt.limit); got != tt.expected {
t.Errorf("Wrap(%q, %d) = %q, want %q", tt.input, tt.limit, got, tt.expected)
}
})
}
}
func TestCutLongWordsUTF8Multibyte(t *testing.T) {
tests := []struct {
name string
input string
prefix string
limit int
}{
{"multibyte_char_U+0080", "\u00800", "Σ½00", 4},
{"multibyte_char_U+00FF", "\u00FF\u00FF\u00FF", "", 2},
{"emoji_4byte", "ππππ", "", 2},
{"mixed_multibyte", "ζ₯ζ¬θͺγγΉγ", "-> ", 5},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
w := wrap.NewWrapper()
w.CutLongWords = true
w.OutputLinePrefix = tt.prefix
result := w.Wrap(tt.input, tt.limit)
if !utf8.ValidString(result) {
t.Errorf("Result is not valid UTF-8: %q (bytes: %v)", result, []byte(result))
}
})
}
}
func TestWrapper_Breakpoints(t *testing.T) {
tests := []struct {
name string
input string
breakpoints string
limit int
expected string
}{
{"space only", "hello world foo bar", " ", 10, "hello\nworld foo\nbar\n"},
{"hyphen only", "hello-world-foo-bar", "-", 12, "hello-world-\nfoo-bar\n"},
{"custom breakpoint", "hello|world|foo|bar", "|", 12, "hello|world|\nfoo|bar\n"},
{"multiple custom breakpoints", "hello|world,foo;bar", "|,;", 12, "hello|world,\nfoo;bar\n"},
{"no breakpoints found", "helloworldfoobar", " ", 10, "helloworldfoobar\n"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
w := wrap.NewWrapper()
w.Breakpoints = tt.breakpoints
if got := w.Wrap(tt.input, tt.limit); got != tt.expected {
t.Errorf("got %q, want %q", got, tt.expected)
}
})
}
}
func TestWrapper_Newline(t *testing.T) {
tests := []struct {
name string
input string
newline string
limit int
expected string
}{
{"default newline", "hello world", "\n", 5, "hello\nworld\n"},
{"CRLF newline", "hello world", "\r\n", 5, "hello\r\nworld\r\n"},
{"custom newline", "hello world", "<br>", 5, "hello<br>world<br>"},
{"input with CRLF", "line1\r\nline2", "\r\n", 80, "line1\r\nline2\r\n"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
w := wrap.NewWrapper()
w.Newline = tt.newline
if got := w.Wrap(tt.input, tt.limit); got != tt.expected {
t.Errorf("got %q, want %q", got, tt.expected)
}
})
}
}
func TestWrapper_OutputLinePrefix(t *testing.T) {
tests := []struct {
name string
input string
prefix string
limit int
expected string
}{
{"comment prefix", "hello world", "// ", 10, "// hello\n// world\n"},
{"bullet prefix", "hello world", "* ", 10, "* hello\n* world\n"},
{"empty prefix", "hello world", "", 5, "hello\nworld\n"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
w := wrap.NewWrapper()
w.OutputLinePrefix = tt.prefix
if got := w.Wrap(tt.input, tt.limit); got != tt.expected {
t.Errorf("got %q, want %q", got, tt.expected)
}
})
}
}
func TestWrapper_OutputLineSuffix(t *testing.T) {
tests := []struct {
name string
input string
suffix string
limit int
expected string
}{
{"trailing backslash", "hello world", " \\", 10, "hello \\\nworld \\\n"},
{"HTML break", "hello world", "<br>", 10, "hello<br>\nworld<br>\n"},
{"empty suffix", "hello world", "", 5, "hello\nworld\n"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
w := wrap.NewWrapper()
w.OutputLineSuffix = tt.suffix
if got := w.Wrap(tt.input, tt.limit); got != tt.expected {
t.Errorf("got %q, want %q", got, tt.expected)
}
})
}
}
func TestWrapper_LimitIncludesPrefixSuffix(t *testing.T) {
tests := []struct {
name string
limitIncludesPrefixSuffix bool
expected string
}{
{"includes prefix/suffix in limit", true, ">> hello\n>> world\n>> foo\n"},
{"excludes prefix/suffix from limit", false, ">> hello\n>> world foo\n"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
w := wrap.NewWrapper()
w.OutputLinePrefix = ">> "
w.LimitIncludesPrefixSuffix = tt.limitIncludesPrefixSuffix
if got := w.Wrap("hello world foo", 10); got != tt.expected {
t.Errorf("got %q, want %q", got, tt.expected)
}
})
}
}
func TestWrapper_TrimInputPrefix(t *testing.T) {
tests := []struct {
name string
input string
trim string
limit int
expected string
}{
{"trim comment prefix", "// hello world", "// ", 80, "hello world\n"},
{"trim multiline", "// line1\n// line2", "// ", 80, "line1\nline2\n"},
{"no match", "hello world", "// ", 80, "hello world\n"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
w := wrap.NewWrapper()
w.TrimInputPrefix = tt.trim
if got := w.Wrap(tt.input, tt.limit); got != tt.expected {
t.Errorf("got %q, want %q", got, tt.expected)
}
})
}
}
func TestWrapper_TrimInputSuffix(t *testing.T) {
tests := []struct {
name string
input string
trim string
limit int
expected string
}{
{"trim trailing marker", "hello world //", " //", 80, "hello world\n"},
{"trim multiline", "line1 //\nline2 //", " //", 80, "line1\nline2\n"},
{"no match", "hello world", " //", 80, "hello world\n"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
w := wrap.NewWrapper()
w.TrimInputSuffix = tt.trim
if got := w.Wrap(tt.input, tt.limit); got != tt.expected {
t.Errorf("got %q, want %q", got, tt.expected)
}
})
}
}
func TestWrapper_StripTrailingNewline(t *testing.T) {
tests := []struct {
name string
stripTrailingNewline bool
expected string
}{
{"keep trailing newline", false, "hello\nworld\n"},
{"strip trailing newline", true, "hello\nworld"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
w := wrap.NewWrapper()
w.StripTrailingNewline = tt.stripTrailingNewline
if got := w.Wrap("hello world", 5); got != tt.expected {
t.Errorf("got %q, want %q", got, tt.expected)
}
})
}
}
func TestWrapper_CutLongWordsFeatures(t *testing.T) {
tests := []struct {
name string
input string
limit int
expected string
}{
{"cut single long word", "abcdefghij", 5, "abcde\nfghij"},
{"cut with normal words", "hi abcdefghij bye", 5, "hi\nabcde\nfghij\nbye"},
{"no cut needed", "hello world", 10, "hello\nworld"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
w := wrap.NewWrapper()
w.CutLongWords = true
w.StripTrailingNewline = true
if got := w.Wrap(tt.input, tt.limit); got != tt.expected {
t.Errorf("got %q, want %q", got, tt.expected)
}
})
}
}
func TestWrapper_CombinedFeatures(t *testing.T) {
tests := []struct {
name string
input string
limit int
prefix string
suffix string
trimInputPrefix string
expected string
}{
{
name: "prefix and suffix together",
input: "hello world",
limit: 15,
prefix: "/* ",
suffix: " */",
expected: "/* hello */\n/* world */",
},
{
name: "trim input and add output prefix",
input: "# hello world",
limit: 10,
prefix: "// ",
trimInputPrefix: "# ",
expected: "// hello\n// world",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
w := wrap.NewWrapper()
w.OutputLinePrefix = tt.prefix
w.OutputLineSuffix = tt.suffix
w.TrimInputPrefix = tt.trimInputPrefix
w.StripTrailingNewline = true
if got := w.Wrap(tt.input, tt.limit); got != tt.expected {
t.Errorf("got %q, want %q", got, tt.expected)
}
})
}
}
func TestWrapper_EdgeCases(t *testing.T) {
tests := []struct {
name string
input string
limit int
stripTrailingNewline bool
expected string
}{
{"empty string", "", 80, false, "\n"},
{"empty string with strip", "", 80, true, ""},
{"limit zero", "hello world", 0, true, "hello world"},
{"limit negative", "hello world", -5, true, "hello world"},
{"string shorter than limit", "hi", 80, true, "hi"},
{"multiple consecutive newlines", "a\n\nb", 80, true, "a\n\nb"},
{"only newlines", "\n\n", 80, true, "\n\n"},
{"unicode multibyte with spaces", "ζ₯ζ¬ θͺγ γΉγ", 3, true, "ζ₯ζ¬\nθͺγ\nγΉγ"},
{"unicode no breakpoint", "ζ₯ζ¬θͺγγΉγ", 3, true, "ζ₯ζ¬θͺγγΉγ"},
{"limit equals word length", "hello world", 5, true, "hello\nworld"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
w := wrap.NewWrapper()
w.StripTrailingNewline = tt.stripTrailingNewline
if got := w.Wrap(tt.input, tt.limit); got != tt.expected {
t.Errorf("got %q, want %q", got, tt.expected)
}
})
}
}
func TestWrap_Shorthand(t *testing.T) {
if got := wrap.Wrap("hello world", 5); got != "hello\nworld\n" {
t.Errorf("got %q, want %q", got, "hello\nworld\n")
}
}
func TestWrapper_UTF8EdgeCases(t *testing.T) {
tests := []struct {
name string
input string
limit int
cutLongWords bool
expected string
}{
{"non-ASCII with CutLongWords", "ζ₯ζ¬θͺγγΉγ", 3, true, "ζ₯ζ¬θͺ\nγγΉγ"},
{"short non-ASCII string", "ζ₯", 10, false, "ζ₯"},
{"non-ASCII CutLongWords exact boundary", "ζ₯ζ¬θͺ", 2, true, "ζ₯ζ¬\nθͺ"},
{"mixed ASCII and non-ASCII", "hello δΈη world", 8, false, "hello δΈη\nworld"},
{"non-ASCII longer than limit in bytes but not runes", "ζ₯ζ¬", 10, false, "ζ₯ζ¬"},
{"non-ASCII exceeding limit needs wrap", "γγγ«γ‘γ― δΈη", 5, false, "γγγ«γ‘γ―\nδΈη"},
{"emoji with spaces", "ππ ππ ππ", 4, false, "ππ\nππ\nππ"},
{"CutLongWords with emoji", "ππππ", 2, true, "ππ\nππ"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
w := wrap.NewWrapper()
w.CutLongWords = tt.cutLongWords
w.StripTrailingNewline = true
if got := w.Wrap(tt.input, tt.limit); got != tt.expected {
t.Errorf("got %q, want %q", got, tt.expected)
}
})
}
}
func TestWrapper_EmptyNewline(t *testing.T) {
// Empty newline should not cause infinite loop, should use default
w := wrap.NewWrapper()
w.Newline = ""
w.StripTrailingNewline = true
result := w.Wrap("hello world", 5)
expected := "hello\nworld"
if result != expected {
t.Errorf("got %q, want %q", result, expected)
}
}
func TestWrapper_LeadingBreakpoints(t *testing.T) {
tests := []struct {
name string
input string
limit int
expected string
}{
{"single leading space", " hello world", 5, "hello\nworld"},
{"multiple leading spaces", " hello", 10, "hello"},
{"leading space with wrap", " hello world", 80, "hello world"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
w := wrap.NewWrapper()
w.StripTrailingNewline = true
if got := w.Wrap(tt.input, tt.limit); got != tt.expected {
t.Errorf("got %q, want %q", got, tt.expected)
}
})
}
}
func TestWrapper_ConsecutiveBreakpoints(t *testing.T) {
tests := []struct {
name string
input string
limit int
expected string
}{
{"double space", "hello world", 6, "hello\nworld"},
{"triple space", "hello world", 6, "hello\nworld"},
{"multiple gaps", "a b c", 3, "a\nb\nc"},
{"spaces around words", " hello world ", 5, "hello\nworld\n"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
w := wrap.NewWrapper()
w.StripTrailingNewline = true
if got := w.Wrap(tt.input, tt.limit); got != tt.expected {
t.Errorf("got %q, want %q", got, tt.expected)
}
})
}
}
func TestWrapper_MinimumRaggedness(t *testing.T) {
tests := []struct {
name string
input string
limit int
expected string
}{
// The classic example from xxyxyz.org
// Greedy: "a b c d e" / "f g h i j" / "k l m n o" / "p" (very uneven)
// Optimal: "a b c d" / "e f g h" / "i j k l" / "m n o p" (balanced)
{
name: "balanced paragraph",
input: "a b c d e f g h i j k l m n o p",
limit: 9,
expected: "a b c d\ne f g h\ni j k l\nm n o p",
},
{
name: "simple two words",
input: "hello world",
limit: 10,
expected: "hello\nworld",
},
{
name: "fits on one line",
input: "hello world",
limit: 20,
expected: "hello world",
},
{
name: "single word",
input: "hello",
limit: 10,
expected: "hello",
},
{
name: "empty string",
input: "",
limit: 10,
expected: "",
},
{
name: "three even words",
input: "aaa bbb ccc",
limit: 5,
expected: "aaa\nbbb\nccc",
},
{
name: "longer text",
input: "The quick brown fox jumps over the lazy dog",
limit: 15,
expected: "The quick brown\nfox jumps over\nthe lazy dog",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
w := wrap.NewWrapper()
w.MinimumRaggedness = true
w.StripTrailingNewline = true
if got := w.Wrap(tt.input, tt.limit); got != tt.expected {
t.Errorf("got %q, want %q", got, tt.expected)
}
})
}
}
func TestWrapper_MinimumRaggednessWithPrefix(t *testing.T) {
w := wrap.NewWrapper()
w.MinimumRaggedness = true
w.StripTrailingNewline = true
w.OutputLinePrefix = "// "
input := "hello world foo bar"
got := w.Wrap(input, 15)
expected := "// hello world\n// foo bar"
if got != expected {
t.Errorf("got %q, want %q", got, expected)
}
}
func TestWrapper_MinimumRaggednessWithCutLongWords(t *testing.T) {
w := wrap.NewWrapper()
w.MinimumRaggedness = true
w.CutLongWords = true
w.StripTrailingNewline = true
input := "hello verylongword world"
got := w.Wrap(input, 5)
// verylongword should be cut into chunks
expected := "hello\nveryl\nongwo\nrd\nworld"
if got != expected {
t.Errorf("got %q, want %q", got, expected)
}
}
func TestWrapper_MinimumRaggednessVsGreedy(t *testing.T) {
// This test demonstrates the difference between greedy and optimal
input := "a b c d e f g h i j k l m n o p qqqqqqqqq"
limit := 9
greedy := wrap.NewWrapper()
greedy.StripTrailingNewline = true
greedyResult := greedy.Wrap(input, limit)
optimal := wrap.NewWrapper()
optimal.MinimumRaggedness = true
optimal.StripTrailingNewline = true
optimalResult := optimal.Wrap(input, limit)
// Results should be different - optimal should be more balanced
if greedyResult == optimalResult {
t.Log("Greedy and optimal produced same result (may be acceptable for some inputs)")
}
// Both should be valid (no line exceeds limit except possibly the last word)
for _, line := range strings.Split(greedyResult, "\n") {
if utf8.RuneCountInString(line) > limit && line != "qqqqqqqqq" {
t.Errorf("greedy line exceeds limit: %q", line)
}
}
for _, line := range strings.Split(optimalResult, "\n") {
if utf8.RuneCountInString(line) > limit && line != "qqqqqqqqq" {
t.Errorf("optimal line exceeds limit: %q", line)
}
}
}
func TestWrapper_MinimumRaggednessUTF8(t *testing.T) {
w := wrap.NewWrapper()
w.MinimumRaggedness = true
w.StripTrailingNewline = true
input := "ζ₯ζ¬ θͺγ γΉγ ζε"
got := w.Wrap(input, 5)
// Should produce valid UTF-8 and respect rune counts
if !utf8.ValidString(got) {
t.Errorf("result is not valid UTF-8: %q", got)
}
}