(x, y string, es EditScript)
| 354 | } |
| 355 | |
| 356 | func validateScript(x, y string, es EditScript) bool { |
| 357 | var bx, by []byte |
| 358 | for _, e := range es { |
| 359 | switch e { |
| 360 | case Identity: |
| 361 | if !compareByte(x[len(bx)], y[len(by)]).Equal() { |
| 362 | return false |
| 363 | } |
| 364 | bx = append(bx, x[len(bx)]) |
| 365 | by = append(by, y[len(by)]) |
| 366 | case UniqueX: |
| 367 | bx = append(bx, x[len(bx)]) |
| 368 | case UniqueY: |
| 369 | by = append(by, y[len(by)]) |
| 370 | case Modified: |
| 371 | if !compareByte(x[len(bx)], y[len(by)]).Similar() { |
| 372 | return false |
| 373 | } |
| 374 | bx = append(bx, x[len(bx)]) |
| 375 | by = append(by, y[len(by)]) |
| 376 | } |
| 377 | } |
| 378 | return string(bx) == x && string(by) == y |
| 379 | } |
| 380 | |
| 381 | // compareByte returns a Result where the result is Equal if x == y, |
| 382 | // similar if x and y differ only in casing, and different otherwise. |
no test coverage detected