1// Code generated by protoc-gen-gogo. DO NOT EDIT.
2// source: c.proto
3
4package importing
5
6import (
7	fmt "fmt"
8	_ "github.com/gogo/protobuf/gogoproto"
9	github_com_gogo_protobuf_jsonpb "github.com/gogo/protobuf/jsonpb"
10	github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
11	proto "github.com/gogo/protobuf/proto"
12	_ "github.com/gogo/protobuf/test/importcustom-issue389/imported"
13	math "math"
14	math_rand "math/rand"
15	testing "testing"
16	time "time"
17)
18
19// Reference imports to suppress errors if they are not otherwise used.
20var _ = proto.Marshal
21var _ = fmt.Errorf
22var _ = math.Inf
23
24func TestCProto(t *testing.T) {
25	seed := time.Now().UnixNano()
26	popr := math_rand.New(math_rand.NewSource(seed))
27	p := NewPopulatedC(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 := &C{}
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 !p.Equal(msg) {
42		t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
43	}
44	if len(littlefuzz) > 0 {
45		fuzzamount := 100
46		for i := 0; i < fuzzamount; i++ {
47			littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256))
48			littlefuzz = append(littlefuzz, byte(popr.Intn(256)))
49		}
50		// shouldn't panic
51		_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
52	}
53}
54
55func TestCMarshalTo(t *testing.T) {
56	seed := time.Now().UnixNano()
57	popr := math_rand.New(math_rand.NewSource(seed))
58	p := NewPopulatedC(popr, false)
59	size := p.Size()
60	dAtA := make([]byte, size)
61	for i := range dAtA {
62		dAtA[i] = byte(popr.Intn(256))
63	}
64	_, err := p.MarshalTo(dAtA)
65	if err != nil {
66		t.Fatalf("seed = %d, err = %v", seed, err)
67	}
68	msg := &C{}
69	if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
70		t.Fatalf("seed = %d, err = %v", seed, err)
71	}
72	for i := range dAtA {
73		dAtA[i] = byte(popr.Intn(256))
74	}
75	if !p.Equal(msg) {
76		t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
77	}
78}
79
80func TestCJSON(t *testing.T) {
81	seed := time.Now().UnixNano()
82	popr := math_rand.New(math_rand.NewSource(seed))
83	p := NewPopulatedC(popr, true)
84	marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
85	jsondata, err := marshaler.MarshalToString(p)
86	if err != nil {
87		t.Fatalf("seed = %d, err = %v", seed, err)
88	}
89	msg := &C{}
90	err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg)
91	if err != nil {
92		t.Fatalf("seed = %d, err = %v", seed, err)
93	}
94	if !p.Equal(msg) {
95		t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p)
96	}
97}
98func TestCProtoText(t *testing.T) {
99	seed := time.Now().UnixNano()
100	popr := math_rand.New(math_rand.NewSource(seed))
101	p := NewPopulatedC(popr, true)
102	dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p)
103	msg := &C{}
104	if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
105		t.Fatalf("seed = %d, err = %v", seed, err)
106	}
107	if !p.Equal(msg) {
108		t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
109	}
110}
111
112func TestCProtoCompactText(t *testing.T) {
113	seed := time.Now().UnixNano()
114	popr := math_rand.New(math_rand.NewSource(seed))
115	p := NewPopulatedC(popr, true)
116	dAtA := github_com_gogo_protobuf_proto.CompactTextString(p)
117	msg := &C{}
118	if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
119		t.Fatalf("seed = %d, err = %v", seed, err)
120	}
121	if !p.Equal(msg) {
122		t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
123	}
124}
125
126func TestCSize(t *testing.T) {
127	seed := time.Now().UnixNano()
128	popr := math_rand.New(math_rand.NewSource(seed))
129	p := NewPopulatedC(popr, true)
130	size2 := github_com_gogo_protobuf_proto.Size(p)
131	dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
132	if err != nil {
133		t.Fatalf("seed = %d, err = %v", seed, err)
134	}
135	size := p.Size()
136	if len(dAtA) != size {
137		t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA))
138	}
139	if size2 != size {
140		t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2)
141	}
142	size3 := github_com_gogo_protobuf_proto.Size(p)
143	if size3 != size {
144		t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
145	}
146}
147
148//These tests are generated by github.com/gogo/protobuf/plugin/testgen
149