Add go fuzzer in preparation for testing. Also gofmt a few files that needed it.

This commit is contained in:
Daniel Smith
2014-07-25 17:58:36 -07:00
parent 8a5cc87df8
commit aa92dd7fb2
6 changed files with 524 additions and 4 deletions

View File

@@ -132,3 +132,23 @@ func (intstr IntOrString) MarshalJSON() ([]byte, error) {
return []byte{}, fmt.Errorf("impossible IntOrString.Kind")
}
}
// StringDiff diffs a and b and returns a human readable diff.
func StringDiff(a, b string) string {
ba := []byte(a)
bb := []byte(b)
out := []byte{}
i := 0
for ; i < len(ba) && i < len(bb); i++ {
if ba[i] != bb[i] {
break
}
out = append(out, ba[i])
}
out = append(out, []byte("\n\nA: ")...)
out = append(out, ba[i:]...)
out = append(out, []byte("\n\nB: ")...)
out = append(out, bb[i:]...)
out = append(out, []byte("\n\n")...)
return string(out)
}