Exemple #1
0
func compareXML(a, b interface{}) error {
	aXml, err := xml.MarshalIndent(a, "", "\t")
	if err != nil {
		return err
	}

	bXml, err := xml.MarshalIndent(b, "", "\t")
	if err != nil {
		return err
	}

	if d := diff.Diff(string(aXml), string(bXml)); d != "" {
		err := fmt.Errorf("Unexpected XML:\n%s", d)
		return err
	}

	return nil
}
Exemple #2
0
// Compare returns a string containing a line-by-line unified diff of the
// values in got and want according to the cfg.
func (cfg *Config) Compare(got, want interface{}) string {
	diffCfg := *cfg
	diffCfg.Diffable = true
	return diff.Diff(cfg.Sprint(got), cfg.Sprint(want))
}