Home / File/ msgpack_test.go — gin Source File

msgpack_test.go — gin Source File

Architecture documentation for msgpack_test.go, a go file in the gin codebase. 1 imports, 0 dependents.

File go RequestBinding FormBinding 1 imports 2 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  35f89c70_61d0_e90b_b96b_49fce8878e4b["msgpack_test.go"]
  fefe783b_8987_7aed_66c9_b2860bfc32e7["bytes"]
  35f89c70_61d0_e90b_b96b_49fce8878e4b --> fefe783b_8987_7aed_66c9_b2860bfc32e7
  style 35f89c70_61d0_e90b_b96b_49fce8878e4b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// Copyright 2019 Gin Core Team. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.

//go:build !nomsgpack

package binding

import (
	"bytes"
	"testing"

	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
	"github.com/ugorji/go/codec"
)

func TestMsgpackBindingBindBody(t *testing.T) {
	type teststruct struct {
		Foo string `msgpack:"foo"`
	}
	var s teststruct
	err := msgpackBinding{}.BindBody(msgpackBody(t, teststruct{"FOO"}), &s)
	require.NoError(t, err)
	assert.Equal(t, "FOO", s.Foo)
}

func msgpackBody(t *testing.T, obj any) []byte {
	var bs bytes.Buffer
	h := &codec.MsgpackHandle{}
	err := codec.NewEncoder(&bs, h).Encode(obj)
	require.NoError(t, err)
	return bs.Bytes()
}

Subdomains

Classes

Dependencies

  • bytes

Frequently Asked Questions

What does msgpack_test.go do?
msgpack_test.go is a source file in the gin codebase, written in go. It belongs to the RequestBinding domain, FormBinding subdomain.
What functions are defined in msgpack_test.go?
msgpack_test.go defines 2 function(s): TestMsgpackBindingBindBody, msgpackBody.
What does msgpack_test.go depend on?
msgpack_test.go imports 1 module(s): bytes.
Where is msgpack_test.go in the architecture?
msgpack_test.go is located at binding/msgpack_test.go (domain: RequestBinding, subdomain: FormBinding, directory: binding).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free