MCPcopy Create free account
hub / github.com/sergi/go-diff / TestDiffMainWithCheckLines

Function TestDiffMainWithCheckLines

diffmatchpatch/diff_test.go:1462–1495  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1460}
1461
1462func TestDiffMainWithCheckLines(t *testing.T) {
1463 type TestCase struct {
1464 Text1 string
1465 Text2 string
1466 }
1467
1468 dmp := New()
1469 dmp.DiffTimeout = 0
1470
1471 // Test cases must be at least 100 chars long to pass the cutoff.
1472 for i, tc := range []TestCase{
1473 {
1474 "1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n",
1475 "abcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\n",
1476 },
1477 {
1478 "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
1479 "abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij",
1480 },
1481 {
1482 "1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n",
1483 "abcdefghij\n1234567890\n1234567890\n1234567890\nabcdefghij\n1234567890\n1234567890\n1234567890\nabcdefghij\n1234567890\n1234567890\n1234567890\nabcdefghij\n",
1484 },
1485 } {
1486 resultWithoutCheckLines := dmp.DiffMain(tc.Text1, tc.Text2, false)
1487 resultWithCheckLines := dmp.DiffMain(tc.Text1, tc.Text2, true)
1488
1489 // TODO this fails for the third test case, why?
1490 if i != 2 {
1491 assert.Equal(t, resultWithoutCheckLines, resultWithCheckLines, fmt.Sprintf("Test case #%d, %#v", i, tc))
1492 }
1493 assert.Equal(t, diffRebuildTexts(resultWithoutCheckLines), diffRebuildTexts(resultWithCheckLines), fmt.Sprintf("Test case #%d, %#v", i, tc))
1494 }
1495}
1496
1497func TestMassiveRuneDiffConversion(t *testing.T) {
1498 sNew, err := ioutil.ReadFile("../testdata/fixture.go")

Callers

nothing calls this directly

Calls 3

NewFunction · 0.85
diffRebuildTextsFunction · 0.85
DiffMainMethod · 0.80

Tested by

no test coverage detected