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

Function TestDiffMainWithCheckLines

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

Source from the content-addressed store, hash-verified

1432}
1433
1434func TestDiffMainWithCheckLines(t *testing.T) {
1435 type TestCase struct {
1436 Text1 string
1437 Text2 string
1438 }
1439
1440 dmp := New()
1441 dmp.DiffTimeout = 0
1442
1443 // Test cases must be at least 100 chars long to pass the cutoff.
1444 for i, tc := range []TestCase{
1445 {
1446 "1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n",
1447 "abcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\nabcdefghij\n",
1448 },
1449 {
1450 "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
1451 "abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij",
1452 },
1453 {
1454 "1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n",
1455 "abcdefghij\n1234567890\n1234567890\n1234567890\nabcdefghij\n1234567890\n1234567890\n1234567890\nabcdefghij\n1234567890\n1234567890\n1234567890\nabcdefghij\n",
1456 },
1457 } {
1458 resultWithoutCheckLines := dmp.DiffMain(tc.Text1, tc.Text2, false)
1459 resultWithCheckLines := dmp.DiffMain(tc.Text1, tc.Text2, true)
1460
1461 // TODO this fails for the third test case, why?
1462 if i != 2 {
1463 assert.Equal(t, resultWithoutCheckLines, resultWithCheckLines, fmt.Sprintf("Test case #%d, %#v", i, tc))
1464 }
1465 assert.Equal(t, diffRebuildTexts(resultWithoutCheckLines), diffRebuildTexts(resultWithCheckLines), fmt.Sprintf("Test case #%d, %#v", i, tc))
1466 }
1467}
1468
1469func TestMassiveRuneDiffConversion(t *testing.T) {
1470 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…