Skip to content

Commit 3403a16

Browse files
committed
update tests
1 parent 3202072 commit 3403a16

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

diffmatchpatch/diff_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,10 @@ func TestDiffLinesToChars(t *testing.T) {
314314
dmp := New()
315315

316316
for i, tc := range []TestCase{
317-
{"", "alpha\r\nbeta\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\nbeta\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"}},
319319
// Omit final newline.
320-
{"alpha\nbeta\nalpha", "", "1,2,3", "", []string{"", "alpha\n", "beta\n", "alpha"}},
320+
{"alpha\nbeta\nalpha", "", "\x01\x02\x03", "", []string{"", "alpha\n", "beta\n", "alpha"}},
321321
} {
322322
actualChars1, actualChars2, actualLines := dmp.DiffLinesToChars(tc.Text1, tc.Text2)
323323
assert.Equal(t, tc.ExpectedChars1, actualChars1, fmt.Sprintf("Test case #%d, %#v", i, tc))
@@ -330,14 +330,14 @@ func TestDiffLinesToChars(t *testing.T) {
330330
lineList := []string{
331331
"", // Account for the initial empty element of the lines array.
332332
}
333-
var charList []string
333+
var charList []rune
334334
for x := 1; x < n+1; x++ {
335335
lineList = append(lineList, strconv.Itoa(x)+"\n")
336-
charList = append(charList, strconv.Itoa(x))
336+
charList = append(charList, rune(x))
337337
}
338338
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))
341341

342342
actualChars1, actualChars2, actualLines := dmp.DiffLinesToChars(lines, "")
343343
assert.Equal(t, chars, actualChars1)
@@ -358,8 +358,8 @@ func TestDiffCharsToLines(t *testing.T) {
358358
for i, tc := range []TestCase{
359359
{
360360
Diffs: []Diff{
361-
{DiffEqual, "1,2,1"},
362-
{DiffInsert, "2,1,2"},
361+
{DiffEqual, "\x01\x02\x01"},
362+
{DiffInsert, "\x02\x01\x02"},
363363
},
364364
Lines: []string{"", "alpha\n", "beta\n"},
365365

@@ -378,13 +378,13 @@ func TestDiffCharsToLines(t *testing.T) {
378378
lineList := []string{
379379
"", // Account for the initial empty element of the lines array.
380380
}
381-
charList := []string{}
381+
charList := []rune{}
382382
for x := 1; x <= n; x++ {
383383
lineList = append(lineList, strconv.Itoa(x)+"\n")
384-
charList = append(charList, strconv.Itoa(x))
384+
charList = append(charList, rune(x))
385385
}
386386
assert.Equal(t, n, len(charList))
387-
chars := strings.Join(charList[:], ",")
387+
chars := string(charList)
388388

389389
actual := dmp.DiffCharsToLines([]Diff{Diff{DiffDelete, chars}}, lineList)
390390
assert.Equal(t, []Diff{Diff{DiffDelete, strings.Join(lineList, "")}}, actual)

0 commit comments

Comments
 (0)