msgpack_test.go
This file
Path
binding/msgpack_test.go
34 lines · 785 bytes · Go
Last changed by
chore: support min go version 1.18 (#3511)thinkeroubefore adoption1e1f0b1
History of this fileTake it
The walk stopped after 200 commits: lines older than f3a6b69 point at it.
Delete unused static const (#2830)Alexander Melentyevbefore adoptionf3a6b69
lines 1–27why, one step back1// Copyright 2019 Gin Core Team. All rights reserved.2// Use of this source code is governed by a MIT style3// license that can be found in the LICENSE file.45//go:build !nomsgpack67package binding89import (10 "bytes"11 "testing"1213 "github.com/stretchr/testify/assert"14 "github.com/stretchr/testify/require"15 "github.com/ugorji/go/codec"16)1718func TestMsgpackBindingBindBody(t *testing.T) {19 type teststruct struct {20 Foo string `msgpack:"foo"`21 }22 var s teststruct23 err := msgpackBinding{}.BindBody(msgpackBody(t, teststruct{"FOO"}), &s)24 require.NoError(t, err)25 assert.Equal(t, "FOO", s.Foo)26}27test support go1.18 (#2990)thinkeroubefore adoption2bde107
line 28why, one step back28func msgpackBody(t *testing.T, obj any) []byte {Delete unused static const (#2830)Alexander Melentyevbefore adoptionf3a6b69
lines 29–34why, one step back29 var bs bytes.Buffer30 h := &codec.MsgpackHandle{}31 err := codec.NewEncoder(&bs, h).Encode(obj)32 require.NoError(t, err)33 return bs.Bytes()34}