(b *testing.B)
| 147 | } |
| 148 | |
| 149 | func BenchmarkCommonLength(b *testing.B) { |
| 150 | data := []struct { |
| 151 | name string |
| 152 | x, y []rune |
| 153 | }{ |
| 154 | {name: "empty", x: nil, y: []rune{}}, |
| 155 | {name: "short", x: []rune("AABCC"), y: []rune("AA-CC")}, |
| 156 | {name: "long", |
| 157 | x: []rune(strings.Repeat("A", 1000) + "B" + strings.Repeat("C", 1000)), |
| 158 | y: []rune(strings.Repeat("A", 1000) + "-" + strings.Repeat("C", 1000)), |
| 159 | }, |
| 160 | } |
| 161 | b.Run("prefix", func(b *testing.B) { |
| 162 | for _, d := range data { |
| 163 | b.Run(d.name, func(b *testing.B) { |
| 164 | for i := 0; i < b.N; i++ { |
| 165 | SinkInt = commonPrefixLength(d.x, d.y) |
| 166 | } |
| 167 | }) |
| 168 | } |
| 169 | }) |
| 170 | b.Run("suffix", func(b *testing.B) { |
| 171 | for _, d := range data { |
| 172 | b.Run(d.name, func(b *testing.B) { |
| 173 | for i := 0; i < b.N; i++ { |
| 174 | SinkInt = commonSuffixLength(d.x, d.y) |
| 175 | } |
| 176 | }) |
| 177 | } |
| 178 | }) |
| 179 | } |
| 180 | |
| 181 | func TestCommonSuffixLength(t *testing.T) { |
| 182 | type TestCase struct { |
nothing calls this directly
no test coverage detected