(t *testing.T)
| 59 | } |
| 60 | |
| 61 | func TestGroupedOpCodes(t *testing.T) { |
| 62 | a := []string{} |
| 63 | for i := 0; i != 39; i++ { |
| 64 | a = append(a, fmt.Sprintf("%02d", i)) |
| 65 | } |
| 66 | b := []string{} |
| 67 | b = append(b, a[:8]...) |
| 68 | b = append(b, " i") |
| 69 | b = append(b, a[8:19]...) |
| 70 | b = append(b, " x") |
| 71 | b = append(b, a[20:22]...) |
| 72 | b = append(b, a[27:34]...) |
| 73 | b = append(b, " y") |
| 74 | b = append(b, a[35:]...) |
| 75 | s := NewMatcher(a, b) |
| 76 | w := &bytes.Buffer{} |
| 77 | for _, g := range s.GetGroupedOpCodes(-1) { |
| 78 | fmt.Fprintf(w, "group\n") |
| 79 | for _, op := range g { |
| 80 | fmt.Fprintf(w, " %s, %d, %d, %d, %d\n", string(op.Tag), |
| 81 | op.I1, op.I2, op.J1, op.J2) |
| 82 | } |
| 83 | } |
| 84 | result := string(w.Bytes()) |
| 85 | expected := `group |
| 86 | e, 5, 8, 5, 8 |
| 87 | i, 8, 8, 8, 9 |
| 88 | e, 8, 11, 9, 12 |
| 89 | group |
| 90 | e, 16, 19, 17, 20 |
| 91 | r, 19, 20, 20, 21 |
| 92 | e, 20, 22, 21, 23 |
| 93 | d, 22, 27, 23, 23 |
| 94 | e, 27, 30, 23, 26 |
| 95 | group |
| 96 | e, 31, 34, 27, 30 |
| 97 | r, 34, 35, 30, 31 |
| 98 | e, 35, 38, 31, 34 |
| 99 | ` |
| 100 | if expected != result { |
| 101 | t.Errorf("unexpected op codes: \n%s", result) |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | func ExampleGetUnifiedDiffString() { |
| 106 | a := `one |
nothing calls this directly
no test coverage detected
searching dependent graphs…