Skip to content

Commit 97f0884

Browse files
Fix tests and make sure tests run on pull requests (#7)
1 parent b7c8604 commit 97f0884

File tree

3 files changed

+27
-24
lines changed

3 files changed

+27
-24
lines changed

.github/workflows/tests.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Tests
22

33
on:
4+
pull_request:
5+
branches:
6+
- "*"
47
push:
58
branches:
69
- "*"

encode_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func TestEncodeBytes(t *testing.T) {
8585
encodeBytes(p, v)
8686

8787
assert.Equal(t, 1+1+4+len(v), len(p.Bytes()))
88-
assert.Equal(t, (Buffer)(v), (p.Bytes())[1+1+4:])
88+
assert.Equal(t, v, (p.Bytes())[1+1+4:])
8989

9090
p.Reset()
9191
n := testing.AllocsPerRun(100, func() {
@@ -105,7 +105,7 @@ func TestEncodeString(t *testing.T) {
105105
encodeString(p, v)
106106

107107
assert.Equal(t, 1+1+4+len(e), len(p.Bytes()))
108-
assert.Equal(t, (Buffer)(e), (p.Bytes())[1+1+4:])
108+
assert.Equal(t, e, (p.Bytes())[1+1+4:])
109109

110110
p.Reset()
111111
n := testing.AllocsPerRun(100, func() {
@@ -125,7 +125,7 @@ func TestEncodeError(t *testing.T) {
125125
encodeError(p, v)
126126

127127
assert.Equal(t, 1+1+1+4+len(e), len(p.Bytes()))
128-
assert.Equal(t, (Buffer)(e), (p.Bytes())[1+1+1+4:])
128+
assert.Equal(t, e, (p.Bytes())[1+1+1+4:])
129129

130130
p.Reset()
131131
n := testing.AllocsPerRun(100, func() {
@@ -144,7 +144,7 @@ func TestEncodeBool(t *testing.T) {
144144
encodeBool(p, true)
145145

146146
assert.Equal(t, 1+len(e), len(p.Bytes()))
147-
assert.Equal(t, (Buffer)(e), (p.Bytes())[1:])
147+
assert.Equal(t, e, (p.Bytes())[1:])
148148

149149
p.Reset()
150150
n := testing.AllocsPerRun(100, func() {
@@ -164,7 +164,7 @@ func TestEncodeUint8(t *testing.T) {
164164
encodeUint8(p, v)
165165

166166
assert.Equal(t, 1+len(e), len(p.Bytes()))
167-
assert.Equal(t, (Buffer)(e), (p.Bytes())[1:])
167+
assert.Equal(t, e, (p.Bytes())[1:])
168168

169169
p.Reset()
170170
n := testing.AllocsPerRun(100, func() {
@@ -184,7 +184,7 @@ func TestEncodeUint16(t *testing.T) {
184184
encodeUint16(p, v)
185185

186186
assert.Equal(t, 1+len(e), len(p.Bytes()))
187-
assert.Equal(t, (Buffer)(e), (p.Bytes())[1:])
187+
assert.Equal(t, e, (p.Bytes())[1:])
188188

189189
p.Reset()
190190
n := testing.AllocsPerRun(100, func() {
@@ -204,7 +204,7 @@ func TestEncodeUint32(t *testing.T) {
204204
encodeUint32(p, v)
205205

206206
assert.Equal(t, 1+len(e), len(p.Bytes()))
207-
assert.Equal(t, (Buffer)(e), (p.Bytes())[1:])
207+
assert.Equal(t, e, (p.Bytes())[1:])
208208

209209
p.Reset()
210210
n := testing.AllocsPerRun(100, func() {
@@ -224,7 +224,7 @@ func TestEncodeUint64(t *testing.T) {
224224
encodeUint64(p, v)
225225

226226
assert.Equal(t, 1+len(e), len(p.Bytes()))
227-
assert.Equal(t, (Buffer)(e), (p.Bytes())[1:])
227+
assert.Equal(t, e, (p.Bytes())[1:])
228228

229229
p.Reset()
230230
n := testing.AllocsPerRun(100, func() {
@@ -244,7 +244,7 @@ func TestEncodeInt32(t *testing.T) {
244244
encodeInt32(p, v)
245245

246246
assert.Equal(t, 1+len(e), len(p.Bytes()))
247-
assert.Equal(t, (Buffer)(e), (p.Bytes())[1:])
247+
assert.Equal(t, e, (p.Bytes())[1:])
248248

249249
p.Reset()
250250
n := testing.AllocsPerRun(100, func() {
@@ -264,7 +264,7 @@ func TestEncodeInt64(t *testing.T) {
264264
encodeInt64(p, v)
265265

266266
assert.Equal(t, 1+len(e), len(p.Bytes()))
267-
assert.Equal(t, (Buffer)(e), (p.Bytes())[1:])
267+
assert.Equal(t, e, (p.Bytes())[1:])
268268

269269
p.Reset()
270270
n := testing.AllocsPerRun(100, func() {
@@ -284,7 +284,7 @@ func TestEncodeFloat32(t *testing.T) {
284284
encodeFloat32(p, v)
285285

286286
assert.Equal(t, 1+len(e), len(p.Bytes()))
287-
assert.Equal(t, (Buffer)(e), (p.Bytes())[1:])
287+
assert.Equal(t, e, (p.Bytes())[1:])
288288

289289
p.Reset()
290290
n := testing.AllocsPerRun(100, func() {
@@ -304,7 +304,7 @@ func TestEncodeFloat64(t *testing.T) {
304304
encodeFloat64(p, v)
305305

306306
assert.Equal(t, 1+len(e), len(p.Bytes()))
307-
assert.Equal(t, (Buffer)(e), (p.Bytes())[1:])
307+
assert.Equal(t, e, (p.Bytes())[1:])
308308

309309
p.Reset()
310310
n := testing.AllocsPerRun(100, func() {

encoder_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func TestEncoderBytes(t *testing.T) {
104104
Encoder(p).Bytes(v)
105105

106106
assert.Equal(t, 1+1+4+len(v), len(p.Bytes()))
107-
assert.Equal(t, (Buffer)(v), (p.Bytes())[1+1+4:])
107+
assert.Equal(t, v, (p.Bytes())[1+1+4:])
108108

109109
p.Reset()
110110
n := testing.AllocsPerRun(100, func() {
@@ -124,7 +124,7 @@ func TestEncoderString(t *testing.T) {
124124
Encoder(p).String(v)
125125

126126
assert.Equal(t, 1+1+4+len(e), len(p.Bytes()))
127-
assert.Equal(t, (Buffer)(e), (p.Bytes())[1+1+4:])
127+
assert.Equal(t, e, (p.Bytes())[1+1+4:])
128128

129129
p.Reset()
130130
n := testing.AllocsPerRun(100, func() {
@@ -144,7 +144,7 @@ func TestEncoderError(t *testing.T) {
144144
Encoder(p).Error(v)
145145

146146
assert.Equal(t, 1+1+1+4+len(e), len(p.Bytes()))
147-
assert.Equal(t, (Buffer)(e), (p.Bytes())[1+1+1+4:])
147+
assert.Equal(t, e, (p.Bytes())[1+1+1+4:])
148148

149149
p.Reset()
150150
n := testing.AllocsPerRun(100, func() {
@@ -163,7 +163,7 @@ func TestEncoderBool(t *testing.T) {
163163
Encoder(p).Bool(true)
164164

165165
assert.Equal(t, 1+len(e), len(p.Bytes()))
166-
assert.Equal(t, (Buffer)(e), (p.Bytes())[1:])
166+
assert.Equal(t, e, (p.Bytes())[1:])
167167

168168
p.Reset()
169169
n := testing.AllocsPerRun(100, func() {
@@ -183,7 +183,7 @@ func TestEncoderUint8(t *testing.T) {
183183
Encoder(p).Uint8(v)
184184

185185
assert.Equal(t, 1+len(e), len(p.Bytes()))
186-
assert.Equal(t, (Buffer)(e), (p.Bytes())[1:])
186+
assert.Equal(t, e, (p.Bytes())[1:])
187187

188188
p.Reset()
189189
n := testing.AllocsPerRun(100, func() {
@@ -203,7 +203,7 @@ func TestEncoderUint16(t *testing.T) {
203203
Encoder(p).Uint16(v)
204204

205205
assert.Equal(t, 1+len(e), len(p.Bytes()))
206-
assert.Equal(t, (Buffer)(e), (p.Bytes())[1:])
206+
assert.Equal(t, e, (p.Bytes())[1:])
207207

208208
p.Reset()
209209
n := testing.AllocsPerRun(100, func() {
@@ -223,7 +223,7 @@ func TestEncoderUint32(t *testing.T) {
223223
Encoder(p).Uint32(v)
224224

225225
assert.Equal(t, 1+len(e), len(p.Bytes()))
226-
assert.Equal(t, (Buffer)(e), (p.Bytes())[1:])
226+
assert.Equal(t, e, (p.Bytes())[1:])
227227

228228
p.Reset()
229229
n := testing.AllocsPerRun(100, func() {
@@ -243,7 +243,7 @@ func TestEncoderUint64(t *testing.T) {
243243
Encoder(p).Uint64(v)
244244

245245
assert.Equal(t, 1+len(e), len(p.Bytes()))
246-
assert.Equal(t, (Buffer)(e), (p.Bytes())[1:])
246+
assert.Equal(t, e, (p.Bytes())[1:])
247247

248248
p.Reset()
249249
n := testing.AllocsPerRun(100, func() {
@@ -263,7 +263,7 @@ func TestEncoderInt32(t *testing.T) {
263263
Encoder(p).Int32(v)
264264

265265
assert.Equal(t, 1+len(e), len(p.Bytes()))
266-
assert.Equal(t, (Buffer)(e), (p.Bytes())[1:])
266+
assert.Equal(t, e, (p.Bytes())[1:])
267267

268268
p.Reset()
269269
n := testing.AllocsPerRun(100, func() {
@@ -283,7 +283,7 @@ func TestEncoderInt64(t *testing.T) {
283283
Encoder(p).Int64(v)
284284

285285
assert.Equal(t, 1+len(e), len(p.Bytes()))
286-
assert.Equal(t, (Buffer)(e), (p.Bytes())[1:])
286+
assert.Equal(t, e, (p.Bytes())[1:])
287287

288288
p.Reset()
289289
n := testing.AllocsPerRun(100, func() {
@@ -303,7 +303,7 @@ func TestEncoderFloat32(t *testing.T) {
303303
Encoder(p).Float32(v)
304304

305305
assert.Equal(t, 1+len(e), len(p.Bytes()))
306-
assert.Equal(t, (Buffer)(e), (p.Bytes())[1:])
306+
assert.Equal(t, e, (p.Bytes())[1:])
307307

308308
p.Reset()
309309
n := testing.AllocsPerRun(100, func() {
@@ -323,7 +323,7 @@ func TestEncoderFloat64(t *testing.T) {
323323
Encoder(p).Float64(v)
324324

325325
assert.Equal(t, 1+len(e), len(p.Bytes()))
326-
assert.Equal(t, (Buffer)(e), (p.Bytes())[1:])
326+
assert.Equal(t, e, (p.Bytes())[1:])
327327

328328
p.Reset()
329329
n := testing.AllocsPerRun(100, func() {

0 commit comments

Comments
 (0)