MCPcopy
hub / github.com/google/go-cmp / validateScript

Function validateScript

cmp/internal/diff/diff_test.go:356–379  ·  view source on GitHub ↗
(x, y string, es EditScript)

Source from the content-addressed store, hash-verified

354}
355
356func 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.

Callers 1

testStringsFunction · 0.85

Calls 3

compareByteFunction · 0.85
SimilarMethod · 0.80
EqualMethod · 0.65

Tested by

no test coverage detected