package xmmsclient

import (
	"bytes"
	"encoding/hex"
	"reflect"
	"testing"
)

func checkBuffer(t *testing.T, expected []byte, actual []byte) {
	if !reflect.DeepEqual(expected, actual) {
		t.Fatalf("\nwant:\n%s\nhave:\n%s", hex.Dump(expected), hex.Dump(actual))
	}
}

func TestSerializeInt(t *testing.T) {
	var expected = []byte{
		0x00, 0x00, 0x00, 0x02,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a,
	}
	var buffer bytes.Buffer

	var err = SerializeXmmsValue(XmmsInt(42), &buffer)
	if err != nil {
		t.Fatal(err)
	}

	checkBuffer(t, expected, buffer.Bytes())
}

package xmmsclient

import (
	"bytes"
	"reflect"
	"testing"
)

func TestSerializeInt(t *testing.T) {
	var expected = []byte{
		0x00, 0x00, 0x00, 0x02,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a,
	}
	var buffer bytes.Buffer

	var err = SerializeXmmsValue(XmmsInt(42), &buffer)
	if err != nil {
		t.Error(err)
	}

	if !reflect.DeepEqual(expected, buffer.Bytes()) {
		t.Errorf("\n\twant %+v\n\thave %+v", expected, buffer.Bytes())
	}
}

--- 
+++ 
@@ -2,9 +2,16 @@
 
 import (
 	"bytes"
+	"encoding/hex"
 	"reflect"
 	"testing"
 )
+
+func checkBuffer(t *testing.T, expected []byte, actual []byte) {
+	if !reflect.DeepEqual(expected, actual) {
+		t.Fatalf("\nwant:\n%s\nhave:\n%s", hex.Dump(expected), hex.Dump(actual))
+	}
+}
 
 func TestSerializeInt(t *testing.T) {
 	var expected = []byte{
@@ -15,10 +22,8 @@
 
 	var err = SerializeXmmsValue(XmmsInt(42), &buffer)
 	if err != nil {
-		t.Error(err)
+		t.Fatal(err)
 	}
 
-	if !reflect.DeepEqual(expected, buffer.Bytes()) {
-		t.Errorf("\n\twant %+v\n\thave %+v", expected, buffer.Bytes())
-	}
+	checkBuffer(t, expected, buffer.Bytes())
 }
Break out buffer-check and use t.Fatal.
