func DiffValuesDefault(a, b interface{}) string { diff := diffmatchpatch.New() at := repr.String(a) bt := repr.String(b) diffs := diff.DiffMain(at, bt, true) w := bytes.NewBuffer(nil) for _, d := range diffs { switch d.Type { case diffmatchpatch.DiffEqual: if len(d.Text) <= 40 { w.WriteString(d.Text) } else { fmt.Fprintf(w, "%s...%s", d.Text[:15], d.Text[len(d.Text)-15:]) } case diffmatchpatch.DiffDelete: fmt.Fprintf(w, "-{{%s}}", d.Text) case diffmatchpatch.DiffInsert: fmt.Fprintf(w, "+{{%s}}", d.Text) } } return w.String() }
func DiffValues(a, b interface{}) string { printer := colour.String() diff := diffmatchpatch.New() at := repr.String(a, repr.OmitEmpty()) bt := repr.String(b, repr.OmitEmpty()) diffs := diff.DiffMain(at, bt, true) for _, d := range diffs { switch d.Type { case diffmatchpatch.DiffEqual: if len(d.Text) <= 40 { printer.Print(d.Text) } else { printer.Printf("%s^B...^R%s", d.Text[:15], d.Text[len(d.Text)-15:]) } case diffmatchpatch.DiffDelete: printer.Printf("^9%s^R", d.Text) case diffmatchpatch.DiffInsert: printer.Printf("^a%s^R", d.Text) } } return printer.String() }
// NotEqual asserts that the specified values are NOT equal. // // assert.NotEqual(t, obj1, obj2, "two objects shouldn't be equal") // // Returns whether the assertion was successful (true) or not (false). func NotEqual(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) { if ObjectsAreEqual(expected, actual) { Fail(t, fmt.Sprintf("Should not be: %s\n", repr.String(actual, repr.OmitEmpty())), msgAndArgs...) } }
// Nil asserts that the specified object is nil. // // assert.Nil(t, err, "err should be nothing") // // Returns whether the assertion was successful (true) or not (false). func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) { if isNil(object) { return } Fail(t, fmt.Sprintf("Expected nil, but got: %s", repr.String(object, repr.OmitEmpty())), msgAndArgs...) }