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

Function TestGroupedOpCodes

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

Source from the content-addressed store, hash-verified

71}
72
73func TestGroupedOpCodes(t *testing.T) {
74 a := []string{}
75 for i := 0; i != 39; i++ {
76 a = append(a, fmt.Sprintf("%02d", i))
77 }
78 b := []string{}
79 b = append(b, a[:8]...)
80 b = append(b, " i")
81 b = append(b, a[8:19]...)
82 b = append(b, " x")
83 b = append(b, a[20:22]...)
84 b = append(b, a[27:34]...)
85 b = append(b, " y")
86 b = append(b, a[35:]...)
87 s := NewMatcher(a, b)
88 w := &bytes.Buffer{}
89 for _, g := range s.GetGroupedOpCodes(-1) {
90 fmt.Fprintf(w, "group\n")
91 for _, op := range g {
92 fmt.Fprintf(w, " %s, %d, %d, %d, %d\n", string(op.Tag),
93 op.I1, op.I2, op.J1, op.J2)
94 }
95 }
96 result := w.String()
97 expected := `group
98 e, 5, 8, 5, 8
99 i, 8, 8, 8, 9
100 e, 8, 11, 9, 12
101group
102 e, 16, 19, 17, 20
103 r, 19, 20, 20, 21
104 e, 20, 22, 21, 23
105 d, 22, 27, 23, 23
106 e, 27, 30, 23, 26
107group
108 e, 31, 34, 27, 30
109 r, 34, 35, 30, 31
110 e, 35, 38, 31, 34
111`
112 if expected != result {
113 t.Errorf("unexpected op codes: \n%s", result)
114 }
115}
116
117func ExampleGetUnifiedDiffString() {
118 a := `one

Callers

nothing calls this directly

Calls 3

NewMatcherFunction · 0.85
GetGroupedOpCodesMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected