Skip to content

Commit 005932b

Browse files
committed
chore: use testify to replace check.v1
1 parent 35fa1c1 commit 005932b

File tree

3 files changed

+75
-85
lines changed

3 files changed

+75
-85
lines changed

go.mod

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
module github.com/vmihailenco/msgpack/v5
22

33
require (
4-
github.com/davecgh/go-spew v1.1.1 // indirect
5-
github.com/kr/pretty v0.1.0 // indirect
64
github.com/stretchr/testify v1.6.1
75
github.com/vmihailenco/tagparser v0.1.2
8-
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127
96
)
107

118
go 1.11

go.sum

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
1+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
12
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2-
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
3-
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4-
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
5-
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
6-
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
7-
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
8-
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
93
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
104
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
115
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
126
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
137
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
148
github.com/vmihailenco/tagparser v0.1.2 h1:gnjoVuB/kljJ5wICEEOpx98oXMWPLj22G67Vbd1qPqc=
159
github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
10+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
1611
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
17-
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
18-
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1912
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
2013
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

msgpack_test.go

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -3,109 +3,109 @@ package msgpack_test
33
import (
44
"bufio"
55
"bytes"
6+
"fmt"
67
"math"
78
"reflect"
89
"testing"
910
"time"
1011

1112
"github.com/stretchr/testify/require"
12-
. "gopkg.in/check.v1"
13-
13+
"github.com/stretchr/testify/suite"
1414
"github.com/vmihailenco/msgpack/v5"
1515
)
1616

1717
type nameStruct struct {
1818
Name string
1919
}
2020

21-
func TestGocheck(t *testing.T) { TestingT(t) }
22-
2321
type MsgpackTest struct {
22+
suite.Suite
23+
2424
buf *bytes.Buffer
2525
enc *msgpack.Encoder
2626
dec *msgpack.Decoder
2727
}
2828

29-
var _ = Suite(&MsgpackTest{})
30-
31-
func (t *MsgpackTest) SetUpTest(c *C) {
29+
func (t *MsgpackTest) SetUpTest() {
3230
t.buf = &bytes.Buffer{}
3331
t.enc = msgpack.NewEncoder(t.buf)
3432
t.dec = msgpack.NewDecoder(bufio.NewReader(t.buf))
3533
}
3634

37-
func (t *MsgpackTest) TestDecodeNil(c *C) {
38-
c.Assert(t.dec.Decode(nil), NotNil)
35+
func (t *MsgpackTest) TestDecodeNil() {
36+
t.NotNil(t.dec.Decode(nil))
3937
}
4038

41-
func (t *MsgpackTest) TestTime(c *C) {
39+
func (t *MsgpackTest) TestTime() {
4240
in := time.Now()
4341
var out time.Time
44-
c.Assert(t.enc.Encode(in), IsNil)
45-
c.Assert(t.dec.Decode(&out), IsNil)
46-
c.Assert(out.Equal(in), Equals, true)
42+
43+
t.Nil(t.enc.Encode(in))
44+
t.Nil(t.dec.Decode(&out))
45+
t.True(out.Equal(in))
4746

4847
var zero time.Time
49-
c.Assert(t.enc.Encode(zero), IsNil)
50-
c.Assert(t.dec.Decode(&out), IsNil)
51-
c.Assert(out.Equal(zero), Equals, true)
52-
c.Assert(out.IsZero(), Equals, true)
48+
t.Nil(t.enc.Encode(zero))
49+
t.Nil(t.dec.Decode(&out))
50+
t.True(out.Equal(zero))
51+
t.True(out.IsZero())
52+
5353
}
5454

55-
func (t *MsgpackTest) TestLargeBytes(c *C) {
55+
func (t *MsgpackTest) TestLargeBytes() {
5656
N := int(1e6)
5757

5858
src := bytes.Repeat([]byte{'1'}, N)
59-
c.Assert(t.enc.Encode(src), IsNil)
59+
t.Nil(t.enc.Encode(src))
6060
var dst []byte
61-
c.Assert(t.dec.Decode(&dst), IsNil)
62-
c.Assert(dst, DeepEquals, src)
61+
t.Nil(t.dec.Decode(&dst))
62+
t.Equal(dst, src)
6363
}
6464

65-
func (t *MsgpackTest) TestLargeString(c *C) {
65+
func (t *MsgpackTest) TestLargeString() {
6666
N := int(1e6)
6767

6868
src := string(bytes.Repeat([]byte{'1'}, N))
69-
c.Assert(t.enc.Encode(src), IsNil)
69+
t.Nil(t.enc.Encode(src))
7070
var dst string
71-
c.Assert(t.dec.Decode(&dst), IsNil)
72-
c.Assert(dst, Equals, src)
71+
t.Nil(t.dec.Decode(&dst))
72+
t.Equal(dst, src)
7373
}
7474

75-
func (t *MsgpackTest) TestSliceOfStructs(c *C) {
76-
in := []*nameStruct{&nameStruct{"hello"}}
75+
func (t *MsgpackTest) TestSliceOfStructs() {
76+
in := []*nameStruct{{"hello"}}
7777
var out []*nameStruct
78-
c.Assert(t.enc.Encode(in), IsNil)
79-
c.Assert(t.dec.Decode(&out), IsNil)
80-
c.Assert(out, DeepEquals, in)
78+
t.Nil(t.enc.Encode(in))
79+
t.Nil(t.dec.Decode(&out))
80+
t.Equal(out, in)
8181
}
8282

83-
func (t *MsgpackTest) TestMap(c *C) {
83+
func (t *MsgpackTest) TestMap() {
8484
for _, i := range []struct {
8585
m map[string]string
8686
b []byte
8787
}{
8888
{map[string]string{}, []byte{0x80}},
8989
{map[string]string{"hello": "world"}, []byte{0x81, 0xa5, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0xa5, 0x77, 0x6f, 0x72, 0x6c, 0x64}},
9090
} {
91-
c.Assert(t.enc.Encode(i.m), IsNil)
92-
c.Assert(t.buf.Bytes(), DeepEquals, i.b, Commentf("err encoding %v", i.m))
91+
t.Nil(t.enc.Encode(i.m))
92+
t.Equal(t.buf.Bytes(), i.b, fmt.Errorf("err encoding %v", i.m))
9393
var m map[string]string
94-
c.Assert(t.dec.Decode(&m), IsNil)
95-
c.Assert(m, DeepEquals, i.m)
94+
t.Nil(t.dec.Decode(&m))
95+
t.Equal(m, i.m)
9696
}
9797
}
9898

99-
func (t *MsgpackTest) TestStructNil(c *C) {
99+
func (t *MsgpackTest) TestStructNil() {
100100
var dst *nameStruct
101101

102-
c.Assert(t.enc.Encode(nameStruct{Name: "foo"}), IsNil)
103-
c.Assert(t.dec.Decode(&dst), IsNil)
104-
c.Assert(dst, Not(IsNil))
105-
c.Assert(dst.Name, Equals, "foo")
102+
t.Nil(t.enc.Encode(nameStruct{Name: "foo"}))
103+
t.Nil(t.dec.Decode(&dst))
104+
t.NotNil(dst)
105+
t.Equal(dst.Name, "foo")
106106
}
107107

108-
func (t *MsgpackTest) TestStructUnknownField(c *C) {
108+
func (t *MsgpackTest) TestStructUnknownField() {
109109
in := struct {
110110
Field1 string
111111
Field2 string
@@ -115,13 +115,13 @@ func (t *MsgpackTest) TestStructUnknownField(c *C) {
115115
Field2: "value2",
116116
Field3: "value3",
117117
}
118-
c.Assert(t.enc.Encode(in), IsNil)
118+
t.Nil(t.enc.Encode(in))
119119

120120
out := struct {
121121
Field2 string
122122
}{}
123-
c.Assert(t.dec.Decode(&out), IsNil)
124-
c.Assert(out.Field2, Equals, "value2")
123+
t.Nil(t.dec.Decode(&out))
124+
t.Equal(out.Field2, "value2")
125125
}
126126

127127
//------------------------------------------------------------------------------
@@ -151,45 +151,45 @@ func (s *coderStruct) DecodeMsgpack(dec *msgpack.Decoder) error {
151151
return dec.Decode(&s.name)
152152
}
153153

154-
func (t *MsgpackTest) TestCoder(c *C) {
154+
func (t *MsgpackTest) TestCoder() {
155155
in := &coderStruct{name: "hello"}
156156
var out coderStruct
157-
c.Assert(t.enc.Encode(in), IsNil)
158-
c.Assert(t.dec.Decode(&out), IsNil)
159-
c.Assert(out.Name(), Equals, "hello")
157+
t.Nil(t.enc.Encode(in))
158+
t.Nil(t.dec.Decode(&out))
159+
t.Equal(out.Name(), "hello")
160160
}
161161

162-
func (t *MsgpackTest) TestNilCoder(c *C) {
162+
func (t *MsgpackTest) TestNilCoder() {
163163
in := &coderStruct{name: "hello"}
164164
var out *coderStruct
165-
c.Assert(t.enc.Encode(in), IsNil)
166-
c.Assert(t.dec.Decode(&out), IsNil)
167-
c.Assert(out.Name(), Equals, "hello")
165+
t.Nil(t.enc.Encode(in))
166+
t.Nil(t.dec.Decode(&out))
167+
t.Equal(out.Name(), "hello")
168168
}
169169

170-
func (t *MsgpackTest) TestNilCoderValue(c *C) {
170+
func (t *MsgpackTest) TestNilCoderValue() {
171171
in := &coderStruct{name: "hello"}
172172
var out *coderStruct
173-
c.Assert(t.enc.Encode(in), IsNil)
174-
c.Assert(t.dec.DecodeValue(reflect.ValueOf(&out)), IsNil)
175-
c.Assert(out.Name(), Equals, "hello")
173+
t.Nil(t.enc.Encode(in))
174+
t.Nil(t.dec.DecodeValue(reflect.ValueOf(&out)))
175+
t.Equal(out.Name(), "hello")
176176
}
177177

178-
func (t *MsgpackTest) TestPtrToCoder(c *C) {
178+
func (t *MsgpackTest) TestPtrToCoder() {
179179
in := &coderStruct{name: "hello"}
180180
var out coderStruct
181181
out2 := &out
182-
c.Assert(t.enc.Encode(in), IsNil)
183-
c.Assert(t.dec.Decode(&out2), IsNil)
184-
c.Assert(out.Name(), Equals, "hello")
182+
t.Nil(t.enc.Encode(in))
183+
t.Nil(t.dec.Decode(&out2))
184+
t.Equal(out.Name(), "hello")
185185
}
186186

187-
func (t *MsgpackTest) TestWrappedCoder(c *C) {
187+
func (t *MsgpackTest) TestWrappedCoder() {
188188
in := &wrapperStruct{coderStruct: coderStruct{name: "hello"}}
189189
var out wrapperStruct
190-
c.Assert(t.enc.Encode(in), IsNil)
191-
c.Assert(t.dec.Decode(&out), IsNil)
192-
c.Assert(out.Name(), Equals, "hello")
190+
t.Nil(t.enc.Encode(in))
191+
t.Nil(t.dec.Decode(&out))
192+
t.Equal(out.Name(), "hello")
193193
}
194194

195195
//------------------------------------------------------------------------------
@@ -203,13 +203,13 @@ type struct1 struct {
203203
Struct2 struct2
204204
}
205205

206-
func (t *MsgpackTest) TestNestedStructs(c *C) {
206+
func (t *MsgpackTest) TestNestedStructs() {
207207
in := &struct1{Name: "hello", Struct2: struct2{Name: "world"}}
208208
var out struct1
209-
c.Assert(t.enc.Encode(in), IsNil)
210-
c.Assert(t.dec.Decode(&out), IsNil)
211-
c.Assert(out.Name, Equals, in.Name)
212-
c.Assert(out.Struct2.Name, Equals, in.Struct2.Name)
209+
t.Nil(t.enc.Encode(in))
210+
t.Nil(t.dec.Decode(&out))
211+
t.Equal(out.Name, in.Name)
212+
t.Equal(out.Struct2.Name, in.Struct2.Name)
213213
}
214214

215215
type Struct4 struct {
@@ -247,13 +247,13 @@ func TestEmbedding(t *testing.T) {
247247
}
248248
}
249249

250-
func (t *MsgpackTest) TestSliceNil(c *C) {
250+
func (t *MsgpackTest) TestSliceNil() {
251251
in := [][]*int{nil}
252252
var out [][]*int
253253

254-
c.Assert(t.enc.Encode(in), IsNil)
255-
c.Assert(t.dec.Decode(&out), IsNil)
256-
c.Assert(out, DeepEquals, in)
254+
t.Nil(t.enc.Encode(in))
255+
t.Nil(t.dec.Decode(&out))
256+
t.Equal(out, in)
257257
}
258258

259259
//------------------------------------------------------------------------------

0 commit comments

Comments
 (0)