From 6a685514dcef5639d0cf495cd15febca0eed7a6b Mon Sep 17 00:00:00 2001 From: xibz Date: Mon, 9 Oct 2017 12:28:32 -0700 Subject: [PATCH] Removing test dependencies (#1577) --- aws/awsutil/copy_test.go | 178 ++++++++++++++++++++------- aws/awsutil/equal_test.go | 5 +- aws/awsutil/path_value_test.go | 82 ++++++++---- aws/signer/v4/functional_1_5_test.go | 41 ++++-- aws/signer/v4/header_rules_test.go | 46 +++++-- aws/types_test.go | 39 ++++-- 6 files changed, 288 insertions(+), 103 deletions(-) diff --git a/aws/awsutil/copy_test.go b/aws/awsutil/copy_test.go index 0e75c5eea1..007b37be19 100644 --- a/aws/awsutil/copy_test.go +++ b/aws/awsutil/copy_test.go @@ -5,11 +5,11 @@ import ( "fmt" "io" "io/ioutil" + "reflect" "testing" "time" "github.com/aws/aws-sdk-go/aws/awsutil" - "github.com/stretchr/testify/assert" ) func ExampleCopy() { @@ -81,12 +81,24 @@ func TestCopy1(t *testing.T) { awsutil.Copy(&f2, f1) // Values are equal - assert.Equal(t, f2.A, f1.A) - assert.Equal(t, f2.B, f1.B) - assert.Equal(t, f2.C, f1.C) - assert.Equal(t, f2.D, f1.D) - assert.Equal(t, f2.E.B, f1.E.B) - assert.Equal(t, f2.E.D, f1.E.D) + if v1, v2 := f2.A, f1.A; v1 != v2 { + t.Errorf("expected values to be equivalent but received %v and %v", v1, v2) + } + if v1, v2 := f2.B, f1.B; !reflect.DeepEqual(v1, v2) { + t.Errorf("expected values to be equivalent but received %v and %v", v1, v2) + } + if v1, v2 := f2.C, f1.C; !reflect.DeepEqual(v1, v2) { + t.Errorf("expected values to be equivalent but received %v and %v", v1, v2) + } + if v1, v2 := f2.D, f1.D; !v1.Equal(*v2) { + t.Errorf("expected values to be equivalent but received %v and %v", v1, v2) + } + if v1, v2 := f2.E.B, f1.E.B; !reflect.DeepEqual(v1, v2) { + t.Errorf("expected values to be equivalent but received %v and %v", v1, v2) + } + if v1, v2 := f2.E.D, f1.E.D; v1 != v2 { + t.Errorf("expected values to be equivalent but received %v and %v", v1, v2) + } // But pointers are not! str3 := "nothello" @@ -99,14 +111,30 @@ func TestCopy1(t *testing.T) { *f2.E.B = int3 f2.E.c = 5 f2.E.D = 5 - assert.NotEqual(t, f2.A, f1.A) - assert.NotEqual(t, f2.B, f1.B) - assert.NotEqual(t, f2.C, f1.C) - assert.NotEqual(t, f2.D, f1.D) - assert.NotEqual(t, f2.E.a, f1.E.a) - assert.NotEqual(t, f2.E.B, f1.E.B) - assert.NotEqual(t, f2.E.c, f1.E.c) - assert.NotEqual(t, f2.E.D, f1.E.D) + if v1, v2 := f2.A, f1.A; v1 == v2 { + t.Errorf("expected values to be not equivalent, but received %v", v1) + } + if v1, v2 := f2.B, f1.B; reflect.DeepEqual(v1, v2) { + t.Errorf("expected values to be not equivalent, but received %v", v1) + } + if v1, v2 := f2.C, f1.C; reflect.DeepEqual(v1, v2) { + t.Errorf("expected values to be not equivalent, but received %v", v1) + } + if v1, v2 := f2.D, f1.D; v1 == v2 { + t.Errorf("expected values to be not equivalent, but received %v", v1) + } + if v1, v2 := f2.E.a, f1.E.a; v1 == v2 { + t.Errorf("expected values to be not equivalent, but received %v", v1) + } + if v1, v2 := f2.E.B, f1.E.B; v1 == v2 { + t.Errorf("expected values to be not equivalent, but received %v", v1) + } + if v1, v2 := f2.E.c, f1.E.c; v1 == v2 { + t.Errorf("expected values to be not equivalent, but received %v", v1) + } + if v1, v2 := f2.E.D, f1.E.D; v1 == v2 { + t.Errorf("expected values to be not equivalent, but received %v", v1) + } } func TestCopyNestedWithUnexported(t *testing.T) { @@ -125,10 +153,18 @@ func TestCopyNestedWithUnexported(t *testing.T) { awsutil.Copy(&f2, f1) // Values match - assert.Equal(t, f2.A, f1.A) - assert.NotEqual(t, f2.B, f1.B) - assert.NotEqual(t, f2.B.a, f1.B.a) - assert.Equal(t, f2.B.B, f2.B.B) + if v1, v2 := f2.A, f1.A; v1 != v2 { + t.Errorf("expected values to be equivalent but received %v and %v", v1, v2) + } + if v1, v2 := f2.B, f1.B; v1 == v2 { + t.Errorf("expected values to be not equivalent, but received %v", v1) + } + if v1, v2 := f2.B.a, f1.B.a; v1 == v2 { + t.Errorf("expected values to be not equivalent, but received %v", v1) + } + if v1, v2 := f2.B.B, f2.B.B; v1 != v2 { + t.Errorf("expected values to be equivalent but received %v and %v", v1, v2) + } } func TestCopyIgnoreNilMembers(t *testing.T) { @@ -139,34 +175,56 @@ func TestCopyIgnoreNilMembers(t *testing.T) { } f := &Foo{} - assert.Nil(t, f.A) - assert.Nil(t, f.B) - assert.Nil(t, f.C) + if v1 := f.A; v1 != nil { + t.Errorf("expected nil, but received %v", v1) + } + if v1 := f.B; v1 != nil { + t.Errorf("expected nil, but received %v", v1) + } + if v1 := f.C; v1 != nil { + t.Errorf("expected nil, but received %v", v1) + } var f2 Foo awsutil.Copy(&f2, f) - assert.Nil(t, f2.A) - assert.Nil(t, f2.B) - assert.Nil(t, f2.C) + if v1 := f2.A; v1 != nil { + t.Errorf("expected nil, but received %v", v1) + } + if v1 := f2.B; v1 != nil { + t.Errorf("expected nil, but received %v", v1) + } + if v1 := f2.C; v1 != nil { + t.Errorf("expected nil, but received %v", v1) + } fcopy := awsutil.CopyOf(f) f3 := fcopy.(*Foo) - assert.Nil(t, f3.A) - assert.Nil(t, f3.B) - assert.Nil(t, f3.C) + if v1 := f3.A; v1 != nil { + t.Errorf("expected nil, but received %v", v1) + } + if v1 := f3.B; v1 != nil { + t.Errorf("expected nil, but received %v", v1) + } + if v1 := f3.C; v1 != nil { + t.Errorf("expected nil, but received %v", v1) + } } func TestCopyPrimitive(t *testing.T) { str := "hello" var s string awsutil.Copy(&s, &str) - assert.Equal(t, "hello", s) + if v1, v2 := "hello", s; v1 != v2 { + t.Errorf("expected values to be equivalent but received %v and %v", v1, v2) + } } func TestCopyNil(t *testing.T) { var s string awsutil.Copy(&s, nil) - assert.Equal(t, "", s) + if v1, v2 := "", s; v1 != v2 { + t.Errorf("expected values to be equivalent but received %v and %v", v1, v2) + } } func TestCopyReader(t *testing.T) { @@ -174,13 +232,21 @@ func TestCopyReader(t *testing.T) { var r io.Reader awsutil.Copy(&r, buf) b, err := ioutil.ReadAll(r) - assert.NoError(t, err) - assert.Equal(t, []byte("hello world"), b) + if err != nil { + t.Errorf("expected no error, but received %v", err) + } + if v1, v2 := []byte("hello world"), b; !bytes.Equal(v1, v2) { + t.Errorf("expected values to be equivalent but received %v and %v", v1, v2) + } // empty bytes because this is not a deep copy b, err = ioutil.ReadAll(buf) - assert.NoError(t, err) - assert.Equal(t, []byte(""), b) + if err != nil { + t.Errorf("expected no error, but received %v", err) + } + if v1, v2 := []byte(""), b; !bytes.Equal(v1, v2) { + t.Errorf("expected values to be equivalent but received %v and %v", v1, v2) + } } func TestCopyDifferentStructs(t *testing.T) { @@ -226,17 +292,39 @@ func TestCopyDifferentStructs(t *testing.T) { awsutil.Copy(&f2, f1) // Values are equal - assert.Equal(t, f2.A, f1.A) - assert.Equal(t, f2.B, f1.B) - assert.Equal(t, f2.C, f1.C) - assert.Equal(t, "unique", f1.SrcUnique) - assert.Equal(t, 1, f1.SameNameDiffType) - assert.Equal(t, 0, f2.DstUnique) - assert.Equal(t, "", f2.SameNameDiffType) - assert.Equal(t, int1, *f1.unexportedPtr) - assert.Nil(t, f2.unexportedPtr) - assert.Equal(t, int2, *f1.ExportedPtr) - assert.Equal(t, int2, *f2.ExportedPtr) + if v1, v2 := f2.A, f1.A; v1 != v2 { + t.Errorf("expected values to be equivalent but received %v and %v", v1, v2) + } + if v1, v2 := f2.B, f1.B; !reflect.DeepEqual(v1, v2) { + t.Errorf("expected values to be equivalent but received %v and %v", v1, v2) + } + if v1, v2 := f2.C, f1.C; !reflect.DeepEqual(v1, v2) { + t.Errorf("expected values to be equivalent but received %v and %v", v1, v2) + } + if v1, v2 := "unique", f1.SrcUnique; v1 != v2 { + t.Errorf("expected values to be equivalent but received %v and %v", v1, v2) + } + if v1, v2 := 1, f1.SameNameDiffType; v1 != v2 { + t.Errorf("expected values to be equivalent but received %v and %v", v1, v2) + } + if v1, v2 := 0, f2.DstUnique; v1 != v2 { + t.Errorf("expected values to be equivalent but received %v and %v", v1, v2) + } + if v1, v2 := "", f2.SameNameDiffType; v1 != v2 { + t.Errorf("expected values to be equivalent but received %v and %v", v1, v2) + } + if v1, v2 := int1, *f1.unexportedPtr; v1 != v2 { + t.Errorf("expected values to be equivalent but received %v and %v", v1, v2) + } + if v1 := f2.unexportedPtr; v1 != nil { + t.Errorf("expected nil, but received %v", v1) + } + if v1, v2 := int2, *f1.ExportedPtr; v1 != v2 { + t.Errorf("expected values to be equivalent but received %v and %v", v1, v2) + } + if v1, v2 := int2, *f2.ExportedPtr; v1 != v2 { + t.Errorf("expected values to be equivalent but received %v and %v", v1, v2) + } } func ExampleCopyOf() { diff --git a/aws/awsutil/equal_test.go b/aws/awsutil/equal_test.go index 7a5db6e49b..18d3c5b8ec 100644 --- a/aws/awsutil/equal_test.go +++ b/aws/awsutil/equal_test.go @@ -5,7 +5,6 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awsutil" - "github.com/stretchr/testify/assert" ) func TestDeepEqual(t *testing.T) { @@ -24,6 +23,8 @@ func TestDeepEqual(t *testing.T) { } for i, c := range cases { - assert.Equal(t, c.equal, awsutil.DeepEqual(c.a, c.b), "%d, a:%v b:%v, %t", i, c.a, c.b, c.equal) + if awsutil.DeepEqual(c.a, c.b) != c.equal { + t.Errorf("%d, a:%v b:%v, %t", i, c.a, c.b, c.equal) + } } } diff --git a/aws/awsutil/path_value_test.go b/aws/awsutil/path_value_test.go index b2225566fa..58a05d6cec 100644 --- a/aws/awsutil/path_value_test.go +++ b/aws/awsutil/path_value_test.go @@ -1,10 +1,10 @@ package awsutil_test import ( + "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" - "github.com/stretchr/testify/assert" ) type Struct struct { @@ -50,8 +50,12 @@ func TestValueAtPathSuccess(t *testing.T) { } for i, c := range testCases { v, err := awsutil.ValuesAtPath(c.data, c.path) - assert.NoError(t, err, "case %d, expected no error, %s", i, c.path) - assert.Equal(t, c.expect, v, "case %d, %s", i, c.path) + if err != nil { + t.Errorf("case %v, expected no error, %v", i, c.path) + } + if e, a := c.expect, v; !awsutil.DeepEqual(e, a) { + t.Errorf("case %v, %v", i, c.path) + } } } @@ -78,12 +82,18 @@ func TestValueAtPathFailure(t *testing.T) { for i, c := range testCases { v, err := awsutil.ValuesAtPath(c.data, c.path) if c.errContains != "" { - assert.Contains(t, err.Error(), c.errContains, "case %d, expected error, %s", i, c.path) + if !strings.Contains(err.Error(), c.errContains) { + t.Errorf("case %v, expected error, %v", i, c.path) + } continue } else { - assert.NoError(t, err, "case %d, expected no error, %s", i, c.path) + if err != nil { + t.Errorf("case %v, expected no error, %v", i, c.path) + } + } + if e, a := c.expect, v; !awsutil.DeepEqual(e, a) { + t.Errorf("case %v, %v", i, c.path) } - assert.Equal(t, c.expect, v, "case %d, %s", i, c.path) } } @@ -92,51 +102,81 @@ func TestSetValueAtPathSuccess(t *testing.T) { awsutil.SetValueAtPath(&s, "C", "test1") awsutil.SetValueAtPath(&s, "B.B.C", "test2") awsutil.SetValueAtPath(&s, "B.D.C", "test3") - assert.Equal(t, "test1", s.C) - assert.Equal(t, "test2", s.B.B.C) - assert.Equal(t, "test3", s.B.D.C) + if e, a := "test1", s.C; e != a { + t.Errorf("expected %v, but received %v", e, a) + } + if e, a := "test2", s.B.B.C; e != a { + t.Errorf("expected %v, but received %v", e, a) + } + if e, a := "test3", s.B.D.C; e != a { + t.Errorf("expected %v, but received %v", e, a) + } awsutil.SetValueAtPath(&s, "B.*.C", "test0") - assert.Equal(t, "test0", s.B.B.C) - assert.Equal(t, "test0", s.B.D.C) + if e, a := "test0", s.B.B.C; e != a { + t.Errorf("expected %v, but received %v", e, a) + } + if e, a := "test0", s.B.D.C; e != a { + t.Errorf("expected %v, but received %v", e, a) + } var s2 Struct awsutil.SetValueAtPath(&s2, "b.b.c", "test0") - assert.Equal(t, "test0", s2.B.B.C) + if e, a := "test0", s2.B.B.C; e != a { + t.Errorf("expected %v, but received %v", e, a) + } awsutil.SetValueAtPath(&s2, "A", []Struct{{}}) - assert.Equal(t, []Struct{{}}, s2.A) + if e, a := []Struct{{}}, s2.A; !awsutil.DeepEqual(e, a) { + t.Errorf("expected %v, but received %v", e, a) + } str := "foo" s3 := Struct{} awsutil.SetValueAtPath(&s3, "b.b.c", str) - assert.Equal(t, "foo", s3.B.B.C) + if e, a := "foo", s3.B.B.C; e != a { + t.Errorf("expected %v, but received %v", e, a) + } s3 = Struct{B: &Struct{B: &Struct{C: str}}} awsutil.SetValueAtPath(&s3, "b.b.c", nil) - assert.Equal(t, "", s3.B.B.C) + if e, a := "", s3.B.B.C; e != a { + t.Errorf("expected %v, but received %v", e, a) + } s3 = Struct{} awsutil.SetValueAtPath(&s3, "b.b.c", nil) - assert.Equal(t, "", s3.B.B.C) + if e, a := "", s3.B.B.C; e != a { + t.Errorf("expected %v, but received %v", e, a) + } s3 = Struct{} awsutil.SetValueAtPath(&s3, "b.b.c", &str) - assert.Equal(t, "foo", s3.B.B.C) + if e, a := "foo", s3.B.B.C; e != a { + t.Errorf("expected %v, but received %v", e, a) + } var s4 struct{ Name *string } awsutil.SetValueAtPath(&s4, "Name", str) - assert.Equal(t, str, *s4.Name) + if e, a := str, *s4.Name; e != a { + t.Errorf("expected %v, but received %v", e, a) + } s4 = struct{ Name *string }{} awsutil.SetValueAtPath(&s4, "Name", nil) - assert.Equal(t, (*string)(nil), s4.Name) + if e, a := (*string)(nil), s4.Name; e != a { + t.Errorf("expected %v, but received %v", e, a) + } s4 = struct{ Name *string }{Name: &str} awsutil.SetValueAtPath(&s4, "Name", nil) - assert.Equal(t, (*string)(nil), s4.Name) + if e, a := (*string)(nil), s4.Name; e != a { + t.Errorf("expected %v, but received %v", e, a) + } s4 = struct{ Name *string }{} awsutil.SetValueAtPath(&s4, "Name", &str) - assert.Equal(t, str, *s4.Name) + if e, a := str, *s4.Name; e != a { + t.Errorf("expected %v, but received %v", e, a) + } } diff --git a/aws/signer/v4/functional_1_5_test.go b/aws/signer/v4/functional_1_5_test.go index 2d4621c64f..2e591c27f5 100644 --- a/aws/signer/v4/functional_1_5_test.go +++ b/aws/signer/v4/functional_1_5_test.go @@ -10,7 +10,6 @@ import ( "github.com/aws/aws-sdk-go/aws/signer/v4" "github.com/aws/aws-sdk-go/awstesting/unit" - "github.com/stretchr/testify/assert" ) func TestStandaloneSign(t *testing.T) { @@ -22,7 +21,9 @@ func TestStandaloneSign(t *testing.T) { c.SubDomain, c.Region, c.Service) req, err := http.NewRequest("GET", host, nil) - assert.NoError(t, err) + if err != nil { + t.Errorf("expected no error, but received %v", err) + } // URL.EscapedPath() will be used by the signer to get the // escaped form of the request's URI path. @@ -30,12 +31,20 @@ func TestStandaloneSign(t *testing.T) { req.URL.RawQuery = c.OrigQuery _, err = signer.Sign(req, nil, c.Service, c.Region, time.Unix(0, 0)) - assert.NoError(t, err) + if err != nil { + t.Errorf("expected no error, but received %v", err) + } actual := req.Header.Get("Authorization") - assert.Equal(t, c.ExpSig, actual) - assert.Equal(t, c.OrigURI, req.URL.Path) - assert.Equal(t, c.EscapedURI, req.URL.EscapedPath()) + if e, a := c.ExpSig, actual; e != a { + t.Errorf("expected %v, but recieved %v", e, a) + } + if e, a := c.OrigURI, req.URL.Path; e != a { + t.Errorf("expected %v, but recieved %v", e, a) + } + if e, a := c.EscapedURI, req.URL.EscapedPath(); e != a { + t.Errorf("expected %v, but recieved %v", e, a) + } } } @@ -48,7 +57,9 @@ func TestStandaloneSign_RawPath(t *testing.T) { c.SubDomain, c.Region, c.Service) req, err := http.NewRequest("GET", host, nil) - assert.NoError(t, err) + if err != nil { + t.Errorf("expected no error, but received %v", err) + } // URL.EscapedPath() will be used by the signer to get the // escaped form of the request's URI path. @@ -57,11 +68,19 @@ func TestStandaloneSign_RawPath(t *testing.T) { req.URL.RawQuery = c.OrigQuery _, err = signer.Sign(req, nil, c.Service, c.Region, time.Unix(0, 0)) - assert.NoError(t, err) + if err != nil { + t.Errorf("expected no error, but received %v", err) + } actual := req.Header.Get("Authorization") - assert.Equal(t, c.ExpSig, actual) - assert.Equal(t, c.OrigURI, req.URL.Path) - assert.Equal(t, c.EscapedURI, req.URL.EscapedPath()) + if e, a := c.ExpSig, actual; e != a { + t.Errorf("expected %v, but recieved %v", e, a) + } + if e, a := c.OrigURI, req.URL.Path; e != a { + t.Errorf("expected %v, but recieved %v", e, a) + } + if e, a := c.EscapedURI, req.URL.EscapedPath(); e != a { + t.Errorf("expected %v, but recieved %v", e, a) + } } } diff --git a/aws/signer/v4/header_rules_test.go b/aws/signer/v4/header_rules_test.go index 7dfddc87e5..f4be951aca 100644 --- a/aws/signer/v4/header_rules_test.go +++ b/aws/signer/v4/header_rules_test.go @@ -2,8 +2,6 @@ package v4 import ( "testing" - - "github.com/stretchr/testify/assert" ) func TestRuleCheckWhitelist(t *testing.T) { @@ -13,8 +11,12 @@ func TestRuleCheckWhitelist(t *testing.T) { }, } - assert.True(t, w.IsValid("Cache-Control")) - assert.False(t, w.IsValid("Cache-")) + if !w.IsValid("Cache-Control") { + t.Error("expected true value") + } + if w.IsValid("Cache-") { + t.Error("expected false value") + } } func TestRuleCheckBlacklist(t *testing.T) { @@ -24,16 +26,26 @@ func TestRuleCheckBlacklist(t *testing.T) { }, } - assert.False(t, b.IsValid("Cache-Control")) - assert.True(t, b.IsValid("Cache-")) + if b.IsValid("Cache-Control") { + t.Error("expected false value") + } + if !b.IsValid("Cache-") { + t.Error("expected true value") + } } func TestRuleCheckPattern(t *testing.T) { p := patterns{"X-Amz-Meta-"} - assert.True(t, p.IsValid("X-Amz-Meta-")) - assert.True(t, p.IsValid("X-Amz-Meta-Star")) - assert.False(t, p.IsValid("Cache-")) + if !p.IsValid("X-Amz-Meta-") { + t.Error("expected true value") + } + if !p.IsValid("X-Amz-Meta-Star") { + t.Error("expected true value") + } + if p.IsValid("Cache-") { + t.Error("expected false value") + } } func TestRuleComplexWhitelist(t *testing.T) { @@ -50,8 +62,16 @@ func TestRuleComplexWhitelist(t *testing.T) { inclusiveRules{patterns{"X-Amz-"}, blacklist{w}}, } - assert.True(t, r.IsValid("X-Amz-Blah")) - assert.False(t, r.IsValid("X-Amz-Meta-")) - assert.False(t, r.IsValid("X-Amz-Meta-Star")) - assert.False(t, r.IsValid("Cache-Control")) + if !r.IsValid("X-Amz-Blah") { + t.Error("expected true value") + } + if r.IsValid("X-Amz-Meta-") { + t.Error("expected false value") + } + if r.IsValid("X-Amz-Meta-Star") { + t.Error("expected false value") + } + if r.IsValid("Cache-Control") { + t.Error("expected false value") + } } diff --git a/aws/types_test.go b/aws/types_test.go index a7cd93b83c..e399ef5737 100644 --- a/aws/types_test.go +++ b/aws/types_test.go @@ -1,32 +1,49 @@ package aws import ( + "bytes" "math/rand" "testing" - - "github.com/stretchr/testify/assert" ) func TestWriteAtBuffer(t *testing.T) { b := &WriteAtBuffer{} n, err := b.WriteAt([]byte{1}, 0) - assert.NoError(t, err) - assert.Equal(t, 1, n) + if err != nil { + t.Errorf("expected no error, but received %v", err) + } + if e, a := 1, n; e != a { + t.Errorf("expected %d, but recieved %d", e, a) + } n, err = b.WriteAt([]byte{1, 1, 1}, 5) - assert.NoError(t, err) - assert.Equal(t, 3, n) + if err != nil { + t.Errorf("expected no error, but received %v", err) + } + if e, a := 3, n; e != a { + t.Errorf("expected %d, but recieved %d", e, a) + } n, err = b.WriteAt([]byte{2}, 1) - assert.NoError(t, err) - assert.Equal(t, 1, n) + if err != nil { + t.Errorf("expected no error, but received %v", err) + } + if e, a := 1, n; e != a { + t.Errorf("expected %d, but recieved %d", e, a) + } n, err = b.WriteAt([]byte{3}, 2) - assert.NoError(t, err) - assert.Equal(t, 1, n) + if err != nil { + t.Errorf("expected no error, but received %v", err) + } + if e, a := 1, n; e != a { + t.Errorf("expected %d, but received %d", e, a) + } - assert.Equal(t, []byte{1, 2, 3, 0, 0, 1, 1, 1}, b.Bytes()) + if !bytes.Equal([]byte{1, 2, 3, 0, 0, 1, 1, 1}, b.Bytes()) { + t.Errorf("expected %v, but received %v", []byte{1, 2, 3, 0, 0, 1, 1, 1}, b.Bytes()) + } } func BenchmarkWriteAtBuffer(b *testing.B) {