MCPcopy
hub / github.com/prometheus/client_golang / TestGetOptCodes

Function TestGetOptCodes

prometheus/internal/difflib_test.go:52–71  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

NewMatcherFunction · 0.85
splitCharsFunction · 0.85
GetOpCodesMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected