MCPcopy Create free account
hub / github.com/cogentcore/core / TestGetOptCodes

Function TestGetOptCodes

texteditor/difflib/difflib_test.go:50–69  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

48}
49
50func TestGetOptCodes(t *testing.T) {
51 a := "qabxcd"
52 b := "abycdf"
53 s := NewMatcher(splitChars(a), splitChars(b))
54 w := &bytes.Buffer{}
55 for _, op := range s.GetOpCodes() {
56 fmt.Fprintf(w, "%s a[%d:%d], (%s) b[%d:%d] (%s)\n", string(op.Tag),
57 op.I1, op.I2, a[op.I1:op.I2], op.J1, op.J2, b[op.J1:op.J2])
58 }
59 result := w.String()
60 expected := `d a[0:1], (q) b[0:0] ()
61e a[1:3], (ab) b[0:2] (ab)
62r a[3:4], (x) b[2:3] (y)
63e a[4:6], (cd) b[3:5] (cd)
64i a[6:6], () b[5:6] (f)
65`
66 if expected != result {
67 t.Errorf("unexpected op codes: \n%s", result)
68 }
69}
70
71func TestGroupedOpCodes(t *testing.T) {
72 a := []string{}

Callers

nothing calls this directly

Calls 5

StringMethod · 0.95
NewMatcherFunction · 0.70
splitCharsFunction · 0.70
ErrorfMethod · 0.65
GetOpCodesMethod · 0.45

Tested by

no test coverage detected