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

Function TestGroupedOpCodes

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

StringMethod · 0.95
NewMatcherFunction · 0.70
ErrorfMethod · 0.65
GetGroupedOpCodesMethod · 0.45

Tested by

no test coverage detected