MCPcopy Index your code
hub / github.com/ByteStorage/FlyDB / TestMessagePackCodec_Encode

Function TestMessagePackCodec_Encode

lib/encoding/messagepack_test.go:93–118  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

91}
92
93func TestMessagePackCodec_Encode(t *testing.T) {
94 type TestStruct struct {
95 Field1 string
96 Field2 int
97 }
98 assert := assert.New(t)
99
100 codec := &MessagePackCodec{
101 MsgPack: NewMsgPackHandle(),
102 }
103
104 t.Run("successful encoding", func(t *testing.T) {
105 testStruct := &TestStruct{
106 Field1: "Test",
107 Field2: 1,
108 }
109 outStruct := &TestStruct{}
110
111 b, err := codec.Encode(testStruct)
112 assert.Nil(err, "Error should be nil")
113 err = codec.Decode(b, outStruct)
114 assert.NoError(err)
115 assert.EqualValues(testStruct, outStruct)
116 })
117
118}
119func TestEncodeString(t *testing.T) {
120 tests := []struct {
121 input string

Callers

nothing calls this directly

Calls 3

EncodeMethod · 0.95
DecodeMethod · 0.95
NewMsgPackHandleFunction · 0.85

Tested by

no test coverage detected