@@ -314,10 +314,10 @@ func TestDiffLinesToChars(t *testing.T) {
314
314
dmp := New ()
315
315
316
316
for i , tc := range []TestCase {
317
- {"" , "alpha\r \n beta\r \n \r \n \r \n " , "" , "1,2,3,3 " , []string {"" , "alpha\r \n " , "beta\r \n " , "\r \n " }},
318
- {"a" , "b" , "1 " , "2 " , []string {"" , "a" , "b" }},
317
+ {"" , "alpha\r \n beta\r \n \r \n \r \n " , "" , "\x01 \x02 \x03 \x03 " , []string {"" , "alpha\r \n " , "beta\r \n " , "\r \n " }},
318
+ {"a" , "b" , "\x01 " , "\x02 " , []string {"" , "a" , "b" }},
319
319
// Omit final newline.
320
- {"alpha\n beta\n alpha" , "" , "1,2,3 " , "" , []string {"" , "alpha\n " , "beta\n " , "alpha" }},
320
+ {"alpha\n beta\n alpha" , "" , "\x01 \x02 \x03 " , "" , []string {"" , "alpha\n " , "beta\n " , "alpha" }},
321
321
} {
322
322
actualChars1 , actualChars2 , actualLines := dmp .DiffLinesToChars (tc .Text1 , tc .Text2 )
323
323
assert .Equal (t , tc .ExpectedChars1 , actualChars1 , fmt .Sprintf ("Test case #%d, %#v" , i , tc ))
@@ -330,14 +330,14 @@ func TestDiffLinesToChars(t *testing.T) {
330
330
lineList := []string {
331
331
"" , // Account for the initial empty element of the lines array.
332
332
}
333
- var charList []string
333
+ var charList []rune
334
334
for x := 1 ; x < n + 1 ; x ++ {
335
335
lineList = append (lineList , strconv .Itoa (x )+ "\n " )
336
- charList = append (charList , strconv . Itoa (x ))
336
+ charList = append (charList , rune (x ))
337
337
}
338
338
lines := strings .Join (lineList , "" )
339
- chars := strings . Join (charList [:], "," )
340
- assert .Equal (t , n , len (strings . Split ( chars , "," ) ))
339
+ chars := string (charList )
340
+ assert .Equal (t , n , len (charList ))
341
341
342
342
actualChars1 , actualChars2 , actualLines := dmp .DiffLinesToChars (lines , "" )
343
343
assert .Equal (t , chars , actualChars1 )
@@ -358,8 +358,8 @@ func TestDiffCharsToLines(t *testing.T) {
358
358
for i , tc := range []TestCase {
359
359
{
360
360
Diffs : []Diff {
361
- {DiffEqual , "1,2,1 " },
362
- {DiffInsert , "2,1,2 " },
361
+ {DiffEqual , "\x01 \x02 \x01 " },
362
+ {DiffInsert , "\x02 \x01 \x02 " },
363
363
},
364
364
Lines : []string {"" , "alpha\n " , "beta\n " },
365
365
@@ -378,13 +378,13 @@ func TestDiffCharsToLines(t *testing.T) {
378
378
lineList := []string {
379
379
"" , // Account for the initial empty element of the lines array.
380
380
}
381
- charList := []string {}
381
+ charList := []rune {}
382
382
for x := 1 ; x <= n ; x ++ {
383
383
lineList = append (lineList , strconv .Itoa (x )+ "\n " )
384
- charList = append (charList , strconv . Itoa (x ))
384
+ charList = append (charList , rune (x ))
385
385
}
386
386
assert .Equal (t , n , len (charList ))
387
- chars := strings . Join (charList [:], "," )
387
+ chars := string (charList )
388
388
389
389
actual := dmp .DiffCharsToLines ([]Diff {Diff {DiffDelete , chars }}, lineList )
390
390
assert .Equal (t , []Diff {Diff {DiffDelete , strings .Join (lineList , "" )}}, actual )
0 commit comments