Exemplo n.º 1
0
func check(t *testing.T, v interface{}, expected, description string) {
	buf := &bytes.Buffer{}
	dumper.Dump(buf, v)

	gotten := addrRe.ReplaceAllString(buf.String(), "&(0xADDR)")

	if gotten != expected {
		t.Errorf("%s: expected \"%s\", gotten \"%s\"", description, expected, gotten)
	}
}
Exemplo n.º 2
0
func checkBeautify(t *testing.T, v interface{}, expected *dumper.BeautifyNode, description string) {
	buf := &bytes.Buffer{}

	dumper.Dump(buf, v)

	gotten, err := dumper.GetBeautifyTree(buf.Bytes())
	if err != nil {
		t.Errorf("%s: parse error: \"%s\"", description, err.Error())
		return
	}

	fixPtrs(gotten)

	if !reflect.DeepEqual(expected, gotten) {
		t.Errorf("%s: expected \n%s\ngotten \n%s\n", description, expected, gotten)
	}
}