(t *testing.T)
| 348 | } |
| 349 | |
| 350 | func TestDiffCharsToLines(t *testing.T) { |
| 351 | type TestCase struct { |
| 352 | Diffs []Diff |
| 353 | Lines []string |
| 354 | |
| 355 | Expected []Diff |
| 356 | } |
| 357 | |
| 358 | dmp := New() |
| 359 | |
| 360 | for i, tc := range []TestCase{ |
| 361 | { |
| 362 | Diffs: []Diff{ |
| 363 | {DiffEqual, "\x01\x02\x01"}, |
| 364 | {DiffInsert, "\x02\x01\x02"}, |
| 365 | }, |
| 366 | Lines: []string{"", "alpha\n", "beta\n"}, |
| 367 | |
| 368 | Expected: []Diff{ |
| 369 | {DiffEqual, "alpha\nbeta\nalpha\n"}, |
| 370 | {DiffInsert, "beta\nalpha\nbeta\n"}, |
| 371 | }, |
| 372 | }, |
| 373 | } { |
| 374 | actual := dmp.DiffCharsToLines(tc.Diffs, tc.Lines) |
| 375 | assert.Equal(t, tc.Expected, actual, fmt.Sprintf("Test case #%d, %#v", i, tc)) |
| 376 | } |
| 377 | |
| 378 | // More than 256 to reveal any 8-bit limitations. |
| 379 | n := 300 |
| 380 | lineList := []string{ |
| 381 | "", // Account for the initial empty element of the lines array. |
| 382 | } |
| 383 | charList := []index{} |
| 384 | for x := 1; x <= n; x++ { |
| 385 | lineList = append(lineList, strconv.Itoa(x)+"\n") |
| 386 | charList = append(charList, index(x)) |
| 387 | } |
| 388 | assert.Equal(t, n, len(charList)) |
| 389 | chars := indexesToString(charList) |
| 390 | |
| 391 | actual := dmp.DiffCharsToLines([]Diff{Diff{DiffDelete, chars}}, lineList) |
| 392 | assert.Equal(t, []Diff{Diff{DiffDelete, strings.Join(lineList, "")}}, actual) |
| 393 | } |
| 394 | |
| 395 | func TestDiffCleanupMerge(t *testing.T) { |
| 396 | type TestCase struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…