MCPcopy
hub / github.com/gogo/protobuf / TestNidOptNativeProto

Function TestNidOptNativeProto

test/combos/both/thetestpb_test.go:24–56  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22var _ = math.Inf
23
24func TestNidOptNativeProto(t *testing.T) {
25 seed := time.Now().UnixNano()
26 popr := math_rand.New(math_rand.NewSource(seed))
27 p := NewPopulatedNidOptNative(popr, false)
28 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
29 if err != nil {
30 t.Fatalf("seed = %d, err = %v", seed, err)
31 }
32 msg := &NidOptNative{}
33 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
34 t.Fatalf("seed = %d, err = %v", seed, err)
35 }
36 littlefuzz := make([]byte, len(dAtA))
37 copy(littlefuzz, dAtA)
38 for i := range dAtA {
39 dAtA[i] = byte(popr.Intn(256))
40 }
41 if err := p.VerboseEqual(msg); err != nil {
42 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
43 }
44 if !p.Equal(msg) {
45 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
46 }
47 if len(littlefuzz) > 0 {
48 fuzzamount := 100
49 for i := 0; i < fuzzamount; i++ {
50 littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256))
51 littlefuzz = append(littlefuzz, byte(popr.Intn(256)))
52 }
53 // shouldn't panic
54 _ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
55 }
56}
57
58func TestNidOptNativeMarshalTo(t *testing.T) {
59 seed := time.Now().UnixNano()

Callers

nothing calls this directly

Calls 6

NewPopulatedNidOptNativeFunction · 0.70
MarshalMethod · 0.65
UnmarshalMethod · 0.65
IntnMethod · 0.65
VerboseEqualMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…