MCPcopy
hub / github.com/lonng/nano / TestProtobufSerialezer_Serialize

Function TestProtobufSerialezer_Serialize

serialize/protobuf/protobuf_test.go:10–27  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestProtobufSerialezer_Serialize(t *testing.T) {
11 m := &testdata.Ping{Content: "hello"}
12 s := NewSerializer()
13
14 b, err := s.Marshal(m)
15 if err != nil {
16 t.Error(err)
17 }
18
19 m1 := &testdata.Ping{}
20 if err := s.Unmarshal(b, m1); err != nil {
21 t.Fatalf("unmarshal failed: %v", err)
22 }
23 // refer: https://developers.google.com/protocol-buffers/docs/reference/go/faq#deepequal
24 if !proto.Equal(m, m1) {
25 t.Fail()
26 }
27}
28
29func BenchmarkSerializer_Serialize(b *testing.B) {
30 m := &testdata.Ping{Content: "hello"}

Callers

nothing calls this directly

Calls 4

MarshalMethod · 0.95
UnmarshalMethod · 0.95
FatalfMethod · 0.80
NewSerializerFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…