1// Code generated by protoc-gen-gogo. DO NOT EDIT.
2// source: castvalue.proto
3
4package castvalue
5
6import testing "testing"
7import math_rand "math/rand"
8import time "time"
9import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
10import github_com_gogo_protobuf_jsonpb "github.com/gogo/protobuf/jsonpb"
11import fmt "fmt"
12import go_parser "go/parser"
13import proto "github.com/gogo/protobuf/proto"
14import math "math"
15import _ "github.com/gogo/protobuf/gogoproto"
16
17// Reference imports to suppress errors if they are not otherwise used.
18var _ = proto.Marshal
19var _ = fmt.Errorf
20var _ = math.Inf
21
22func TestCastawayProto(t *testing.T) {
23	seed := time.Now().UnixNano()
24	popr := math_rand.New(math_rand.NewSource(seed))
25	p := NewPopulatedCastaway(popr, false)
26	dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
27	if err != nil {
28		t.Fatalf("seed = %d, err = %v", seed, err)
29	}
30	msg := &Castaway{}
31	if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
32		t.Fatalf("seed = %d, err = %v", seed, err)
33	}
34	littlefuzz := make([]byte, len(dAtA))
35	copy(littlefuzz, dAtA)
36	for i := range dAtA {
37		dAtA[i] = byte(popr.Intn(256))
38	}
39	if err := p.VerboseEqual(msg); err != nil {
40		t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
41	}
42	if !p.Equal(msg) {
43		t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
44	}
45	if len(littlefuzz) > 0 {
46		fuzzamount := 100
47		for i := 0; i < fuzzamount; i++ {
48			littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256))
49			littlefuzz = append(littlefuzz, byte(popr.Intn(256)))
50		}
51		// shouldn't panic
52		_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
53	}
54}
55
56func BenchmarkCastawayProtoMarshal(b *testing.B) {
57	popr := math_rand.New(math_rand.NewSource(616))
58	total := 0
59	pops := make([]*Castaway, 10000)
60	for i := 0; i < 10000; i++ {
61		pops[i] = NewPopulatedCastaway(popr, false)
62	}
63	b.ResetTimer()
64	for i := 0; i < b.N; i++ {
65		dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000])
66		if err != nil {
67			panic(err)
68		}
69		total += len(dAtA)
70	}
71	b.SetBytes(int64(total / b.N))
72}
73
74func BenchmarkCastawayProtoUnmarshal(b *testing.B) {
75	popr := math_rand.New(math_rand.NewSource(616))
76	total := 0
77	datas := make([][]byte, 10000)
78	for i := 0; i < 10000; i++ {
79		dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedCastaway(popr, false))
80		if err != nil {
81			panic(err)
82		}
83		datas[i] = dAtA
84	}
85	msg := &Castaway{}
86	b.ResetTimer()
87	for i := 0; i < b.N; i++ {
88		total += len(datas[i%10000])
89		if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil {
90			panic(err)
91		}
92	}
93	b.SetBytes(int64(total / b.N))
94}
95
96func TestWilsonProto(t *testing.T) {
97	seed := time.Now().UnixNano()
98	popr := math_rand.New(math_rand.NewSource(seed))
99	p := NewPopulatedWilson(popr, false)
100	dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
101	if err != nil {
102		t.Fatalf("seed = %d, err = %v", seed, err)
103	}
104	msg := &Wilson{}
105	if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
106		t.Fatalf("seed = %d, err = %v", seed, err)
107	}
108	littlefuzz := make([]byte, len(dAtA))
109	copy(littlefuzz, dAtA)
110	for i := range dAtA {
111		dAtA[i] = byte(popr.Intn(256))
112	}
113	if err := p.VerboseEqual(msg); err != nil {
114		t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
115	}
116	if !p.Equal(msg) {
117		t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
118	}
119	if len(littlefuzz) > 0 {
120		fuzzamount := 100
121		for i := 0; i < fuzzamount; i++ {
122			littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256))
123			littlefuzz = append(littlefuzz, byte(popr.Intn(256)))
124		}
125		// shouldn't panic
126		_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
127	}
128}
129
130func BenchmarkWilsonProtoMarshal(b *testing.B) {
131	popr := math_rand.New(math_rand.NewSource(616))
132	total := 0
133	pops := make([]*Wilson, 10000)
134	for i := 0; i < 10000; i++ {
135		pops[i] = NewPopulatedWilson(popr, false)
136	}
137	b.ResetTimer()
138	for i := 0; i < b.N; i++ {
139		dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000])
140		if err != nil {
141			panic(err)
142		}
143		total += len(dAtA)
144	}
145	b.SetBytes(int64(total / b.N))
146}
147
148func BenchmarkWilsonProtoUnmarshal(b *testing.B) {
149	popr := math_rand.New(math_rand.NewSource(616))
150	total := 0
151	datas := make([][]byte, 10000)
152	for i := 0; i < 10000; i++ {
153		dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedWilson(popr, false))
154		if err != nil {
155			panic(err)
156		}
157		datas[i] = dAtA
158	}
159	msg := &Wilson{}
160	b.ResetTimer()
161	for i := 0; i < b.N; i++ {
162		total += len(datas[i%10000])
163		if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil {
164			panic(err)
165		}
166	}
167	b.SetBytes(int64(total / b.N))
168}
169
170func TestCastawayJSON(t *testing.T) {
171	seed := time.Now().UnixNano()
172	popr := math_rand.New(math_rand.NewSource(seed))
173	p := NewPopulatedCastaway(popr, true)
174	marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
175	jsondata, err := marshaler.MarshalToString(p)
176	if err != nil {
177		t.Fatalf("seed = %d, err = %v", seed, err)
178	}
179	msg := &Castaway{}
180	err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg)
181	if err != nil {
182		t.Fatalf("seed = %d, err = %v", seed, err)
183	}
184	if err := p.VerboseEqual(msg); err != nil {
185		t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
186	}
187	if !p.Equal(msg) {
188		t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p)
189	}
190}
191func TestWilsonJSON(t *testing.T) {
192	seed := time.Now().UnixNano()
193	popr := math_rand.New(math_rand.NewSource(seed))
194	p := NewPopulatedWilson(popr, true)
195	marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
196	jsondata, err := marshaler.MarshalToString(p)
197	if err != nil {
198		t.Fatalf("seed = %d, err = %v", seed, err)
199	}
200	msg := &Wilson{}
201	err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg)
202	if err != nil {
203		t.Fatalf("seed = %d, err = %v", seed, err)
204	}
205	if err := p.VerboseEqual(msg); err != nil {
206		t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
207	}
208	if !p.Equal(msg) {
209		t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p)
210	}
211}
212func TestCastawayProtoText(t *testing.T) {
213	seed := time.Now().UnixNano()
214	popr := math_rand.New(math_rand.NewSource(seed))
215	p := NewPopulatedCastaway(popr, true)
216	dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p)
217	msg := &Castaway{}
218	if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
219		t.Fatalf("seed = %d, err = %v", seed, err)
220	}
221	if err := p.VerboseEqual(msg); err != nil {
222		t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
223	}
224	if !p.Equal(msg) {
225		t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
226	}
227}
228
229func TestCastawayProtoCompactText(t *testing.T) {
230	seed := time.Now().UnixNano()
231	popr := math_rand.New(math_rand.NewSource(seed))
232	p := NewPopulatedCastaway(popr, true)
233	dAtA := github_com_gogo_protobuf_proto.CompactTextString(p)
234	msg := &Castaway{}
235	if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
236		t.Fatalf("seed = %d, err = %v", seed, err)
237	}
238	if err := p.VerboseEqual(msg); err != nil {
239		t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
240	}
241	if !p.Equal(msg) {
242		t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
243	}
244}
245
246func TestWilsonProtoText(t *testing.T) {
247	seed := time.Now().UnixNano()
248	popr := math_rand.New(math_rand.NewSource(seed))
249	p := NewPopulatedWilson(popr, true)
250	dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p)
251	msg := &Wilson{}
252	if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
253		t.Fatalf("seed = %d, err = %v", seed, err)
254	}
255	if err := p.VerboseEqual(msg); err != nil {
256		t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
257	}
258	if !p.Equal(msg) {
259		t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
260	}
261}
262
263func TestWilsonProtoCompactText(t *testing.T) {
264	seed := time.Now().UnixNano()
265	popr := math_rand.New(math_rand.NewSource(seed))
266	p := NewPopulatedWilson(popr, true)
267	dAtA := github_com_gogo_protobuf_proto.CompactTextString(p)
268	msg := &Wilson{}
269	if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
270		t.Fatalf("seed = %d, err = %v", seed, err)
271	}
272	if err := p.VerboseEqual(msg); err != nil {
273		t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
274	}
275	if !p.Equal(msg) {
276		t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
277	}
278}
279
280func TestCastvalueDescription(t *testing.T) {
281	CastvalueDescription()
282}
283func TestCastawayVerboseEqual(t *testing.T) {
284	popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
285	p := NewPopulatedCastaway(popr, false)
286	dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
287	if err != nil {
288		panic(err)
289	}
290	msg := &Castaway{}
291	if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
292		panic(err)
293	}
294	if err := p.VerboseEqual(msg); err != nil {
295		t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err)
296	}
297}
298func TestWilsonVerboseEqual(t *testing.T) {
299	popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
300	p := NewPopulatedWilson(popr, false)
301	dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
302	if err != nil {
303		panic(err)
304	}
305	msg := &Wilson{}
306	if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
307		panic(err)
308	}
309	if err := p.VerboseEqual(msg); err != nil {
310		t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err)
311	}
312}
313func TestCastawayFace(t *testing.T) {
314	popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
315	p := NewPopulatedCastaway(popr, true)
316	msg := p.TestProto()
317	if !p.Equal(msg) {
318		t.Fatalf("%#v !Face Equal %#v", msg, p)
319	}
320}
321func TestWilsonFace(t *testing.T) {
322	popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
323	p := NewPopulatedWilson(popr, true)
324	msg := p.TestProto()
325	if !p.Equal(msg) {
326		t.Fatalf("%#v !Face Equal %#v", msg, p)
327	}
328}
329func TestCastawayGoString(t *testing.T) {
330	popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
331	p := NewPopulatedCastaway(popr, false)
332	s1 := p.GoString()
333	s2 := fmt.Sprintf("%#v", p)
334	if s1 != s2 {
335		t.Fatalf("GoString want %v got %v", s1, s2)
336	}
337	_, err := go_parser.ParseExpr(s1)
338	if err != nil {
339		t.Fatal(err)
340	}
341}
342func TestWilsonGoString(t *testing.T) {
343	popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
344	p := NewPopulatedWilson(popr, false)
345	s1 := p.GoString()
346	s2 := fmt.Sprintf("%#v", p)
347	if s1 != s2 {
348		t.Fatalf("GoString want %v got %v", s1, s2)
349	}
350	_, err := go_parser.ParseExpr(s1)
351	if err != nil {
352		t.Fatal(err)
353	}
354}
355func TestCastawaySize(t *testing.T) {
356	seed := time.Now().UnixNano()
357	popr := math_rand.New(math_rand.NewSource(seed))
358	p := NewPopulatedCastaway(popr, true)
359	size2 := github_com_gogo_protobuf_proto.Size(p)
360	dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
361	if err != nil {
362		t.Fatalf("seed = %d, err = %v", seed, err)
363	}
364	size := p.Size()
365	if len(dAtA) != size {
366		t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA))
367	}
368	if size2 != size {
369		t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2)
370	}
371	size3 := github_com_gogo_protobuf_proto.Size(p)
372	if size3 != size {
373		t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
374	}
375}
376
377func BenchmarkCastawaySize(b *testing.B) {
378	popr := math_rand.New(math_rand.NewSource(616))
379	total := 0
380	pops := make([]*Castaway, 1000)
381	for i := 0; i < 1000; i++ {
382		pops[i] = NewPopulatedCastaway(popr, false)
383	}
384	b.ResetTimer()
385	for i := 0; i < b.N; i++ {
386		total += pops[i%1000].Size()
387	}
388	b.SetBytes(int64(total / b.N))
389}
390
391func TestWilsonSize(t *testing.T) {
392	seed := time.Now().UnixNano()
393	popr := math_rand.New(math_rand.NewSource(seed))
394	p := NewPopulatedWilson(popr, true)
395	size2 := github_com_gogo_protobuf_proto.Size(p)
396	dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
397	if err != nil {
398		t.Fatalf("seed = %d, err = %v", seed, err)
399	}
400	size := p.Size()
401	if len(dAtA) != size {
402		t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA))
403	}
404	if size2 != size {
405		t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2)
406	}
407	size3 := github_com_gogo_protobuf_proto.Size(p)
408	if size3 != size {
409		t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
410	}
411}
412
413func BenchmarkWilsonSize(b *testing.B) {
414	popr := math_rand.New(math_rand.NewSource(616))
415	total := 0
416	pops := make([]*Wilson, 1000)
417	for i := 0; i < 1000; i++ {
418		pops[i] = NewPopulatedWilson(popr, false)
419	}
420	b.ResetTimer()
421	for i := 0; i < b.N; i++ {
422		total += pops[i%1000].Size()
423	}
424	b.SetBytes(int64(total / b.N))
425}
426
427func TestCastawayStringer(t *testing.T) {
428	popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
429	p := NewPopulatedCastaway(popr, false)
430	s1 := p.String()
431	s2 := fmt.Sprintf("%v", p)
432	if s1 != s2 {
433		t.Fatalf("String want %v got %v", s1, s2)
434	}
435}
436func TestWilsonStringer(t *testing.T) {
437	popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
438	p := NewPopulatedWilson(popr, false)
439	s1 := p.String()
440	s2 := fmt.Sprintf("%v", p)
441	if s1 != s2 {
442		t.Fatalf("String want %v got %v", s1, s2)
443	}
444}
445
446//These tests are generated by github.com/gogo/protobuf/plugin/testgen
447