From: Matt Joiner Date: Tue, 23 Feb 2016 10:47:00 +0000 (+1100) Subject: bencode: Update some test code X-Git-Tag: v1.0.0~854 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=c0cef5274ba8562c783666565eacb4be9efd88b0;p=btrtrc.git bencode: Update some test code --- diff --git a/bencode/both_test.go b/bencode/both_test.go index d837b619..b0bb074d 100644 --- a/bencode/both_test.go +++ b/bencode/both_test.go @@ -1,35 +1,31 @@ package bencode -import "testing" -import "bytes" -import "io/ioutil" +import ( + "bytes" + "io/ioutil" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) func loadFile(name string, t *testing.T) []byte { data, err := ioutil.ReadFile(name) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) return data } func testFileInterface(t *testing.T, filename string) { data1 := loadFile(filename, t) - var iface interface{} + var iface interface{} err := Unmarshal(data1, &iface) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) data2, err := Marshal(iface) - if err != nil { - t.Fatal(err) - } - - if !bytes.Equal(data1, data2) { - t.Fatalf("equality expected\n") - } + require.NoError(t, err) + assert.EqualValues(t, data1, data2) } func TestBothInterface(t *testing.T) {