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

Function TestDiffCommonPrefix

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

Source from the content-addressed store, hash-verified

61}
62
63func TestDiffCommonPrefix(t *testing.T) {
64 type TestCase struct {
65 Name string
66
67 Text1 string
68 Text2 string
69
70 Expected int
71 }
72
73 dmp := New()
74
75 for i, tc := range []TestCase{
76 {"Null", "abc", "xyz", 0},
77 {"Non-null", "1234abcdef", "1234xyz", 4},
78 {"Whole", "1234", "1234xyz", 4},
79 } {
80 actual := dmp.DiffCommonPrefix(tc.Text1, tc.Text2)
81 assert.Equal(t, tc.Expected, actual, fmt.Sprintf("Test case #%d, %s", i, tc.Name))
82 }
83}
84
85func BenchmarkDiffCommonPrefix(b *testing.B) {
86 s := "ABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ"

Callers

nothing calls this directly

Calls 2

NewFunction · 0.85
DiffCommonPrefixMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…