1// Code generated by protoc-gen-gogo. DO NOT EDIT. 2// source: combos/neither/theproto3.proto 3 4package theproto3 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/combos/both" 13 go_parser "go/parser" 14 math "math" 15 math_rand "math/rand" 16 testing "testing" 17 time "time" 18) 19 20// Reference imports to suppress errors if they are not otherwise used. 21var _ = proto.Marshal 22var _ = fmt.Errorf 23var _ = math.Inf 24 25func TestMessageProto(t *testing.T) { 26 seed := time.Now().UnixNano() 27 popr := math_rand.New(math_rand.NewSource(seed)) 28 p := NewPopulatedMessage(popr, false) 29 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 30 if err != nil { 31 t.Fatalf("seed = %d, err = %v", seed, err) 32 } 33 msg := &Message{} 34 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 35 t.Fatalf("seed = %d, err = %v", seed, err) 36 } 37 littlefuzz := make([]byte, len(dAtA)) 38 copy(littlefuzz, dAtA) 39 for i := range dAtA { 40 dAtA[i] = byte(popr.Intn(256)) 41 } 42 if err := p.VerboseEqual(msg); err != nil { 43 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 44 } 45 if !p.Equal(msg) { 46 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 47 } 48 if len(littlefuzz) > 0 { 49 fuzzamount := 100 50 for i := 0; i < fuzzamount; i++ { 51 littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256)) 52 littlefuzz = append(littlefuzz, byte(popr.Intn(256))) 53 } 54 // shouldn't panic 55 _ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg) 56 } 57} 58 59func BenchmarkMessageProtoMarshal(b *testing.B) { 60 popr := math_rand.New(math_rand.NewSource(616)) 61 total := 0 62 pops := make([]*Message, 10000) 63 for i := 0; i < 10000; i++ { 64 pops[i] = NewPopulatedMessage(popr, false) 65 } 66 b.ResetTimer() 67 for i := 0; i < b.N; i++ { 68 dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000]) 69 if err != nil { 70 panic(err) 71 } 72 total += len(dAtA) 73 } 74 b.SetBytes(int64(total / b.N)) 75} 76 77func BenchmarkMessageProtoUnmarshal(b *testing.B) { 78 popr := math_rand.New(math_rand.NewSource(616)) 79 total := 0 80 datas := make([][]byte, 10000) 81 for i := 0; i < 10000; i++ { 82 dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedMessage(popr, false)) 83 if err != nil { 84 panic(err) 85 } 86 datas[i] = dAtA 87 } 88 msg := &Message{} 89 b.ResetTimer() 90 for i := 0; i < b.N; i++ { 91 total += len(datas[i%10000]) 92 if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil { 93 panic(err) 94 } 95 } 96 b.SetBytes(int64(total / b.N)) 97} 98 99func TestNestedProto(t *testing.T) { 100 seed := time.Now().UnixNano() 101 popr := math_rand.New(math_rand.NewSource(seed)) 102 p := NewPopulatedNested(popr, false) 103 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 104 if err != nil { 105 t.Fatalf("seed = %d, err = %v", seed, err) 106 } 107 msg := &Nested{} 108 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 109 t.Fatalf("seed = %d, err = %v", seed, err) 110 } 111 littlefuzz := make([]byte, len(dAtA)) 112 copy(littlefuzz, dAtA) 113 for i := range dAtA { 114 dAtA[i] = byte(popr.Intn(256)) 115 } 116 if err := p.VerboseEqual(msg); err != nil { 117 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 118 } 119 if !p.Equal(msg) { 120 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 121 } 122 if len(littlefuzz) > 0 { 123 fuzzamount := 100 124 for i := 0; i < fuzzamount; i++ { 125 littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256)) 126 littlefuzz = append(littlefuzz, byte(popr.Intn(256))) 127 } 128 // shouldn't panic 129 _ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg) 130 } 131} 132 133func BenchmarkNestedProtoMarshal(b *testing.B) { 134 popr := math_rand.New(math_rand.NewSource(616)) 135 total := 0 136 pops := make([]*Nested, 10000) 137 for i := 0; i < 10000; i++ { 138 pops[i] = NewPopulatedNested(popr, false) 139 } 140 b.ResetTimer() 141 for i := 0; i < b.N; i++ { 142 dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000]) 143 if err != nil { 144 panic(err) 145 } 146 total += len(dAtA) 147 } 148 b.SetBytes(int64(total / b.N)) 149} 150 151func BenchmarkNestedProtoUnmarshal(b *testing.B) { 152 popr := math_rand.New(math_rand.NewSource(616)) 153 total := 0 154 datas := make([][]byte, 10000) 155 for i := 0; i < 10000; i++ { 156 dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedNested(popr, false)) 157 if err != nil { 158 panic(err) 159 } 160 datas[i] = dAtA 161 } 162 msg := &Nested{} 163 b.ResetTimer() 164 for i := 0; i < b.N; i++ { 165 total += len(datas[i%10000]) 166 if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil { 167 panic(err) 168 } 169 } 170 b.SetBytes(int64(total / b.N)) 171} 172 173func TestAllMapsProto(t *testing.T) { 174 seed := time.Now().UnixNano() 175 popr := math_rand.New(math_rand.NewSource(seed)) 176 p := NewPopulatedAllMaps(popr, false) 177 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 178 if err != nil { 179 t.Fatalf("seed = %d, err = %v", seed, err) 180 } 181 msg := &AllMaps{} 182 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 183 t.Fatalf("seed = %d, err = %v", seed, err) 184 } 185 littlefuzz := make([]byte, len(dAtA)) 186 copy(littlefuzz, dAtA) 187 for i := range dAtA { 188 dAtA[i] = byte(popr.Intn(256)) 189 } 190 if err := p.VerboseEqual(msg); err != nil { 191 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 192 } 193 if !p.Equal(msg) { 194 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 195 } 196 if len(littlefuzz) > 0 { 197 fuzzamount := 100 198 for i := 0; i < fuzzamount; i++ { 199 littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256)) 200 littlefuzz = append(littlefuzz, byte(popr.Intn(256))) 201 } 202 // shouldn't panic 203 _ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg) 204 } 205} 206 207func BenchmarkAllMapsProtoMarshal(b *testing.B) { 208 popr := math_rand.New(math_rand.NewSource(616)) 209 total := 0 210 pops := make([]*AllMaps, 10000) 211 for i := 0; i < 10000; i++ { 212 pops[i] = NewPopulatedAllMaps(popr, false) 213 } 214 b.ResetTimer() 215 for i := 0; i < b.N; i++ { 216 dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000]) 217 if err != nil { 218 panic(err) 219 } 220 total += len(dAtA) 221 } 222 b.SetBytes(int64(total / b.N)) 223} 224 225func BenchmarkAllMapsProtoUnmarshal(b *testing.B) { 226 popr := math_rand.New(math_rand.NewSource(616)) 227 total := 0 228 datas := make([][]byte, 10000) 229 for i := 0; i < 10000; i++ { 230 dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedAllMaps(popr, false)) 231 if err != nil { 232 panic(err) 233 } 234 datas[i] = dAtA 235 } 236 msg := &AllMaps{} 237 b.ResetTimer() 238 for i := 0; i < b.N; i++ { 239 total += len(datas[i%10000]) 240 if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil { 241 panic(err) 242 } 243 } 244 b.SetBytes(int64(total / b.N)) 245} 246 247func TestAllMapsOrderedProto(t *testing.T) { 248 seed := time.Now().UnixNano() 249 popr := math_rand.New(math_rand.NewSource(seed)) 250 p := NewPopulatedAllMapsOrdered(popr, false) 251 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 252 if err != nil { 253 t.Fatalf("seed = %d, err = %v", seed, err) 254 } 255 msg := &AllMapsOrdered{} 256 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 257 t.Fatalf("seed = %d, err = %v", seed, err) 258 } 259 littlefuzz := make([]byte, len(dAtA)) 260 copy(littlefuzz, dAtA) 261 for i := range dAtA { 262 dAtA[i] = byte(popr.Intn(256)) 263 } 264 if err := p.VerboseEqual(msg); err != nil { 265 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 266 } 267 if !p.Equal(msg) { 268 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 269 } 270 if len(littlefuzz) > 0 { 271 fuzzamount := 100 272 for i := 0; i < fuzzamount; i++ { 273 littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256)) 274 littlefuzz = append(littlefuzz, byte(popr.Intn(256))) 275 } 276 // shouldn't panic 277 _ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg) 278 } 279} 280 281func BenchmarkAllMapsOrderedProtoMarshal(b *testing.B) { 282 popr := math_rand.New(math_rand.NewSource(616)) 283 total := 0 284 pops := make([]*AllMapsOrdered, 10000) 285 for i := 0; i < 10000; i++ { 286 pops[i] = NewPopulatedAllMapsOrdered(popr, false) 287 } 288 b.ResetTimer() 289 for i := 0; i < b.N; i++ { 290 dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000]) 291 if err != nil { 292 panic(err) 293 } 294 total += len(dAtA) 295 } 296 b.SetBytes(int64(total / b.N)) 297} 298 299func BenchmarkAllMapsOrderedProtoUnmarshal(b *testing.B) { 300 popr := math_rand.New(math_rand.NewSource(616)) 301 total := 0 302 datas := make([][]byte, 10000) 303 for i := 0; i < 10000; i++ { 304 dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedAllMapsOrdered(popr, false)) 305 if err != nil { 306 panic(err) 307 } 308 datas[i] = dAtA 309 } 310 msg := &AllMapsOrdered{} 311 b.ResetTimer() 312 for i := 0; i < b.N; i++ { 313 total += len(datas[i%10000]) 314 if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil { 315 panic(err) 316 } 317 } 318 b.SetBytes(int64(total / b.N)) 319} 320 321func TestMessageWithMapProto(t *testing.T) { 322 seed := time.Now().UnixNano() 323 popr := math_rand.New(math_rand.NewSource(seed)) 324 p := NewPopulatedMessageWithMap(popr, false) 325 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 326 if err != nil { 327 t.Fatalf("seed = %d, err = %v", seed, err) 328 } 329 msg := &MessageWithMap{} 330 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 331 t.Fatalf("seed = %d, err = %v", seed, err) 332 } 333 littlefuzz := make([]byte, len(dAtA)) 334 copy(littlefuzz, dAtA) 335 for i := range dAtA { 336 dAtA[i] = byte(popr.Intn(256)) 337 } 338 if err := p.VerboseEqual(msg); err != nil { 339 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 340 } 341 if !p.Equal(msg) { 342 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 343 } 344 if len(littlefuzz) > 0 { 345 fuzzamount := 100 346 for i := 0; i < fuzzamount; i++ { 347 littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256)) 348 littlefuzz = append(littlefuzz, byte(popr.Intn(256))) 349 } 350 // shouldn't panic 351 _ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg) 352 } 353} 354 355func BenchmarkMessageWithMapProtoMarshal(b *testing.B) { 356 popr := math_rand.New(math_rand.NewSource(616)) 357 total := 0 358 pops := make([]*MessageWithMap, 10000) 359 for i := 0; i < 10000; i++ { 360 pops[i] = NewPopulatedMessageWithMap(popr, false) 361 } 362 b.ResetTimer() 363 for i := 0; i < b.N; i++ { 364 dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000]) 365 if err != nil { 366 panic(err) 367 } 368 total += len(dAtA) 369 } 370 b.SetBytes(int64(total / b.N)) 371} 372 373func BenchmarkMessageWithMapProtoUnmarshal(b *testing.B) { 374 popr := math_rand.New(math_rand.NewSource(616)) 375 total := 0 376 datas := make([][]byte, 10000) 377 for i := 0; i < 10000; i++ { 378 dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedMessageWithMap(popr, false)) 379 if err != nil { 380 panic(err) 381 } 382 datas[i] = dAtA 383 } 384 msg := &MessageWithMap{} 385 b.ResetTimer() 386 for i := 0; i < b.N; i++ { 387 total += len(datas[i%10000]) 388 if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil { 389 panic(err) 390 } 391 } 392 b.SetBytes(int64(total / b.N)) 393} 394 395func TestFloatingPointProto(t *testing.T) { 396 seed := time.Now().UnixNano() 397 popr := math_rand.New(math_rand.NewSource(seed)) 398 p := NewPopulatedFloatingPoint(popr, false) 399 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 400 if err != nil { 401 t.Fatalf("seed = %d, err = %v", seed, err) 402 } 403 msg := &FloatingPoint{} 404 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 405 t.Fatalf("seed = %d, err = %v", seed, err) 406 } 407 littlefuzz := make([]byte, len(dAtA)) 408 copy(littlefuzz, dAtA) 409 for i := range dAtA { 410 dAtA[i] = byte(popr.Intn(256)) 411 } 412 if err := p.VerboseEqual(msg); err != nil { 413 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 414 } 415 if !p.Equal(msg) { 416 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 417 } 418 if len(littlefuzz) > 0 { 419 fuzzamount := 100 420 for i := 0; i < fuzzamount; i++ { 421 littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256)) 422 littlefuzz = append(littlefuzz, byte(popr.Intn(256))) 423 } 424 // shouldn't panic 425 _ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg) 426 } 427} 428 429func BenchmarkFloatingPointProtoMarshal(b *testing.B) { 430 popr := math_rand.New(math_rand.NewSource(616)) 431 total := 0 432 pops := make([]*FloatingPoint, 10000) 433 for i := 0; i < 10000; i++ { 434 pops[i] = NewPopulatedFloatingPoint(popr, false) 435 } 436 b.ResetTimer() 437 for i := 0; i < b.N; i++ { 438 dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000]) 439 if err != nil { 440 panic(err) 441 } 442 total += len(dAtA) 443 } 444 b.SetBytes(int64(total / b.N)) 445} 446 447func BenchmarkFloatingPointProtoUnmarshal(b *testing.B) { 448 popr := math_rand.New(math_rand.NewSource(616)) 449 total := 0 450 datas := make([][]byte, 10000) 451 for i := 0; i < 10000; i++ { 452 dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedFloatingPoint(popr, false)) 453 if err != nil { 454 panic(err) 455 } 456 datas[i] = dAtA 457 } 458 msg := &FloatingPoint{} 459 b.ResetTimer() 460 for i := 0; i < b.N; i++ { 461 total += len(datas[i%10000]) 462 if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil { 463 panic(err) 464 } 465 } 466 b.SetBytes(int64(total / b.N)) 467} 468 469func TestUint128PairProto(t *testing.T) { 470 seed := time.Now().UnixNano() 471 popr := math_rand.New(math_rand.NewSource(seed)) 472 p := NewPopulatedUint128Pair(popr, false) 473 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 474 if err != nil { 475 t.Fatalf("seed = %d, err = %v", seed, err) 476 } 477 msg := &Uint128Pair{} 478 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 479 t.Fatalf("seed = %d, err = %v", seed, err) 480 } 481 littlefuzz := make([]byte, len(dAtA)) 482 copy(littlefuzz, dAtA) 483 for i := range dAtA { 484 dAtA[i] = byte(popr.Intn(256)) 485 } 486 if err := p.VerboseEqual(msg); err != nil { 487 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 488 } 489 if !p.Equal(msg) { 490 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 491 } 492 if len(littlefuzz) > 0 { 493 fuzzamount := 100 494 for i := 0; i < fuzzamount; i++ { 495 littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256)) 496 littlefuzz = append(littlefuzz, byte(popr.Intn(256))) 497 } 498 // shouldn't panic 499 _ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg) 500 } 501} 502 503func BenchmarkUint128PairProtoMarshal(b *testing.B) { 504 popr := math_rand.New(math_rand.NewSource(616)) 505 total := 0 506 pops := make([]*Uint128Pair, 10000) 507 for i := 0; i < 10000; i++ { 508 pops[i] = NewPopulatedUint128Pair(popr, false) 509 } 510 b.ResetTimer() 511 for i := 0; i < b.N; i++ { 512 dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000]) 513 if err != nil { 514 panic(err) 515 } 516 total += len(dAtA) 517 } 518 b.SetBytes(int64(total / b.N)) 519} 520 521func BenchmarkUint128PairProtoUnmarshal(b *testing.B) { 522 popr := math_rand.New(math_rand.NewSource(616)) 523 total := 0 524 datas := make([][]byte, 10000) 525 for i := 0; i < 10000; i++ { 526 dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedUint128Pair(popr, false)) 527 if err != nil { 528 panic(err) 529 } 530 datas[i] = dAtA 531 } 532 msg := &Uint128Pair{} 533 b.ResetTimer() 534 for i := 0; i < b.N; i++ { 535 total += len(datas[i%10000]) 536 if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil { 537 panic(err) 538 } 539 } 540 b.SetBytes(int64(total / b.N)) 541} 542 543func TestContainsNestedMapProto(t *testing.T) { 544 seed := time.Now().UnixNano() 545 popr := math_rand.New(math_rand.NewSource(seed)) 546 p := NewPopulatedContainsNestedMap(popr, false) 547 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 548 if err != nil { 549 t.Fatalf("seed = %d, err = %v", seed, err) 550 } 551 msg := &ContainsNestedMap{} 552 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 553 t.Fatalf("seed = %d, err = %v", seed, err) 554 } 555 littlefuzz := make([]byte, len(dAtA)) 556 copy(littlefuzz, dAtA) 557 for i := range dAtA { 558 dAtA[i] = byte(popr.Intn(256)) 559 } 560 if err := p.VerboseEqual(msg); err != nil { 561 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 562 } 563 if !p.Equal(msg) { 564 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 565 } 566 if len(littlefuzz) > 0 { 567 fuzzamount := 100 568 for i := 0; i < fuzzamount; i++ { 569 littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256)) 570 littlefuzz = append(littlefuzz, byte(popr.Intn(256))) 571 } 572 // shouldn't panic 573 _ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg) 574 } 575} 576 577func BenchmarkContainsNestedMapProtoMarshal(b *testing.B) { 578 popr := math_rand.New(math_rand.NewSource(616)) 579 total := 0 580 pops := make([]*ContainsNestedMap, 10000) 581 for i := 0; i < 10000; i++ { 582 pops[i] = NewPopulatedContainsNestedMap(popr, false) 583 } 584 b.ResetTimer() 585 for i := 0; i < b.N; i++ { 586 dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000]) 587 if err != nil { 588 panic(err) 589 } 590 total += len(dAtA) 591 } 592 b.SetBytes(int64(total / b.N)) 593} 594 595func BenchmarkContainsNestedMapProtoUnmarshal(b *testing.B) { 596 popr := math_rand.New(math_rand.NewSource(616)) 597 total := 0 598 datas := make([][]byte, 10000) 599 for i := 0; i < 10000; i++ { 600 dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedContainsNestedMap(popr, false)) 601 if err != nil { 602 panic(err) 603 } 604 datas[i] = dAtA 605 } 606 msg := &ContainsNestedMap{} 607 b.ResetTimer() 608 for i := 0; i < b.N; i++ { 609 total += len(datas[i%10000]) 610 if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil { 611 panic(err) 612 } 613 } 614 b.SetBytes(int64(total / b.N)) 615} 616 617func TestContainsNestedMap_NestedMapProto(t *testing.T) { 618 seed := time.Now().UnixNano() 619 popr := math_rand.New(math_rand.NewSource(seed)) 620 p := NewPopulatedContainsNestedMap_NestedMap(popr, false) 621 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 622 if err != nil { 623 t.Fatalf("seed = %d, err = %v", seed, err) 624 } 625 msg := &ContainsNestedMap_NestedMap{} 626 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 627 t.Fatalf("seed = %d, err = %v", seed, err) 628 } 629 littlefuzz := make([]byte, len(dAtA)) 630 copy(littlefuzz, dAtA) 631 for i := range dAtA { 632 dAtA[i] = byte(popr.Intn(256)) 633 } 634 if err := p.VerboseEqual(msg); err != nil { 635 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 636 } 637 if !p.Equal(msg) { 638 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 639 } 640 if len(littlefuzz) > 0 { 641 fuzzamount := 100 642 for i := 0; i < fuzzamount; i++ { 643 littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256)) 644 littlefuzz = append(littlefuzz, byte(popr.Intn(256))) 645 } 646 // shouldn't panic 647 _ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg) 648 } 649} 650 651func BenchmarkContainsNestedMap_NestedMapProtoMarshal(b *testing.B) { 652 popr := math_rand.New(math_rand.NewSource(616)) 653 total := 0 654 pops := make([]*ContainsNestedMap_NestedMap, 10000) 655 for i := 0; i < 10000; i++ { 656 pops[i] = NewPopulatedContainsNestedMap_NestedMap(popr, false) 657 } 658 b.ResetTimer() 659 for i := 0; i < b.N; i++ { 660 dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000]) 661 if err != nil { 662 panic(err) 663 } 664 total += len(dAtA) 665 } 666 b.SetBytes(int64(total / b.N)) 667} 668 669func BenchmarkContainsNestedMap_NestedMapProtoUnmarshal(b *testing.B) { 670 popr := math_rand.New(math_rand.NewSource(616)) 671 total := 0 672 datas := make([][]byte, 10000) 673 for i := 0; i < 10000; i++ { 674 dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedContainsNestedMap_NestedMap(popr, false)) 675 if err != nil { 676 panic(err) 677 } 678 datas[i] = dAtA 679 } 680 msg := &ContainsNestedMap_NestedMap{} 681 b.ResetTimer() 682 for i := 0; i < b.N; i++ { 683 total += len(datas[i%10000]) 684 if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil { 685 panic(err) 686 } 687 } 688 b.SetBytes(int64(total / b.N)) 689} 690 691func TestNotPackedProto(t *testing.T) { 692 seed := time.Now().UnixNano() 693 popr := math_rand.New(math_rand.NewSource(seed)) 694 p := NewPopulatedNotPacked(popr, false) 695 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 696 if err != nil { 697 t.Fatalf("seed = %d, err = %v", seed, err) 698 } 699 msg := &NotPacked{} 700 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 701 t.Fatalf("seed = %d, err = %v", seed, err) 702 } 703 littlefuzz := make([]byte, len(dAtA)) 704 copy(littlefuzz, dAtA) 705 for i := range dAtA { 706 dAtA[i] = byte(popr.Intn(256)) 707 } 708 if err := p.VerboseEqual(msg); err != nil { 709 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 710 } 711 if !p.Equal(msg) { 712 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 713 } 714 if len(littlefuzz) > 0 { 715 fuzzamount := 100 716 for i := 0; i < fuzzamount; i++ { 717 littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256)) 718 littlefuzz = append(littlefuzz, byte(popr.Intn(256))) 719 } 720 // shouldn't panic 721 _ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg) 722 } 723} 724 725func BenchmarkNotPackedProtoMarshal(b *testing.B) { 726 popr := math_rand.New(math_rand.NewSource(616)) 727 total := 0 728 pops := make([]*NotPacked, 10000) 729 for i := 0; i < 10000; i++ { 730 pops[i] = NewPopulatedNotPacked(popr, false) 731 } 732 b.ResetTimer() 733 for i := 0; i < b.N; i++ { 734 dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000]) 735 if err != nil { 736 panic(err) 737 } 738 total += len(dAtA) 739 } 740 b.SetBytes(int64(total / b.N)) 741} 742 743func BenchmarkNotPackedProtoUnmarshal(b *testing.B) { 744 popr := math_rand.New(math_rand.NewSource(616)) 745 total := 0 746 datas := make([][]byte, 10000) 747 for i := 0; i < 10000; i++ { 748 dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedNotPacked(popr, false)) 749 if err != nil { 750 panic(err) 751 } 752 datas[i] = dAtA 753 } 754 msg := &NotPacked{} 755 b.ResetTimer() 756 for i := 0; i < b.N; i++ { 757 total += len(datas[i%10000]) 758 if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil { 759 panic(err) 760 } 761 } 762 b.SetBytes(int64(total / b.N)) 763} 764 765func TestMessageJSON(t *testing.T) { 766 seed := time.Now().UnixNano() 767 popr := math_rand.New(math_rand.NewSource(seed)) 768 p := NewPopulatedMessage(popr, true) 769 marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{} 770 jsondata, err := marshaler.MarshalToString(p) 771 if err != nil { 772 t.Fatalf("seed = %d, err = %v", seed, err) 773 } 774 msg := &Message{} 775 err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg) 776 if err != nil { 777 t.Fatalf("seed = %d, err = %v", seed, err) 778 } 779 if err := p.VerboseEqual(msg); err != nil { 780 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 781 } 782 if !p.Equal(msg) { 783 t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p) 784 } 785} 786func TestNestedJSON(t *testing.T) { 787 seed := time.Now().UnixNano() 788 popr := math_rand.New(math_rand.NewSource(seed)) 789 p := NewPopulatedNested(popr, true) 790 marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{} 791 jsondata, err := marshaler.MarshalToString(p) 792 if err != nil { 793 t.Fatalf("seed = %d, err = %v", seed, err) 794 } 795 msg := &Nested{} 796 err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg) 797 if err != nil { 798 t.Fatalf("seed = %d, err = %v", seed, err) 799 } 800 if err := p.VerboseEqual(msg); err != nil { 801 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 802 } 803 if !p.Equal(msg) { 804 t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p) 805 } 806} 807func TestAllMapsJSON(t *testing.T) { 808 seed := time.Now().UnixNano() 809 popr := math_rand.New(math_rand.NewSource(seed)) 810 p := NewPopulatedAllMaps(popr, true) 811 marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{} 812 jsondata, err := marshaler.MarshalToString(p) 813 if err != nil { 814 t.Fatalf("seed = %d, err = %v", seed, err) 815 } 816 msg := &AllMaps{} 817 err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg) 818 if err != nil { 819 t.Fatalf("seed = %d, err = %v", seed, err) 820 } 821 if err := p.VerboseEqual(msg); err != nil { 822 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 823 } 824 if !p.Equal(msg) { 825 t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p) 826 } 827} 828func TestAllMapsOrderedJSON(t *testing.T) { 829 seed := time.Now().UnixNano() 830 popr := math_rand.New(math_rand.NewSource(seed)) 831 p := NewPopulatedAllMapsOrdered(popr, true) 832 marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{} 833 jsondata, err := marshaler.MarshalToString(p) 834 if err != nil { 835 t.Fatalf("seed = %d, err = %v", seed, err) 836 } 837 msg := &AllMapsOrdered{} 838 err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg) 839 if err != nil { 840 t.Fatalf("seed = %d, err = %v", seed, err) 841 } 842 if err := p.VerboseEqual(msg); err != nil { 843 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 844 } 845 if !p.Equal(msg) { 846 t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p) 847 } 848} 849func TestMessageWithMapJSON(t *testing.T) { 850 seed := time.Now().UnixNano() 851 popr := math_rand.New(math_rand.NewSource(seed)) 852 p := NewPopulatedMessageWithMap(popr, true) 853 marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{} 854 jsondata, err := marshaler.MarshalToString(p) 855 if err != nil { 856 t.Fatalf("seed = %d, err = %v", seed, err) 857 } 858 msg := &MessageWithMap{} 859 err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg) 860 if err != nil { 861 t.Fatalf("seed = %d, err = %v", seed, err) 862 } 863 if err := p.VerboseEqual(msg); err != nil { 864 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 865 } 866 if !p.Equal(msg) { 867 t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p) 868 } 869} 870func TestFloatingPointJSON(t *testing.T) { 871 seed := time.Now().UnixNano() 872 popr := math_rand.New(math_rand.NewSource(seed)) 873 p := NewPopulatedFloatingPoint(popr, true) 874 marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{} 875 jsondata, err := marshaler.MarshalToString(p) 876 if err != nil { 877 t.Fatalf("seed = %d, err = %v", seed, err) 878 } 879 msg := &FloatingPoint{} 880 err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg) 881 if err != nil { 882 t.Fatalf("seed = %d, err = %v", seed, err) 883 } 884 if err := p.VerboseEqual(msg); err != nil { 885 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 886 } 887 if !p.Equal(msg) { 888 t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p) 889 } 890} 891func TestUint128PairJSON(t *testing.T) { 892 seed := time.Now().UnixNano() 893 popr := math_rand.New(math_rand.NewSource(seed)) 894 p := NewPopulatedUint128Pair(popr, true) 895 marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{} 896 jsondata, err := marshaler.MarshalToString(p) 897 if err != nil { 898 t.Fatalf("seed = %d, err = %v", seed, err) 899 } 900 msg := &Uint128Pair{} 901 err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg) 902 if err != nil { 903 t.Fatalf("seed = %d, err = %v", seed, err) 904 } 905 if err := p.VerboseEqual(msg); err != nil { 906 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 907 } 908 if !p.Equal(msg) { 909 t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p) 910 } 911} 912func TestContainsNestedMapJSON(t *testing.T) { 913 seed := time.Now().UnixNano() 914 popr := math_rand.New(math_rand.NewSource(seed)) 915 p := NewPopulatedContainsNestedMap(popr, true) 916 marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{} 917 jsondata, err := marshaler.MarshalToString(p) 918 if err != nil { 919 t.Fatalf("seed = %d, err = %v", seed, err) 920 } 921 msg := &ContainsNestedMap{} 922 err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg) 923 if err != nil { 924 t.Fatalf("seed = %d, err = %v", seed, err) 925 } 926 if err := p.VerboseEqual(msg); err != nil { 927 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 928 } 929 if !p.Equal(msg) { 930 t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p) 931 } 932} 933func TestContainsNestedMap_NestedMapJSON(t *testing.T) { 934 seed := time.Now().UnixNano() 935 popr := math_rand.New(math_rand.NewSource(seed)) 936 p := NewPopulatedContainsNestedMap_NestedMap(popr, true) 937 marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{} 938 jsondata, err := marshaler.MarshalToString(p) 939 if err != nil { 940 t.Fatalf("seed = %d, err = %v", seed, err) 941 } 942 msg := &ContainsNestedMap_NestedMap{} 943 err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg) 944 if err != nil { 945 t.Fatalf("seed = %d, err = %v", seed, err) 946 } 947 if err := p.VerboseEqual(msg); err != nil { 948 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 949 } 950 if !p.Equal(msg) { 951 t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p) 952 } 953} 954func TestNotPackedJSON(t *testing.T) { 955 seed := time.Now().UnixNano() 956 popr := math_rand.New(math_rand.NewSource(seed)) 957 p := NewPopulatedNotPacked(popr, true) 958 marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{} 959 jsondata, err := marshaler.MarshalToString(p) 960 if err != nil { 961 t.Fatalf("seed = %d, err = %v", seed, err) 962 } 963 msg := &NotPacked{} 964 err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg) 965 if err != nil { 966 t.Fatalf("seed = %d, err = %v", seed, err) 967 } 968 if err := p.VerboseEqual(msg); err != nil { 969 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 970 } 971 if !p.Equal(msg) { 972 t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p) 973 } 974} 975func TestMessageProtoText(t *testing.T) { 976 seed := time.Now().UnixNano() 977 popr := math_rand.New(math_rand.NewSource(seed)) 978 p := NewPopulatedMessage(popr, true) 979 dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p) 980 msg := &Message{} 981 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 982 t.Fatalf("seed = %d, err = %v", seed, err) 983 } 984 if err := p.VerboseEqual(msg); err != nil { 985 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 986 } 987 if !p.Equal(msg) { 988 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 989 } 990} 991 992func TestMessageProtoCompactText(t *testing.T) { 993 seed := time.Now().UnixNano() 994 popr := math_rand.New(math_rand.NewSource(seed)) 995 p := NewPopulatedMessage(popr, true) 996 dAtA := github_com_gogo_protobuf_proto.CompactTextString(p) 997 msg := &Message{} 998 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 999 t.Fatalf("seed = %d, err = %v", seed, err) 1000 } 1001 if err := p.VerboseEqual(msg); err != nil { 1002 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 1003 } 1004 if !p.Equal(msg) { 1005 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 1006 } 1007} 1008 1009func TestNestedProtoText(t *testing.T) { 1010 seed := time.Now().UnixNano() 1011 popr := math_rand.New(math_rand.NewSource(seed)) 1012 p := NewPopulatedNested(popr, true) 1013 dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p) 1014 msg := &Nested{} 1015 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 1016 t.Fatalf("seed = %d, err = %v", seed, err) 1017 } 1018 if err := p.VerboseEqual(msg); err != nil { 1019 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 1020 } 1021 if !p.Equal(msg) { 1022 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 1023 } 1024} 1025 1026func TestNestedProtoCompactText(t *testing.T) { 1027 seed := time.Now().UnixNano() 1028 popr := math_rand.New(math_rand.NewSource(seed)) 1029 p := NewPopulatedNested(popr, true) 1030 dAtA := github_com_gogo_protobuf_proto.CompactTextString(p) 1031 msg := &Nested{} 1032 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 1033 t.Fatalf("seed = %d, err = %v", seed, err) 1034 } 1035 if err := p.VerboseEqual(msg); err != nil { 1036 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 1037 } 1038 if !p.Equal(msg) { 1039 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 1040 } 1041} 1042 1043func TestAllMapsProtoText(t *testing.T) { 1044 seed := time.Now().UnixNano() 1045 popr := math_rand.New(math_rand.NewSource(seed)) 1046 p := NewPopulatedAllMaps(popr, true) 1047 dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p) 1048 msg := &AllMaps{} 1049 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 1050 t.Fatalf("seed = %d, err = %v", seed, err) 1051 } 1052 if err := p.VerboseEqual(msg); err != nil { 1053 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 1054 } 1055 if !p.Equal(msg) { 1056 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 1057 } 1058} 1059 1060func TestAllMapsProtoCompactText(t *testing.T) { 1061 seed := time.Now().UnixNano() 1062 popr := math_rand.New(math_rand.NewSource(seed)) 1063 p := NewPopulatedAllMaps(popr, true) 1064 dAtA := github_com_gogo_protobuf_proto.CompactTextString(p) 1065 msg := &AllMaps{} 1066 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 1067 t.Fatalf("seed = %d, err = %v", seed, err) 1068 } 1069 if err := p.VerboseEqual(msg); err != nil { 1070 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 1071 } 1072 if !p.Equal(msg) { 1073 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 1074 } 1075} 1076 1077func TestAllMapsOrderedProtoText(t *testing.T) { 1078 seed := time.Now().UnixNano() 1079 popr := math_rand.New(math_rand.NewSource(seed)) 1080 p := NewPopulatedAllMapsOrdered(popr, true) 1081 dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p) 1082 msg := &AllMapsOrdered{} 1083 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 1084 t.Fatalf("seed = %d, err = %v", seed, err) 1085 } 1086 if err := p.VerboseEqual(msg); err != nil { 1087 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 1088 } 1089 if !p.Equal(msg) { 1090 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 1091 } 1092} 1093 1094func TestAllMapsOrderedProtoCompactText(t *testing.T) { 1095 seed := time.Now().UnixNano() 1096 popr := math_rand.New(math_rand.NewSource(seed)) 1097 p := NewPopulatedAllMapsOrdered(popr, true) 1098 dAtA := github_com_gogo_protobuf_proto.CompactTextString(p) 1099 msg := &AllMapsOrdered{} 1100 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 1101 t.Fatalf("seed = %d, err = %v", seed, err) 1102 } 1103 if err := p.VerboseEqual(msg); err != nil { 1104 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 1105 } 1106 if !p.Equal(msg) { 1107 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 1108 } 1109} 1110 1111func TestMessageWithMapProtoText(t *testing.T) { 1112 seed := time.Now().UnixNano() 1113 popr := math_rand.New(math_rand.NewSource(seed)) 1114 p := NewPopulatedMessageWithMap(popr, true) 1115 dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p) 1116 msg := &MessageWithMap{} 1117 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 1118 t.Fatalf("seed = %d, err = %v", seed, err) 1119 } 1120 if err := p.VerboseEqual(msg); err != nil { 1121 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 1122 } 1123 if !p.Equal(msg) { 1124 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 1125 } 1126} 1127 1128func TestMessageWithMapProtoCompactText(t *testing.T) { 1129 seed := time.Now().UnixNano() 1130 popr := math_rand.New(math_rand.NewSource(seed)) 1131 p := NewPopulatedMessageWithMap(popr, true) 1132 dAtA := github_com_gogo_protobuf_proto.CompactTextString(p) 1133 msg := &MessageWithMap{} 1134 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 1135 t.Fatalf("seed = %d, err = %v", seed, err) 1136 } 1137 if err := p.VerboseEqual(msg); err != nil { 1138 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 1139 } 1140 if !p.Equal(msg) { 1141 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 1142 } 1143} 1144 1145func TestFloatingPointProtoText(t *testing.T) { 1146 seed := time.Now().UnixNano() 1147 popr := math_rand.New(math_rand.NewSource(seed)) 1148 p := NewPopulatedFloatingPoint(popr, true) 1149 dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p) 1150 msg := &FloatingPoint{} 1151 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 1152 t.Fatalf("seed = %d, err = %v", seed, err) 1153 } 1154 if err := p.VerboseEqual(msg); err != nil { 1155 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 1156 } 1157 if !p.Equal(msg) { 1158 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 1159 } 1160} 1161 1162func TestFloatingPointProtoCompactText(t *testing.T) { 1163 seed := time.Now().UnixNano() 1164 popr := math_rand.New(math_rand.NewSource(seed)) 1165 p := NewPopulatedFloatingPoint(popr, true) 1166 dAtA := github_com_gogo_protobuf_proto.CompactTextString(p) 1167 msg := &FloatingPoint{} 1168 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 1169 t.Fatalf("seed = %d, err = %v", seed, err) 1170 } 1171 if err := p.VerboseEqual(msg); err != nil { 1172 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 1173 } 1174 if !p.Equal(msg) { 1175 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 1176 } 1177} 1178 1179func TestUint128PairProtoText(t *testing.T) { 1180 seed := time.Now().UnixNano() 1181 popr := math_rand.New(math_rand.NewSource(seed)) 1182 p := NewPopulatedUint128Pair(popr, true) 1183 dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p) 1184 msg := &Uint128Pair{} 1185 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 1186 t.Fatalf("seed = %d, err = %v", seed, err) 1187 } 1188 if err := p.VerboseEqual(msg); err != nil { 1189 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 1190 } 1191 if !p.Equal(msg) { 1192 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 1193 } 1194} 1195 1196func TestUint128PairProtoCompactText(t *testing.T) { 1197 seed := time.Now().UnixNano() 1198 popr := math_rand.New(math_rand.NewSource(seed)) 1199 p := NewPopulatedUint128Pair(popr, true) 1200 dAtA := github_com_gogo_protobuf_proto.CompactTextString(p) 1201 msg := &Uint128Pair{} 1202 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 1203 t.Fatalf("seed = %d, err = %v", seed, err) 1204 } 1205 if err := p.VerboseEqual(msg); err != nil { 1206 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 1207 } 1208 if !p.Equal(msg) { 1209 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 1210 } 1211} 1212 1213func TestContainsNestedMapProtoText(t *testing.T) { 1214 seed := time.Now().UnixNano() 1215 popr := math_rand.New(math_rand.NewSource(seed)) 1216 p := NewPopulatedContainsNestedMap(popr, true) 1217 dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p) 1218 msg := &ContainsNestedMap{} 1219 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 1220 t.Fatalf("seed = %d, err = %v", seed, err) 1221 } 1222 if err := p.VerboseEqual(msg); err != nil { 1223 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 1224 } 1225 if !p.Equal(msg) { 1226 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 1227 } 1228} 1229 1230func TestContainsNestedMapProtoCompactText(t *testing.T) { 1231 seed := time.Now().UnixNano() 1232 popr := math_rand.New(math_rand.NewSource(seed)) 1233 p := NewPopulatedContainsNestedMap(popr, true) 1234 dAtA := github_com_gogo_protobuf_proto.CompactTextString(p) 1235 msg := &ContainsNestedMap{} 1236 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 1237 t.Fatalf("seed = %d, err = %v", seed, err) 1238 } 1239 if err := p.VerboseEqual(msg); err != nil { 1240 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 1241 } 1242 if !p.Equal(msg) { 1243 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 1244 } 1245} 1246 1247func TestContainsNestedMap_NestedMapProtoText(t *testing.T) { 1248 seed := time.Now().UnixNano() 1249 popr := math_rand.New(math_rand.NewSource(seed)) 1250 p := NewPopulatedContainsNestedMap_NestedMap(popr, true) 1251 dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p) 1252 msg := &ContainsNestedMap_NestedMap{} 1253 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 1254 t.Fatalf("seed = %d, err = %v", seed, err) 1255 } 1256 if err := p.VerboseEqual(msg); err != nil { 1257 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 1258 } 1259 if !p.Equal(msg) { 1260 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 1261 } 1262} 1263 1264func TestContainsNestedMap_NestedMapProtoCompactText(t *testing.T) { 1265 seed := time.Now().UnixNano() 1266 popr := math_rand.New(math_rand.NewSource(seed)) 1267 p := NewPopulatedContainsNestedMap_NestedMap(popr, true) 1268 dAtA := github_com_gogo_protobuf_proto.CompactTextString(p) 1269 msg := &ContainsNestedMap_NestedMap{} 1270 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 1271 t.Fatalf("seed = %d, err = %v", seed, err) 1272 } 1273 if err := p.VerboseEqual(msg); err != nil { 1274 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 1275 } 1276 if !p.Equal(msg) { 1277 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 1278 } 1279} 1280 1281func TestNotPackedProtoText(t *testing.T) { 1282 seed := time.Now().UnixNano() 1283 popr := math_rand.New(math_rand.NewSource(seed)) 1284 p := NewPopulatedNotPacked(popr, true) 1285 dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p) 1286 msg := &NotPacked{} 1287 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 1288 t.Fatalf("seed = %d, err = %v", seed, err) 1289 } 1290 if err := p.VerboseEqual(msg); err != nil { 1291 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 1292 } 1293 if !p.Equal(msg) { 1294 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 1295 } 1296} 1297 1298func TestNotPackedProtoCompactText(t *testing.T) { 1299 seed := time.Now().UnixNano() 1300 popr := math_rand.New(math_rand.NewSource(seed)) 1301 p := NewPopulatedNotPacked(popr, true) 1302 dAtA := github_com_gogo_protobuf_proto.CompactTextString(p) 1303 msg := &NotPacked{} 1304 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 1305 t.Fatalf("seed = %d, err = %v", seed, err) 1306 } 1307 if err := p.VerboseEqual(msg); err != nil { 1308 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 1309 } 1310 if !p.Equal(msg) { 1311 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 1312 } 1313} 1314 1315func TestTheproto3Description(t *testing.T) { 1316 Theproto3Description() 1317} 1318func TestMessageVerboseEqual(t *testing.T) { 1319 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1320 p := NewPopulatedMessage(popr, false) 1321 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 1322 if err != nil { 1323 panic(err) 1324 } 1325 msg := &Message{} 1326 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 1327 panic(err) 1328 } 1329 if err := p.VerboseEqual(msg); err != nil { 1330 t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err) 1331 } 1332} 1333func TestNestedVerboseEqual(t *testing.T) { 1334 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1335 p := NewPopulatedNested(popr, false) 1336 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 1337 if err != nil { 1338 panic(err) 1339 } 1340 msg := &Nested{} 1341 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 1342 panic(err) 1343 } 1344 if err := p.VerboseEqual(msg); err != nil { 1345 t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err) 1346 } 1347} 1348func TestAllMapsVerboseEqual(t *testing.T) { 1349 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1350 p := NewPopulatedAllMaps(popr, false) 1351 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 1352 if err != nil { 1353 panic(err) 1354 } 1355 msg := &AllMaps{} 1356 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 1357 panic(err) 1358 } 1359 if err := p.VerboseEqual(msg); err != nil { 1360 t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err) 1361 } 1362} 1363func TestAllMapsOrderedVerboseEqual(t *testing.T) { 1364 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1365 p := NewPopulatedAllMapsOrdered(popr, false) 1366 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 1367 if err != nil { 1368 panic(err) 1369 } 1370 msg := &AllMapsOrdered{} 1371 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 1372 panic(err) 1373 } 1374 if err := p.VerboseEqual(msg); err != nil { 1375 t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err) 1376 } 1377} 1378func TestMessageWithMapVerboseEqual(t *testing.T) { 1379 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1380 p := NewPopulatedMessageWithMap(popr, false) 1381 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 1382 if err != nil { 1383 panic(err) 1384 } 1385 msg := &MessageWithMap{} 1386 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 1387 panic(err) 1388 } 1389 if err := p.VerboseEqual(msg); err != nil { 1390 t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err) 1391 } 1392} 1393func TestFloatingPointVerboseEqual(t *testing.T) { 1394 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1395 p := NewPopulatedFloatingPoint(popr, false) 1396 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 1397 if err != nil { 1398 panic(err) 1399 } 1400 msg := &FloatingPoint{} 1401 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 1402 panic(err) 1403 } 1404 if err := p.VerboseEqual(msg); err != nil { 1405 t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err) 1406 } 1407} 1408func TestUint128PairVerboseEqual(t *testing.T) { 1409 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1410 p := NewPopulatedUint128Pair(popr, false) 1411 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 1412 if err != nil { 1413 panic(err) 1414 } 1415 msg := &Uint128Pair{} 1416 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 1417 panic(err) 1418 } 1419 if err := p.VerboseEqual(msg); err != nil { 1420 t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err) 1421 } 1422} 1423func TestContainsNestedMapVerboseEqual(t *testing.T) { 1424 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1425 p := NewPopulatedContainsNestedMap(popr, false) 1426 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 1427 if err != nil { 1428 panic(err) 1429 } 1430 msg := &ContainsNestedMap{} 1431 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 1432 panic(err) 1433 } 1434 if err := p.VerboseEqual(msg); err != nil { 1435 t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err) 1436 } 1437} 1438func TestContainsNestedMap_NestedMapVerboseEqual(t *testing.T) { 1439 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1440 p := NewPopulatedContainsNestedMap_NestedMap(popr, false) 1441 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 1442 if err != nil { 1443 panic(err) 1444 } 1445 msg := &ContainsNestedMap_NestedMap{} 1446 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 1447 panic(err) 1448 } 1449 if err := p.VerboseEqual(msg); err != nil { 1450 t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err) 1451 } 1452} 1453func TestNotPackedVerboseEqual(t *testing.T) { 1454 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1455 p := NewPopulatedNotPacked(popr, false) 1456 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 1457 if err != nil { 1458 panic(err) 1459 } 1460 msg := &NotPacked{} 1461 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 1462 panic(err) 1463 } 1464 if err := p.VerboseEqual(msg); err != nil { 1465 t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err) 1466 } 1467} 1468func TestMessageFace(t *testing.T) { 1469 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1470 p := NewPopulatedMessage(popr, true) 1471 msg := p.TestProto() 1472 if !p.Equal(msg) { 1473 t.Fatalf("%#v !Face Equal %#v", msg, p) 1474 } 1475} 1476func TestNestedFace(t *testing.T) { 1477 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1478 p := NewPopulatedNested(popr, true) 1479 msg := p.TestProto() 1480 if !p.Equal(msg) { 1481 t.Fatalf("%#v !Face Equal %#v", msg, p) 1482 } 1483} 1484func TestAllMapsFace(t *testing.T) { 1485 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1486 p := NewPopulatedAllMaps(popr, true) 1487 msg := p.TestProto() 1488 if !p.Equal(msg) { 1489 t.Fatalf("%#v !Face Equal %#v", msg, p) 1490 } 1491} 1492func TestAllMapsOrderedFace(t *testing.T) { 1493 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1494 p := NewPopulatedAllMapsOrdered(popr, true) 1495 msg := p.TestProto() 1496 if !p.Equal(msg) { 1497 t.Fatalf("%#v !Face Equal %#v", msg, p) 1498 } 1499} 1500func TestMessageWithMapFace(t *testing.T) { 1501 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1502 p := NewPopulatedMessageWithMap(popr, true) 1503 msg := p.TestProto() 1504 if !p.Equal(msg) { 1505 t.Fatalf("%#v !Face Equal %#v", msg, p) 1506 } 1507} 1508func TestFloatingPointFace(t *testing.T) { 1509 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1510 p := NewPopulatedFloatingPoint(popr, true) 1511 msg := p.TestProto() 1512 if !p.Equal(msg) { 1513 t.Fatalf("%#v !Face Equal %#v", msg, p) 1514 } 1515} 1516func TestUint128PairFace(t *testing.T) { 1517 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1518 p := NewPopulatedUint128Pair(popr, true) 1519 msg := p.TestProto() 1520 if !p.Equal(msg) { 1521 t.Fatalf("%#v !Face Equal %#v", msg, p) 1522 } 1523} 1524func TestContainsNestedMapFace(t *testing.T) { 1525 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1526 p := NewPopulatedContainsNestedMap(popr, true) 1527 msg := p.TestProto() 1528 if !p.Equal(msg) { 1529 t.Fatalf("%#v !Face Equal %#v", msg, p) 1530 } 1531} 1532func TestContainsNestedMap_NestedMapFace(t *testing.T) { 1533 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1534 p := NewPopulatedContainsNestedMap_NestedMap(popr, true) 1535 msg := p.TestProto() 1536 if !p.Equal(msg) { 1537 t.Fatalf("%#v !Face Equal %#v", msg, p) 1538 } 1539} 1540func TestNotPackedFace(t *testing.T) { 1541 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1542 p := NewPopulatedNotPacked(popr, true) 1543 msg := p.TestProto() 1544 if !p.Equal(msg) { 1545 t.Fatalf("%#v !Face Equal %#v", msg, p) 1546 } 1547} 1548func TestMessageGoString(t *testing.T) { 1549 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1550 p := NewPopulatedMessage(popr, false) 1551 s1 := p.GoString() 1552 s2 := fmt.Sprintf("%#v", p) 1553 if s1 != s2 { 1554 t.Fatalf("GoString want %v got %v", s1, s2) 1555 } 1556 _, err := go_parser.ParseExpr(s1) 1557 if err != nil { 1558 t.Fatal(err) 1559 } 1560} 1561func TestNestedGoString(t *testing.T) { 1562 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1563 p := NewPopulatedNested(popr, false) 1564 s1 := p.GoString() 1565 s2 := fmt.Sprintf("%#v", p) 1566 if s1 != s2 { 1567 t.Fatalf("GoString want %v got %v", s1, s2) 1568 } 1569 _, err := go_parser.ParseExpr(s1) 1570 if err != nil { 1571 t.Fatal(err) 1572 } 1573} 1574func TestAllMapsGoString(t *testing.T) { 1575 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1576 p := NewPopulatedAllMaps(popr, false) 1577 s1 := p.GoString() 1578 s2 := fmt.Sprintf("%#v", p) 1579 if s1 != s2 { 1580 t.Fatalf("GoString want %v got %v", s1, s2) 1581 } 1582 _, err := go_parser.ParseExpr(s1) 1583 if err != nil { 1584 t.Fatal(err) 1585 } 1586} 1587func TestAllMapsOrderedGoString(t *testing.T) { 1588 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1589 p := NewPopulatedAllMapsOrdered(popr, false) 1590 s1 := p.GoString() 1591 s2 := fmt.Sprintf("%#v", p) 1592 if s1 != s2 { 1593 t.Fatalf("GoString want %v got %v", s1, s2) 1594 } 1595 _, err := go_parser.ParseExpr(s1) 1596 if err != nil { 1597 t.Fatal(err) 1598 } 1599} 1600func TestMessageWithMapGoString(t *testing.T) { 1601 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1602 p := NewPopulatedMessageWithMap(popr, false) 1603 s1 := p.GoString() 1604 s2 := fmt.Sprintf("%#v", p) 1605 if s1 != s2 { 1606 t.Fatalf("GoString want %v got %v", s1, s2) 1607 } 1608 _, err := go_parser.ParseExpr(s1) 1609 if err != nil { 1610 t.Fatal(err) 1611 } 1612} 1613func TestFloatingPointGoString(t *testing.T) { 1614 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1615 p := NewPopulatedFloatingPoint(popr, false) 1616 s1 := p.GoString() 1617 s2 := fmt.Sprintf("%#v", p) 1618 if s1 != s2 { 1619 t.Fatalf("GoString want %v got %v", s1, s2) 1620 } 1621 _, err := go_parser.ParseExpr(s1) 1622 if err != nil { 1623 t.Fatal(err) 1624 } 1625} 1626func TestUint128PairGoString(t *testing.T) { 1627 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1628 p := NewPopulatedUint128Pair(popr, false) 1629 s1 := p.GoString() 1630 s2 := fmt.Sprintf("%#v", p) 1631 if s1 != s2 { 1632 t.Fatalf("GoString want %v got %v", s1, s2) 1633 } 1634 _, err := go_parser.ParseExpr(s1) 1635 if err != nil { 1636 t.Fatal(err) 1637 } 1638} 1639func TestContainsNestedMapGoString(t *testing.T) { 1640 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1641 p := NewPopulatedContainsNestedMap(popr, false) 1642 s1 := p.GoString() 1643 s2 := fmt.Sprintf("%#v", p) 1644 if s1 != s2 { 1645 t.Fatalf("GoString want %v got %v", s1, s2) 1646 } 1647 _, err := go_parser.ParseExpr(s1) 1648 if err != nil { 1649 t.Fatal(err) 1650 } 1651} 1652func TestContainsNestedMap_NestedMapGoString(t *testing.T) { 1653 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1654 p := NewPopulatedContainsNestedMap_NestedMap(popr, false) 1655 s1 := p.GoString() 1656 s2 := fmt.Sprintf("%#v", p) 1657 if s1 != s2 { 1658 t.Fatalf("GoString want %v got %v", s1, s2) 1659 } 1660 _, err := go_parser.ParseExpr(s1) 1661 if err != nil { 1662 t.Fatal(err) 1663 } 1664} 1665func TestNotPackedGoString(t *testing.T) { 1666 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 1667 p := NewPopulatedNotPacked(popr, false) 1668 s1 := p.GoString() 1669 s2 := fmt.Sprintf("%#v", p) 1670 if s1 != s2 { 1671 t.Fatalf("GoString want %v got %v", s1, s2) 1672 } 1673 _, err := go_parser.ParseExpr(s1) 1674 if err != nil { 1675 t.Fatal(err) 1676 } 1677} 1678func TestMessageSize(t *testing.T) { 1679 seed := time.Now().UnixNano() 1680 popr := math_rand.New(math_rand.NewSource(seed)) 1681 p := NewPopulatedMessage(popr, true) 1682 size2 := github_com_gogo_protobuf_proto.Size(p) 1683 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 1684 if err != nil { 1685 t.Fatalf("seed = %d, err = %v", seed, err) 1686 } 1687 size := p.Size() 1688 if len(dAtA) != size { 1689 t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA)) 1690 } 1691 if size2 != size { 1692 t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2) 1693 } 1694 size3 := github_com_gogo_protobuf_proto.Size(p) 1695 if size3 != size { 1696 t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3) 1697 } 1698} 1699 1700func BenchmarkMessageSize(b *testing.B) { 1701 popr := math_rand.New(math_rand.NewSource(616)) 1702 total := 0 1703 pops := make([]*Message, 1000) 1704 for i := 0; i < 1000; i++ { 1705 pops[i] = NewPopulatedMessage(popr, false) 1706 } 1707 b.ResetTimer() 1708 for i := 0; i < b.N; i++ { 1709 total += pops[i%1000].Size() 1710 } 1711 b.SetBytes(int64(total / b.N)) 1712} 1713 1714func TestNestedSize(t *testing.T) { 1715 seed := time.Now().UnixNano() 1716 popr := math_rand.New(math_rand.NewSource(seed)) 1717 p := NewPopulatedNested(popr, true) 1718 size2 := github_com_gogo_protobuf_proto.Size(p) 1719 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 1720 if err != nil { 1721 t.Fatalf("seed = %d, err = %v", seed, err) 1722 } 1723 size := p.Size() 1724 if len(dAtA) != size { 1725 t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA)) 1726 } 1727 if size2 != size { 1728 t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2) 1729 } 1730 size3 := github_com_gogo_protobuf_proto.Size(p) 1731 if size3 != size { 1732 t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3) 1733 } 1734} 1735 1736func BenchmarkNestedSize(b *testing.B) { 1737 popr := math_rand.New(math_rand.NewSource(616)) 1738 total := 0 1739 pops := make([]*Nested, 1000) 1740 for i := 0; i < 1000; i++ { 1741 pops[i] = NewPopulatedNested(popr, false) 1742 } 1743 b.ResetTimer() 1744 for i := 0; i < b.N; i++ { 1745 total += pops[i%1000].Size() 1746 } 1747 b.SetBytes(int64(total / b.N)) 1748} 1749 1750func TestAllMapsSize(t *testing.T) { 1751 seed := time.Now().UnixNano() 1752 popr := math_rand.New(math_rand.NewSource(seed)) 1753 p := NewPopulatedAllMaps(popr, true) 1754 size2 := github_com_gogo_protobuf_proto.Size(p) 1755 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 1756 if err != nil { 1757 t.Fatalf("seed = %d, err = %v", seed, err) 1758 } 1759 size := p.Size() 1760 if len(dAtA) != size { 1761 t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA)) 1762 } 1763 if size2 != size { 1764 t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2) 1765 } 1766 size3 := github_com_gogo_protobuf_proto.Size(p) 1767 if size3 != size { 1768 t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3) 1769 } 1770} 1771 1772func BenchmarkAllMapsSize(b *testing.B) { 1773 popr := math_rand.New(math_rand.NewSource(616)) 1774 total := 0 1775 pops := make([]*AllMaps, 1000) 1776 for i := 0; i < 1000; i++ { 1777 pops[i] = NewPopulatedAllMaps(popr, false) 1778 } 1779 b.ResetTimer() 1780 for i := 0; i < b.N; i++ { 1781 total += pops[i%1000].Size() 1782 } 1783 b.SetBytes(int64(total / b.N)) 1784} 1785 1786func TestAllMapsOrderedSize(t *testing.T) { 1787 seed := time.Now().UnixNano() 1788 popr := math_rand.New(math_rand.NewSource(seed)) 1789 p := NewPopulatedAllMapsOrdered(popr, true) 1790 size2 := github_com_gogo_protobuf_proto.Size(p) 1791 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 1792 if err != nil { 1793 t.Fatalf("seed = %d, err = %v", seed, err) 1794 } 1795 size := p.Size() 1796 if len(dAtA) != size { 1797 t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA)) 1798 } 1799 if size2 != size { 1800 t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2) 1801 } 1802 size3 := github_com_gogo_protobuf_proto.Size(p) 1803 if size3 != size { 1804 t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3) 1805 } 1806} 1807 1808func BenchmarkAllMapsOrderedSize(b *testing.B) { 1809 popr := math_rand.New(math_rand.NewSource(616)) 1810 total := 0 1811 pops := make([]*AllMapsOrdered, 1000) 1812 for i := 0; i < 1000; i++ { 1813 pops[i] = NewPopulatedAllMapsOrdered(popr, false) 1814 } 1815 b.ResetTimer() 1816 for i := 0; i < b.N; i++ { 1817 total += pops[i%1000].Size() 1818 } 1819 b.SetBytes(int64(total / b.N)) 1820} 1821 1822func TestMessageWithMapSize(t *testing.T) { 1823 seed := time.Now().UnixNano() 1824 popr := math_rand.New(math_rand.NewSource(seed)) 1825 p := NewPopulatedMessageWithMap(popr, true) 1826 size2 := github_com_gogo_protobuf_proto.Size(p) 1827 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 1828 if err != nil { 1829 t.Fatalf("seed = %d, err = %v", seed, err) 1830 } 1831 size := p.Size() 1832 if len(dAtA) != size { 1833 t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA)) 1834 } 1835 if size2 != size { 1836 t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2) 1837 } 1838 size3 := github_com_gogo_protobuf_proto.Size(p) 1839 if size3 != size { 1840 t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3) 1841 } 1842} 1843 1844func BenchmarkMessageWithMapSize(b *testing.B) { 1845 popr := math_rand.New(math_rand.NewSource(616)) 1846 total := 0 1847 pops := make([]*MessageWithMap, 1000) 1848 for i := 0; i < 1000; i++ { 1849 pops[i] = NewPopulatedMessageWithMap(popr, false) 1850 } 1851 b.ResetTimer() 1852 for i := 0; i < b.N; i++ { 1853 total += pops[i%1000].Size() 1854 } 1855 b.SetBytes(int64(total / b.N)) 1856} 1857 1858func TestFloatingPointSize(t *testing.T) { 1859 seed := time.Now().UnixNano() 1860 popr := math_rand.New(math_rand.NewSource(seed)) 1861 p := NewPopulatedFloatingPoint(popr, true) 1862 size2 := github_com_gogo_protobuf_proto.Size(p) 1863 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 1864 if err != nil { 1865 t.Fatalf("seed = %d, err = %v", seed, err) 1866 } 1867 size := p.Size() 1868 if len(dAtA) != size { 1869 t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA)) 1870 } 1871 if size2 != size { 1872 t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2) 1873 } 1874 size3 := github_com_gogo_protobuf_proto.Size(p) 1875 if size3 != size { 1876 t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3) 1877 } 1878} 1879 1880func BenchmarkFloatingPointSize(b *testing.B) { 1881 popr := math_rand.New(math_rand.NewSource(616)) 1882 total := 0 1883 pops := make([]*FloatingPoint, 1000) 1884 for i := 0; i < 1000; i++ { 1885 pops[i] = NewPopulatedFloatingPoint(popr, false) 1886 } 1887 b.ResetTimer() 1888 for i := 0; i < b.N; i++ { 1889 total += pops[i%1000].Size() 1890 } 1891 b.SetBytes(int64(total / b.N)) 1892} 1893 1894func TestUint128PairSize(t *testing.T) { 1895 seed := time.Now().UnixNano() 1896 popr := math_rand.New(math_rand.NewSource(seed)) 1897 p := NewPopulatedUint128Pair(popr, true) 1898 size2 := github_com_gogo_protobuf_proto.Size(p) 1899 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 1900 if err != nil { 1901 t.Fatalf("seed = %d, err = %v", seed, err) 1902 } 1903 size := p.Size() 1904 if len(dAtA) != size { 1905 t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA)) 1906 } 1907 if size2 != size { 1908 t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2) 1909 } 1910 size3 := github_com_gogo_protobuf_proto.Size(p) 1911 if size3 != size { 1912 t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3) 1913 } 1914} 1915 1916func BenchmarkUint128PairSize(b *testing.B) { 1917 popr := math_rand.New(math_rand.NewSource(616)) 1918 total := 0 1919 pops := make([]*Uint128Pair, 1000) 1920 for i := 0; i < 1000; i++ { 1921 pops[i] = NewPopulatedUint128Pair(popr, false) 1922 } 1923 b.ResetTimer() 1924 for i := 0; i < b.N; i++ { 1925 total += pops[i%1000].Size() 1926 } 1927 b.SetBytes(int64(total / b.N)) 1928} 1929 1930func TestContainsNestedMapSize(t *testing.T) { 1931 seed := time.Now().UnixNano() 1932 popr := math_rand.New(math_rand.NewSource(seed)) 1933 p := NewPopulatedContainsNestedMap(popr, true) 1934 size2 := github_com_gogo_protobuf_proto.Size(p) 1935 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 1936 if err != nil { 1937 t.Fatalf("seed = %d, err = %v", seed, err) 1938 } 1939 size := p.Size() 1940 if len(dAtA) != size { 1941 t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA)) 1942 } 1943 if size2 != size { 1944 t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2) 1945 } 1946 size3 := github_com_gogo_protobuf_proto.Size(p) 1947 if size3 != size { 1948 t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3) 1949 } 1950} 1951 1952func BenchmarkContainsNestedMapSize(b *testing.B) { 1953 popr := math_rand.New(math_rand.NewSource(616)) 1954 total := 0 1955 pops := make([]*ContainsNestedMap, 1000) 1956 for i := 0; i < 1000; i++ { 1957 pops[i] = NewPopulatedContainsNestedMap(popr, false) 1958 } 1959 b.ResetTimer() 1960 for i := 0; i < b.N; i++ { 1961 total += pops[i%1000].Size() 1962 } 1963 b.SetBytes(int64(total / b.N)) 1964} 1965 1966func TestContainsNestedMap_NestedMapSize(t *testing.T) { 1967 seed := time.Now().UnixNano() 1968 popr := math_rand.New(math_rand.NewSource(seed)) 1969 p := NewPopulatedContainsNestedMap_NestedMap(popr, true) 1970 size2 := github_com_gogo_protobuf_proto.Size(p) 1971 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 1972 if err != nil { 1973 t.Fatalf("seed = %d, err = %v", seed, err) 1974 } 1975 size := p.Size() 1976 if len(dAtA) != size { 1977 t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA)) 1978 } 1979 if size2 != size { 1980 t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2) 1981 } 1982 size3 := github_com_gogo_protobuf_proto.Size(p) 1983 if size3 != size { 1984 t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3) 1985 } 1986} 1987 1988func BenchmarkContainsNestedMap_NestedMapSize(b *testing.B) { 1989 popr := math_rand.New(math_rand.NewSource(616)) 1990 total := 0 1991 pops := make([]*ContainsNestedMap_NestedMap, 1000) 1992 for i := 0; i < 1000; i++ { 1993 pops[i] = NewPopulatedContainsNestedMap_NestedMap(popr, false) 1994 } 1995 b.ResetTimer() 1996 for i := 0; i < b.N; i++ { 1997 total += pops[i%1000].Size() 1998 } 1999 b.SetBytes(int64(total / b.N)) 2000} 2001 2002func TestNotPackedSize(t *testing.T) { 2003 seed := time.Now().UnixNano() 2004 popr := math_rand.New(math_rand.NewSource(seed)) 2005 p := NewPopulatedNotPacked(popr, true) 2006 size2 := github_com_gogo_protobuf_proto.Size(p) 2007 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 2008 if err != nil { 2009 t.Fatalf("seed = %d, err = %v", seed, err) 2010 } 2011 size := p.Size() 2012 if len(dAtA) != size { 2013 t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA)) 2014 } 2015 if size2 != size { 2016 t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2) 2017 } 2018 size3 := github_com_gogo_protobuf_proto.Size(p) 2019 if size3 != size { 2020 t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3) 2021 } 2022} 2023 2024func BenchmarkNotPackedSize(b *testing.B) { 2025 popr := math_rand.New(math_rand.NewSource(616)) 2026 total := 0 2027 pops := make([]*NotPacked, 1000) 2028 for i := 0; i < 1000; i++ { 2029 pops[i] = NewPopulatedNotPacked(popr, false) 2030 } 2031 b.ResetTimer() 2032 for i := 0; i < b.N; i++ { 2033 total += pops[i%1000].Size() 2034 } 2035 b.SetBytes(int64(total / b.N)) 2036} 2037 2038func TestMessageStringer(t *testing.T) { 2039 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 2040 p := NewPopulatedMessage(popr, false) 2041 s1 := p.String() 2042 s2 := fmt.Sprintf("%v", p) 2043 if s1 != s2 { 2044 t.Fatalf("String want %v got %v", s1, s2) 2045 } 2046} 2047func TestNestedStringer(t *testing.T) { 2048 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 2049 p := NewPopulatedNested(popr, false) 2050 s1 := p.String() 2051 s2 := fmt.Sprintf("%v", p) 2052 if s1 != s2 { 2053 t.Fatalf("String want %v got %v", s1, s2) 2054 } 2055} 2056func TestAllMapsStringer(t *testing.T) { 2057 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 2058 p := NewPopulatedAllMaps(popr, false) 2059 s1 := p.String() 2060 s2 := fmt.Sprintf("%v", p) 2061 if s1 != s2 { 2062 t.Fatalf("String want %v got %v", s1, s2) 2063 } 2064} 2065func TestAllMapsOrderedStringer(t *testing.T) { 2066 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 2067 p := NewPopulatedAllMapsOrdered(popr, false) 2068 s1 := p.String() 2069 s2 := fmt.Sprintf("%v", p) 2070 if s1 != s2 { 2071 t.Fatalf("String want %v got %v", s1, s2) 2072 } 2073} 2074func TestMessageWithMapStringer(t *testing.T) { 2075 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 2076 p := NewPopulatedMessageWithMap(popr, false) 2077 s1 := p.String() 2078 s2 := fmt.Sprintf("%v", p) 2079 if s1 != s2 { 2080 t.Fatalf("String want %v got %v", s1, s2) 2081 } 2082} 2083func TestFloatingPointStringer(t *testing.T) { 2084 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 2085 p := NewPopulatedFloatingPoint(popr, false) 2086 s1 := p.String() 2087 s2 := fmt.Sprintf("%v", p) 2088 if s1 != s2 { 2089 t.Fatalf("String want %v got %v", s1, s2) 2090 } 2091} 2092func TestUint128PairStringer(t *testing.T) { 2093 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 2094 p := NewPopulatedUint128Pair(popr, false) 2095 s1 := p.String() 2096 s2 := fmt.Sprintf("%v", p) 2097 if s1 != s2 { 2098 t.Fatalf("String want %v got %v", s1, s2) 2099 } 2100} 2101func TestContainsNestedMapStringer(t *testing.T) { 2102 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 2103 p := NewPopulatedContainsNestedMap(popr, false) 2104 s1 := p.String() 2105 s2 := fmt.Sprintf("%v", p) 2106 if s1 != s2 { 2107 t.Fatalf("String want %v got %v", s1, s2) 2108 } 2109} 2110func TestContainsNestedMap_NestedMapStringer(t *testing.T) { 2111 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 2112 p := NewPopulatedContainsNestedMap_NestedMap(popr, false) 2113 s1 := p.String() 2114 s2 := fmt.Sprintf("%v", p) 2115 if s1 != s2 { 2116 t.Fatalf("String want %v got %v", s1, s2) 2117 } 2118} 2119func TestNotPackedStringer(t *testing.T) { 2120 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 2121 p := NewPopulatedNotPacked(popr, false) 2122 s1 := p.String() 2123 s2 := fmt.Sprintf("%v", p) 2124 if s1 != s2 { 2125 t.Fatalf("String want %v got %v", s1, s2) 2126 } 2127} 2128 2129//These tests are generated by github.com/gogo/protobuf/plugin/testgen 2130