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

Function TestGetOptCodes

texteditor/difflib/bytes/bytes_test.go:67–86  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

65}
66
67func TestGetOptCodes(t *testing.T) {
68 a := "qabxcd"
69 b := "abycdf"
70 s := NewMatcher(splitChars(a), splitChars(b))
71 w := &bytes.Buffer{}
72 for _, op := range s.GetOpCodes() {
73 fmt.Fprintf(w, "%s a[%d:%d], (%s) b[%d:%d] (%s)\n", string(op.Tag),
74 op.I1, op.I2, a[op.I1:op.I2], op.J1, op.J2, b[op.J1:op.J2])
75 }
76 result := w.String()
77 expected := `d a[0:1], (q) b[0:0] ()
78e a[1:3], (ab) b[0:2] (ab)
79r a[3:4], (x) b[2:3] (y)
80e a[4:6], (cd) b[3:5] (cd)
81i a[6:6], () b[5:6] (f)
82`
83 if expected != result {
84 t.Errorf("unexpected op codes: \n%s", result)
85 }
86}
87
88func TestGroupedOpCodes(t *testing.T) {
89 a := [][]byte{}

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