1// Code generated by protoc-gen-gogo. DO NOT EDIT. 2// source: combos/both/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 TestCastawayMarshalTo(t *testing.T) { 57 seed := time.Now().UnixNano() 58 popr := math_rand.New(math_rand.NewSource(seed)) 59 p := NewPopulatedCastaway(popr, false) 60 size := p.Size() 61 dAtA := make([]byte, size) 62 for i := range dAtA { 63 dAtA[i] = byte(popr.Intn(256)) 64 } 65 _, err := p.MarshalTo(dAtA) 66 if err != nil { 67 t.Fatalf("seed = %d, err = %v", seed, err) 68 } 69 msg := &Castaway{} 70 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 71 t.Fatalf("seed = %d, err = %v", seed, err) 72 } 73 for i := range dAtA { 74 dAtA[i] = byte(popr.Intn(256)) 75 } 76 if err := p.VerboseEqual(msg); err != nil { 77 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 78 } 79 if !p.Equal(msg) { 80 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 81 } 82} 83 84func BenchmarkCastawayProtoMarshal(b *testing.B) { 85 popr := math_rand.New(math_rand.NewSource(616)) 86 total := 0 87 pops := make([]*Castaway, 10000) 88 for i := 0; i < 10000; i++ { 89 pops[i] = NewPopulatedCastaway(popr, false) 90 } 91 b.ResetTimer() 92 for i := 0; i < b.N; i++ { 93 dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000]) 94 if err != nil { 95 panic(err) 96 } 97 total += len(dAtA) 98 } 99 b.SetBytes(int64(total / b.N)) 100} 101 102func BenchmarkCastawayProtoUnmarshal(b *testing.B) { 103 popr := math_rand.New(math_rand.NewSource(616)) 104 total := 0 105 datas := make([][]byte, 10000) 106 for i := 0; i < 10000; i++ { 107 dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedCastaway(popr, false)) 108 if err != nil { 109 panic(err) 110 } 111 datas[i] = dAtA 112 } 113 msg := &Castaway{} 114 b.ResetTimer() 115 for i := 0; i < b.N; i++ { 116 total += len(datas[i%10000]) 117 if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil { 118 panic(err) 119 } 120 } 121 b.SetBytes(int64(total / b.N)) 122} 123 124func TestWilsonProto(t *testing.T) { 125 seed := time.Now().UnixNano() 126 popr := math_rand.New(math_rand.NewSource(seed)) 127 p := NewPopulatedWilson(popr, false) 128 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 129 if err != nil { 130 t.Fatalf("seed = %d, err = %v", seed, err) 131 } 132 msg := &Wilson{} 133 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 134 t.Fatalf("seed = %d, err = %v", seed, err) 135 } 136 littlefuzz := make([]byte, len(dAtA)) 137 copy(littlefuzz, dAtA) 138 for i := range dAtA { 139 dAtA[i] = byte(popr.Intn(256)) 140 } 141 if err := p.VerboseEqual(msg); err != nil { 142 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 143 } 144 if !p.Equal(msg) { 145 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 146 } 147 if len(littlefuzz) > 0 { 148 fuzzamount := 100 149 for i := 0; i < fuzzamount; i++ { 150 littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256)) 151 littlefuzz = append(littlefuzz, byte(popr.Intn(256))) 152 } 153 // shouldn't panic 154 _ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg) 155 } 156} 157 158func TestWilsonMarshalTo(t *testing.T) { 159 seed := time.Now().UnixNano() 160 popr := math_rand.New(math_rand.NewSource(seed)) 161 p := NewPopulatedWilson(popr, false) 162 size := p.Size() 163 dAtA := make([]byte, size) 164 for i := range dAtA { 165 dAtA[i] = byte(popr.Intn(256)) 166 } 167 _, err := p.MarshalTo(dAtA) 168 if err != nil { 169 t.Fatalf("seed = %d, err = %v", seed, err) 170 } 171 msg := &Wilson{} 172 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 173 t.Fatalf("seed = %d, err = %v", seed, err) 174 } 175 for i := range dAtA { 176 dAtA[i] = byte(popr.Intn(256)) 177 } 178 if err := p.VerboseEqual(msg); err != nil { 179 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 180 } 181 if !p.Equal(msg) { 182 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 183 } 184} 185 186func BenchmarkWilsonProtoMarshal(b *testing.B) { 187 popr := math_rand.New(math_rand.NewSource(616)) 188 total := 0 189 pops := make([]*Wilson, 10000) 190 for i := 0; i < 10000; i++ { 191 pops[i] = NewPopulatedWilson(popr, false) 192 } 193 b.ResetTimer() 194 for i := 0; i < b.N; i++ { 195 dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000]) 196 if err != nil { 197 panic(err) 198 } 199 total += len(dAtA) 200 } 201 b.SetBytes(int64(total / b.N)) 202} 203 204func BenchmarkWilsonProtoUnmarshal(b *testing.B) { 205 popr := math_rand.New(math_rand.NewSource(616)) 206 total := 0 207 datas := make([][]byte, 10000) 208 for i := 0; i < 10000; i++ { 209 dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedWilson(popr, false)) 210 if err != nil { 211 panic(err) 212 } 213 datas[i] = dAtA 214 } 215 msg := &Wilson{} 216 b.ResetTimer() 217 for i := 0; i < b.N; i++ { 218 total += len(datas[i%10000]) 219 if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil { 220 panic(err) 221 } 222 } 223 b.SetBytes(int64(total / b.N)) 224} 225 226func TestCastawayJSON(t *testing.T) { 227 seed := time.Now().UnixNano() 228 popr := math_rand.New(math_rand.NewSource(seed)) 229 p := NewPopulatedCastaway(popr, true) 230 marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{} 231 jsondata, err := marshaler.MarshalToString(p) 232 if err != nil { 233 t.Fatalf("seed = %d, err = %v", seed, err) 234 } 235 msg := &Castaway{} 236 err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg) 237 if err != nil { 238 t.Fatalf("seed = %d, err = %v", seed, err) 239 } 240 if err := p.VerboseEqual(msg); err != nil { 241 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 242 } 243 if !p.Equal(msg) { 244 t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p) 245 } 246} 247func TestWilsonJSON(t *testing.T) { 248 seed := time.Now().UnixNano() 249 popr := math_rand.New(math_rand.NewSource(seed)) 250 p := NewPopulatedWilson(popr, true) 251 marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{} 252 jsondata, err := marshaler.MarshalToString(p) 253 if err != nil { 254 t.Fatalf("seed = %d, err = %v", seed, err) 255 } 256 msg := &Wilson{} 257 err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg) 258 if err != nil { 259 t.Fatalf("seed = %d, err = %v", seed, err) 260 } 261 if err := p.VerboseEqual(msg); err != nil { 262 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 263 } 264 if !p.Equal(msg) { 265 t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p) 266 } 267} 268func TestCastawayProtoText(t *testing.T) { 269 seed := time.Now().UnixNano() 270 popr := math_rand.New(math_rand.NewSource(seed)) 271 p := NewPopulatedCastaway(popr, true) 272 dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p) 273 msg := &Castaway{} 274 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 275 t.Fatalf("seed = %d, err = %v", seed, err) 276 } 277 if err := p.VerboseEqual(msg); err != nil { 278 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 279 } 280 if !p.Equal(msg) { 281 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 282 } 283} 284 285func TestCastawayProtoCompactText(t *testing.T) { 286 seed := time.Now().UnixNano() 287 popr := math_rand.New(math_rand.NewSource(seed)) 288 p := NewPopulatedCastaway(popr, true) 289 dAtA := github_com_gogo_protobuf_proto.CompactTextString(p) 290 msg := &Castaway{} 291 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 292 t.Fatalf("seed = %d, err = %v", seed, err) 293 } 294 if err := p.VerboseEqual(msg); err != nil { 295 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 296 } 297 if !p.Equal(msg) { 298 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 299 } 300} 301 302func TestWilsonProtoText(t *testing.T) { 303 seed := time.Now().UnixNano() 304 popr := math_rand.New(math_rand.NewSource(seed)) 305 p := NewPopulatedWilson(popr, true) 306 dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p) 307 msg := &Wilson{} 308 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 309 t.Fatalf("seed = %d, err = %v", seed, err) 310 } 311 if err := p.VerboseEqual(msg); err != nil { 312 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 313 } 314 if !p.Equal(msg) { 315 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 316 } 317} 318 319func TestWilsonProtoCompactText(t *testing.T) { 320 seed := time.Now().UnixNano() 321 popr := math_rand.New(math_rand.NewSource(seed)) 322 p := NewPopulatedWilson(popr, true) 323 dAtA := github_com_gogo_protobuf_proto.CompactTextString(p) 324 msg := &Wilson{} 325 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 326 t.Fatalf("seed = %d, err = %v", seed, err) 327 } 328 if err := p.VerboseEqual(msg); err != nil { 329 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 330 } 331 if !p.Equal(msg) { 332 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 333 } 334} 335 336func TestCastvalueDescription(t *testing.T) { 337 CastvalueDescription() 338} 339func TestCastawayVerboseEqual(t *testing.T) { 340 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 341 p := NewPopulatedCastaway(popr, false) 342 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 343 if err != nil { 344 panic(err) 345 } 346 msg := &Castaway{} 347 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 348 panic(err) 349 } 350 if err := p.VerboseEqual(msg); err != nil { 351 t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err) 352 } 353} 354func TestWilsonVerboseEqual(t *testing.T) { 355 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 356 p := NewPopulatedWilson(popr, false) 357 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 358 if err != nil { 359 panic(err) 360 } 361 msg := &Wilson{} 362 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 363 panic(err) 364 } 365 if err := p.VerboseEqual(msg); err != nil { 366 t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err) 367 } 368} 369func TestCastawayFace(t *testing.T) { 370 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 371 p := NewPopulatedCastaway(popr, true) 372 msg := p.TestProto() 373 if !p.Equal(msg) { 374 t.Fatalf("%#v !Face Equal %#v", msg, p) 375 } 376} 377func TestWilsonFace(t *testing.T) { 378 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 379 p := NewPopulatedWilson(popr, true) 380 msg := p.TestProto() 381 if !p.Equal(msg) { 382 t.Fatalf("%#v !Face Equal %#v", msg, p) 383 } 384} 385func TestCastawayGoString(t *testing.T) { 386 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 387 p := NewPopulatedCastaway(popr, false) 388 s1 := p.GoString() 389 s2 := fmt.Sprintf("%#v", p) 390 if s1 != s2 { 391 t.Fatalf("GoString want %v got %v", s1, s2) 392 } 393 _, err := go_parser.ParseExpr(s1) 394 if err != nil { 395 t.Fatal(err) 396 } 397} 398func TestWilsonGoString(t *testing.T) { 399 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 400 p := NewPopulatedWilson(popr, false) 401 s1 := p.GoString() 402 s2 := fmt.Sprintf("%#v", p) 403 if s1 != s2 { 404 t.Fatalf("GoString want %v got %v", s1, s2) 405 } 406 _, err := go_parser.ParseExpr(s1) 407 if err != nil { 408 t.Fatal(err) 409 } 410} 411func TestCastawaySize(t *testing.T) { 412 seed := time.Now().UnixNano() 413 popr := math_rand.New(math_rand.NewSource(seed)) 414 p := NewPopulatedCastaway(popr, true) 415 size2 := github_com_gogo_protobuf_proto.Size(p) 416 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 417 if err != nil { 418 t.Fatalf("seed = %d, err = %v", seed, err) 419 } 420 size := p.Size() 421 if len(dAtA) != size { 422 t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA)) 423 } 424 if size2 != size { 425 t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2) 426 } 427 size3 := github_com_gogo_protobuf_proto.Size(p) 428 if size3 != size { 429 t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3) 430 } 431} 432 433func BenchmarkCastawaySize(b *testing.B) { 434 popr := math_rand.New(math_rand.NewSource(616)) 435 total := 0 436 pops := make([]*Castaway, 1000) 437 for i := 0; i < 1000; i++ { 438 pops[i] = NewPopulatedCastaway(popr, false) 439 } 440 b.ResetTimer() 441 for i := 0; i < b.N; i++ { 442 total += pops[i%1000].Size() 443 } 444 b.SetBytes(int64(total / b.N)) 445} 446 447func TestWilsonSize(t *testing.T) { 448 seed := time.Now().UnixNano() 449 popr := math_rand.New(math_rand.NewSource(seed)) 450 p := NewPopulatedWilson(popr, true) 451 size2 := github_com_gogo_protobuf_proto.Size(p) 452 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 453 if err != nil { 454 t.Fatalf("seed = %d, err = %v", seed, err) 455 } 456 size := p.Size() 457 if len(dAtA) != size { 458 t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA)) 459 } 460 if size2 != size { 461 t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2) 462 } 463 size3 := github_com_gogo_protobuf_proto.Size(p) 464 if size3 != size { 465 t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3) 466 } 467} 468 469func BenchmarkWilsonSize(b *testing.B) { 470 popr := math_rand.New(math_rand.NewSource(616)) 471 total := 0 472 pops := make([]*Wilson, 1000) 473 for i := 0; i < 1000; i++ { 474 pops[i] = NewPopulatedWilson(popr, false) 475 } 476 b.ResetTimer() 477 for i := 0; i < b.N; i++ { 478 total += pops[i%1000].Size() 479 } 480 b.SetBytes(int64(total / b.N)) 481} 482 483func TestCastawayStringer(t *testing.T) { 484 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 485 p := NewPopulatedCastaway(popr, false) 486 s1 := p.String() 487 s2 := fmt.Sprintf("%v", p) 488 if s1 != s2 { 489 t.Fatalf("String want %v got %v", s1, s2) 490 } 491} 492func TestWilsonStringer(t *testing.T) { 493 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 494 p := NewPopulatedWilson(popr, false) 495 s1 := p.String() 496 s2 := fmt.Sprintf("%v", p) 497 if s1 != s2 { 498 t.Fatalf("String want %v got %v", s1, s2) 499 } 500} 501 502//These tests are generated by github.com/gogo/protobuf/plugin/testgen 503