MCPcopy Index your code
hub / github.com/expr-lang/expr / TestGetOptCodes

Function TestGetOptCodes

internal/difflib/difflib_test.go:40–59  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

38}
39
40func TestGetOptCodes(t *testing.T) {
41 a := "qabxcd"
42 b := "abycdf"
43 s := NewMatcher(splitChars(a), splitChars(b))
44 w := &bytes.Buffer{}
45 for _, op := range s.GetOpCodes() {
46 fmt.Fprintf(w, "%s a[%d:%d], (%s) b[%d:%d] (%s)\n", string(op.Tag),
47 op.I1, op.I2, a[op.I1:op.I2], op.J1, op.J2, b[op.J1:op.J2])
48 }
49 result := string(w.Bytes())
50 expected := `d a[0:1], (q) b[0:0] ()
51e a[1:3], (ab) b[0:2] (ab)
52r a[3:4], (x) b[2:3] (y)
53e a[4:6], (cd) b[3:5] (cd)
54i a[6:6], () b[5:6] (f)
55`
56 if expected != result {
57 t.Errorf("unexpected op codes: \n%s", result)
58 }
59}
60
61func TestGroupedOpCodes(t *testing.T) {
62 a := []string{}

Callers

nothing calls this directly

Calls 5

NewMatcherFunction · 0.85
splitCharsFunction · 0.85
GetOpCodesMethod · 0.80
FprintfMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…