(n int, px, py, pm float32, seed int64)
| 308 | } |
| 309 | |
| 310 | func generateStrings(n int, px, py, pm float32, seed int64) (string, string) { |
| 311 | if px+py+pm > 1.0 { |
| 312 | panic("invalid probabilities") |
| 313 | } |
| 314 | py += px |
| 315 | pm += py |
| 316 | |
| 317 | b := make([]byte, n) |
| 318 | r := rand.New(rand.NewSource(seed)) |
| 319 | r.Read(b) |
| 320 | |
| 321 | var x, y []byte |
| 322 | for len(b) > 0 { |
| 323 | switch p := r.Float32(); { |
| 324 | case p < px: // UniqueX |
| 325 | x = append(x, b[0]) |
| 326 | case p < py: // UniqueY |
| 327 | y = append(y, b[0]) |
| 328 | case p < pm: // Modified |
| 329 | x = append(x, 'A'+(b[0]%26)) |
| 330 | y = append(y, 'a'+(b[0]%26)) |
| 331 | default: // Identity |
| 332 | x = append(x, b[0]) |
| 333 | y = append(y, b[0]) |
| 334 | } |
| 335 | b = b[1:] |
| 336 | } |
| 337 | return string(x), string(y) |
| 338 | } |
| 339 | |
| 340 | func testStrings(t *testing.T, x, y string) EditScript { |
| 341 | es := Difference(len(x), len(y), func(ix, iy int) Result { |
no outgoing calls
no test coverage detected