mirror of
https://github.com/genuinetools/reg.git
synced 2024-08-21 14:20:23 -04:00
2145 lines
63 KiB
Go
2145 lines
63 KiB
Go
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
|
// source: combos/unmarshaler/theproto3.proto
|
|
|
|
/*
|
|
Package theproto3 is a generated protocol buffer package.
|
|
|
|
It is generated from these files:
|
|
combos/unmarshaler/theproto3.proto
|
|
|
|
It has these top-level messages:
|
|
Message
|
|
Nested
|
|
AllMaps
|
|
AllMapsOrdered
|
|
MessageWithMap
|
|
FloatingPoint
|
|
Uint128Pair
|
|
ContainsNestedMap
|
|
NotPacked
|
|
*/
|
|
package theproto3
|
|
|
|
import testing "testing"
|
|
import math_rand "math/rand"
|
|
import time "time"
|
|
import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
|
|
import github_com_gogo_protobuf_jsonpb "github.com/gogo/protobuf/jsonpb"
|
|
import fmt "fmt"
|
|
import go_parser "go/parser"
|
|
import proto "github.com/gogo/protobuf/proto"
|
|
import math "math"
|
|
import _ "github.com/gogo/protobuf/gogoproto"
|
|
import _ "github.com/gogo/protobuf/test/combos/both"
|
|
|
|
// Reference imports to suppress errors if they are not otherwise used.
|
|
var _ = proto.Marshal
|
|
var _ = fmt.Errorf
|
|
var _ = math.Inf
|
|
|
|
func TestMessageProto(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedMessage(popr, false)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
msg := &Message{}
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
littlefuzz := make([]byte, len(dAtA))
|
|
copy(littlefuzz, dAtA)
|
|
for i := range dAtA {
|
|
dAtA[i] = byte(popr.Intn(256))
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
if len(littlefuzz) > 0 {
|
|
fuzzamount := 100
|
|
for i := 0; i < fuzzamount; i++ {
|
|
littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256))
|
|
littlefuzz = append(littlefuzz, byte(popr.Intn(256)))
|
|
}
|
|
// shouldn't panic
|
|
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
|
|
}
|
|
}
|
|
|
|
func BenchmarkMessageProtoMarshal(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
pops := make([]*Message, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
pops[i] = NewPopulatedMessage(popr, false)
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000])
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
total += len(dAtA)
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func BenchmarkMessageProtoUnmarshal(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
datas := make([][]byte, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedMessage(popr, false))
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
datas[i] = dAtA
|
|
}
|
|
msg := &Message{}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
total += len(datas[i%10000])
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func TestNestedProto(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedNested(popr, false)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
msg := &Nested{}
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
littlefuzz := make([]byte, len(dAtA))
|
|
copy(littlefuzz, dAtA)
|
|
for i := range dAtA {
|
|
dAtA[i] = byte(popr.Intn(256))
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
if len(littlefuzz) > 0 {
|
|
fuzzamount := 100
|
|
for i := 0; i < fuzzamount; i++ {
|
|
littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256))
|
|
littlefuzz = append(littlefuzz, byte(popr.Intn(256)))
|
|
}
|
|
// shouldn't panic
|
|
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
|
|
}
|
|
}
|
|
|
|
func BenchmarkNestedProtoMarshal(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
pops := make([]*Nested, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
pops[i] = NewPopulatedNested(popr, false)
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000])
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
total += len(dAtA)
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func BenchmarkNestedProtoUnmarshal(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
datas := make([][]byte, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedNested(popr, false))
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
datas[i] = dAtA
|
|
}
|
|
msg := &Nested{}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
total += len(datas[i%10000])
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func TestAllMapsProto(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedAllMaps(popr, false)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
msg := &AllMaps{}
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
littlefuzz := make([]byte, len(dAtA))
|
|
copy(littlefuzz, dAtA)
|
|
for i := range dAtA {
|
|
dAtA[i] = byte(popr.Intn(256))
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
if len(littlefuzz) > 0 {
|
|
fuzzamount := 100
|
|
for i := 0; i < fuzzamount; i++ {
|
|
littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256))
|
|
littlefuzz = append(littlefuzz, byte(popr.Intn(256)))
|
|
}
|
|
// shouldn't panic
|
|
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
|
|
}
|
|
}
|
|
|
|
func BenchmarkAllMapsProtoMarshal(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
pops := make([]*AllMaps, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
pops[i] = NewPopulatedAllMaps(popr, false)
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000])
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
total += len(dAtA)
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func BenchmarkAllMapsProtoUnmarshal(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
datas := make([][]byte, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedAllMaps(popr, false))
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
datas[i] = dAtA
|
|
}
|
|
msg := &AllMaps{}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
total += len(datas[i%10000])
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func TestAllMapsOrderedProto(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedAllMapsOrdered(popr, false)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
msg := &AllMapsOrdered{}
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
littlefuzz := make([]byte, len(dAtA))
|
|
copy(littlefuzz, dAtA)
|
|
for i := range dAtA {
|
|
dAtA[i] = byte(popr.Intn(256))
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
if len(littlefuzz) > 0 {
|
|
fuzzamount := 100
|
|
for i := 0; i < fuzzamount; i++ {
|
|
littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256))
|
|
littlefuzz = append(littlefuzz, byte(popr.Intn(256)))
|
|
}
|
|
// shouldn't panic
|
|
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
|
|
}
|
|
}
|
|
|
|
func BenchmarkAllMapsOrderedProtoMarshal(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
pops := make([]*AllMapsOrdered, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
pops[i] = NewPopulatedAllMapsOrdered(popr, false)
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000])
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
total += len(dAtA)
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func BenchmarkAllMapsOrderedProtoUnmarshal(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
datas := make([][]byte, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedAllMapsOrdered(popr, false))
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
datas[i] = dAtA
|
|
}
|
|
msg := &AllMapsOrdered{}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
total += len(datas[i%10000])
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func TestMessageWithMapProto(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedMessageWithMap(popr, false)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
msg := &MessageWithMap{}
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
littlefuzz := make([]byte, len(dAtA))
|
|
copy(littlefuzz, dAtA)
|
|
for i := range dAtA {
|
|
dAtA[i] = byte(popr.Intn(256))
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
if len(littlefuzz) > 0 {
|
|
fuzzamount := 100
|
|
for i := 0; i < fuzzamount; i++ {
|
|
littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256))
|
|
littlefuzz = append(littlefuzz, byte(popr.Intn(256)))
|
|
}
|
|
// shouldn't panic
|
|
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
|
|
}
|
|
}
|
|
|
|
func BenchmarkMessageWithMapProtoMarshal(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
pops := make([]*MessageWithMap, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
pops[i] = NewPopulatedMessageWithMap(popr, false)
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000])
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
total += len(dAtA)
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func BenchmarkMessageWithMapProtoUnmarshal(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
datas := make([][]byte, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedMessageWithMap(popr, false))
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
datas[i] = dAtA
|
|
}
|
|
msg := &MessageWithMap{}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
total += len(datas[i%10000])
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func TestFloatingPointProto(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedFloatingPoint(popr, false)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
msg := &FloatingPoint{}
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
littlefuzz := make([]byte, len(dAtA))
|
|
copy(littlefuzz, dAtA)
|
|
for i := range dAtA {
|
|
dAtA[i] = byte(popr.Intn(256))
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
if len(littlefuzz) > 0 {
|
|
fuzzamount := 100
|
|
for i := 0; i < fuzzamount; i++ {
|
|
littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256))
|
|
littlefuzz = append(littlefuzz, byte(popr.Intn(256)))
|
|
}
|
|
// shouldn't panic
|
|
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
|
|
}
|
|
}
|
|
|
|
func BenchmarkFloatingPointProtoMarshal(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
pops := make([]*FloatingPoint, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
pops[i] = NewPopulatedFloatingPoint(popr, false)
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000])
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
total += len(dAtA)
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func BenchmarkFloatingPointProtoUnmarshal(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
datas := make([][]byte, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedFloatingPoint(popr, false))
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
datas[i] = dAtA
|
|
}
|
|
msg := &FloatingPoint{}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
total += len(datas[i%10000])
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func TestUint128PairProto(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedUint128Pair(popr, false)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
msg := &Uint128Pair{}
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
littlefuzz := make([]byte, len(dAtA))
|
|
copy(littlefuzz, dAtA)
|
|
for i := range dAtA {
|
|
dAtA[i] = byte(popr.Intn(256))
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
if len(littlefuzz) > 0 {
|
|
fuzzamount := 100
|
|
for i := 0; i < fuzzamount; i++ {
|
|
littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256))
|
|
littlefuzz = append(littlefuzz, byte(popr.Intn(256)))
|
|
}
|
|
// shouldn't panic
|
|
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
|
|
}
|
|
}
|
|
|
|
func BenchmarkUint128PairProtoMarshal(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
pops := make([]*Uint128Pair, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
pops[i] = NewPopulatedUint128Pair(popr, false)
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000])
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
total += len(dAtA)
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func BenchmarkUint128PairProtoUnmarshal(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
datas := make([][]byte, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedUint128Pair(popr, false))
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
datas[i] = dAtA
|
|
}
|
|
msg := &Uint128Pair{}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
total += len(datas[i%10000])
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func TestContainsNestedMapProto(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedContainsNestedMap(popr, false)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
msg := &ContainsNestedMap{}
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
littlefuzz := make([]byte, len(dAtA))
|
|
copy(littlefuzz, dAtA)
|
|
for i := range dAtA {
|
|
dAtA[i] = byte(popr.Intn(256))
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
if len(littlefuzz) > 0 {
|
|
fuzzamount := 100
|
|
for i := 0; i < fuzzamount; i++ {
|
|
littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256))
|
|
littlefuzz = append(littlefuzz, byte(popr.Intn(256)))
|
|
}
|
|
// shouldn't panic
|
|
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
|
|
}
|
|
}
|
|
|
|
func BenchmarkContainsNestedMapProtoMarshal(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
pops := make([]*ContainsNestedMap, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
pops[i] = NewPopulatedContainsNestedMap(popr, false)
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000])
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
total += len(dAtA)
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func BenchmarkContainsNestedMapProtoUnmarshal(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
datas := make([][]byte, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedContainsNestedMap(popr, false))
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
datas[i] = dAtA
|
|
}
|
|
msg := &ContainsNestedMap{}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
total += len(datas[i%10000])
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func TestContainsNestedMap_NestedMapProto(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedContainsNestedMap_NestedMap(popr, false)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
msg := &ContainsNestedMap_NestedMap{}
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
littlefuzz := make([]byte, len(dAtA))
|
|
copy(littlefuzz, dAtA)
|
|
for i := range dAtA {
|
|
dAtA[i] = byte(popr.Intn(256))
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
if len(littlefuzz) > 0 {
|
|
fuzzamount := 100
|
|
for i := 0; i < fuzzamount; i++ {
|
|
littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256))
|
|
littlefuzz = append(littlefuzz, byte(popr.Intn(256)))
|
|
}
|
|
// shouldn't panic
|
|
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
|
|
}
|
|
}
|
|
|
|
func BenchmarkContainsNestedMap_NestedMapProtoMarshal(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
pops := make([]*ContainsNestedMap_NestedMap, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
pops[i] = NewPopulatedContainsNestedMap_NestedMap(popr, false)
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000])
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
total += len(dAtA)
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func BenchmarkContainsNestedMap_NestedMapProtoUnmarshal(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
datas := make([][]byte, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedContainsNestedMap_NestedMap(popr, false))
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
datas[i] = dAtA
|
|
}
|
|
msg := &ContainsNestedMap_NestedMap{}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
total += len(datas[i%10000])
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func TestNotPackedProto(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedNotPacked(popr, false)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
msg := &NotPacked{}
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
littlefuzz := make([]byte, len(dAtA))
|
|
copy(littlefuzz, dAtA)
|
|
for i := range dAtA {
|
|
dAtA[i] = byte(popr.Intn(256))
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
if len(littlefuzz) > 0 {
|
|
fuzzamount := 100
|
|
for i := 0; i < fuzzamount; i++ {
|
|
littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256))
|
|
littlefuzz = append(littlefuzz, byte(popr.Intn(256)))
|
|
}
|
|
// shouldn't panic
|
|
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
|
|
}
|
|
}
|
|
|
|
func BenchmarkNotPackedProtoMarshal(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
pops := make([]*NotPacked, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
pops[i] = NewPopulatedNotPacked(popr, false)
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000])
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
total += len(dAtA)
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func BenchmarkNotPackedProtoUnmarshal(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
datas := make([][]byte, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedNotPacked(popr, false))
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
datas[i] = dAtA
|
|
}
|
|
msg := &NotPacked{}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
total += len(datas[i%10000])
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func TestMessageJSON(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedMessage(popr, true)
|
|
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
|
|
jsondata, err := marshaler.MarshalToString(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
msg := &Message{}
|
|
err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p)
|
|
}
|
|
}
|
|
func TestNestedJSON(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedNested(popr, true)
|
|
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
|
|
jsondata, err := marshaler.MarshalToString(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
msg := &Nested{}
|
|
err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p)
|
|
}
|
|
}
|
|
func TestAllMapsJSON(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedAllMaps(popr, true)
|
|
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
|
|
jsondata, err := marshaler.MarshalToString(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
msg := &AllMaps{}
|
|
err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p)
|
|
}
|
|
}
|
|
func TestAllMapsOrderedJSON(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedAllMapsOrdered(popr, true)
|
|
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
|
|
jsondata, err := marshaler.MarshalToString(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
msg := &AllMapsOrdered{}
|
|
err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p)
|
|
}
|
|
}
|
|
func TestMessageWithMapJSON(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedMessageWithMap(popr, true)
|
|
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
|
|
jsondata, err := marshaler.MarshalToString(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
msg := &MessageWithMap{}
|
|
err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p)
|
|
}
|
|
}
|
|
func TestFloatingPointJSON(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedFloatingPoint(popr, true)
|
|
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
|
|
jsondata, err := marshaler.MarshalToString(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
msg := &FloatingPoint{}
|
|
err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p)
|
|
}
|
|
}
|
|
func TestUint128PairJSON(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedUint128Pair(popr, true)
|
|
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
|
|
jsondata, err := marshaler.MarshalToString(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
msg := &Uint128Pair{}
|
|
err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p)
|
|
}
|
|
}
|
|
func TestContainsNestedMapJSON(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedContainsNestedMap(popr, true)
|
|
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
|
|
jsondata, err := marshaler.MarshalToString(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
msg := &ContainsNestedMap{}
|
|
err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p)
|
|
}
|
|
}
|
|
func TestContainsNestedMap_NestedMapJSON(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedContainsNestedMap_NestedMap(popr, true)
|
|
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
|
|
jsondata, err := marshaler.MarshalToString(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
msg := &ContainsNestedMap_NestedMap{}
|
|
err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p)
|
|
}
|
|
}
|
|
func TestNotPackedJSON(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedNotPacked(popr, true)
|
|
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
|
|
jsondata, err := marshaler.MarshalToString(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
msg := &NotPacked{}
|
|
err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p)
|
|
}
|
|
}
|
|
func TestMessageProtoText(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedMessage(popr, true)
|
|
dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p)
|
|
msg := &Message{}
|
|
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
}
|
|
|
|
func TestMessageProtoCompactText(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedMessage(popr, true)
|
|
dAtA := github_com_gogo_protobuf_proto.CompactTextString(p)
|
|
msg := &Message{}
|
|
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
}
|
|
|
|
func TestNestedProtoText(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedNested(popr, true)
|
|
dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p)
|
|
msg := &Nested{}
|
|
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
}
|
|
|
|
func TestNestedProtoCompactText(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedNested(popr, true)
|
|
dAtA := github_com_gogo_protobuf_proto.CompactTextString(p)
|
|
msg := &Nested{}
|
|
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
}
|
|
|
|
func TestAllMapsProtoText(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedAllMaps(popr, true)
|
|
dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p)
|
|
msg := &AllMaps{}
|
|
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
}
|
|
|
|
func TestAllMapsProtoCompactText(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedAllMaps(popr, true)
|
|
dAtA := github_com_gogo_protobuf_proto.CompactTextString(p)
|
|
msg := &AllMaps{}
|
|
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
}
|
|
|
|
func TestAllMapsOrderedProtoText(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedAllMapsOrdered(popr, true)
|
|
dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p)
|
|
msg := &AllMapsOrdered{}
|
|
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
}
|
|
|
|
func TestAllMapsOrderedProtoCompactText(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedAllMapsOrdered(popr, true)
|
|
dAtA := github_com_gogo_protobuf_proto.CompactTextString(p)
|
|
msg := &AllMapsOrdered{}
|
|
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
}
|
|
|
|
func TestMessageWithMapProtoText(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedMessageWithMap(popr, true)
|
|
dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p)
|
|
msg := &MessageWithMap{}
|
|
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
}
|
|
|
|
func TestMessageWithMapProtoCompactText(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedMessageWithMap(popr, true)
|
|
dAtA := github_com_gogo_protobuf_proto.CompactTextString(p)
|
|
msg := &MessageWithMap{}
|
|
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
}
|
|
|
|
func TestFloatingPointProtoText(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedFloatingPoint(popr, true)
|
|
dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p)
|
|
msg := &FloatingPoint{}
|
|
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
}
|
|
|
|
func TestFloatingPointProtoCompactText(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedFloatingPoint(popr, true)
|
|
dAtA := github_com_gogo_protobuf_proto.CompactTextString(p)
|
|
msg := &FloatingPoint{}
|
|
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
}
|
|
|
|
func TestUint128PairProtoText(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedUint128Pair(popr, true)
|
|
dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p)
|
|
msg := &Uint128Pair{}
|
|
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
}
|
|
|
|
func TestUint128PairProtoCompactText(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedUint128Pair(popr, true)
|
|
dAtA := github_com_gogo_protobuf_proto.CompactTextString(p)
|
|
msg := &Uint128Pair{}
|
|
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
}
|
|
|
|
func TestContainsNestedMapProtoText(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedContainsNestedMap(popr, true)
|
|
dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p)
|
|
msg := &ContainsNestedMap{}
|
|
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
}
|
|
|
|
func TestContainsNestedMapProtoCompactText(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedContainsNestedMap(popr, true)
|
|
dAtA := github_com_gogo_protobuf_proto.CompactTextString(p)
|
|
msg := &ContainsNestedMap{}
|
|
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
}
|
|
|
|
func TestContainsNestedMap_NestedMapProtoText(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedContainsNestedMap_NestedMap(popr, true)
|
|
dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p)
|
|
msg := &ContainsNestedMap_NestedMap{}
|
|
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
}
|
|
|
|
func TestContainsNestedMap_NestedMapProtoCompactText(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedContainsNestedMap_NestedMap(popr, true)
|
|
dAtA := github_com_gogo_protobuf_proto.CompactTextString(p)
|
|
msg := &ContainsNestedMap_NestedMap{}
|
|
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
}
|
|
|
|
func TestNotPackedProtoText(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedNotPacked(popr, true)
|
|
dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p)
|
|
msg := &NotPacked{}
|
|
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
}
|
|
|
|
func TestNotPackedProtoCompactText(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedNotPacked(popr, true)
|
|
dAtA := github_com_gogo_protobuf_proto.CompactTextString(p)
|
|
msg := &NotPacked{}
|
|
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
|
|
}
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
}
|
|
}
|
|
|
|
func TestTheproto3Description(t *testing.T) {
|
|
Theproto3Description()
|
|
}
|
|
func TestMessageVerboseEqual(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedMessage(popr, false)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
msg := &Message{}
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
|
|
panic(err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err)
|
|
}
|
|
}
|
|
func TestNestedVerboseEqual(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedNested(popr, false)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
msg := &Nested{}
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
|
|
panic(err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err)
|
|
}
|
|
}
|
|
func TestAllMapsVerboseEqual(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedAllMaps(popr, false)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
msg := &AllMaps{}
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
|
|
panic(err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err)
|
|
}
|
|
}
|
|
func TestAllMapsOrderedVerboseEqual(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedAllMapsOrdered(popr, false)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
msg := &AllMapsOrdered{}
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
|
|
panic(err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err)
|
|
}
|
|
}
|
|
func TestMessageWithMapVerboseEqual(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedMessageWithMap(popr, false)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
msg := &MessageWithMap{}
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
|
|
panic(err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err)
|
|
}
|
|
}
|
|
func TestFloatingPointVerboseEqual(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedFloatingPoint(popr, false)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
msg := &FloatingPoint{}
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
|
|
panic(err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err)
|
|
}
|
|
}
|
|
func TestUint128PairVerboseEqual(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedUint128Pair(popr, false)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
msg := &Uint128Pair{}
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
|
|
panic(err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err)
|
|
}
|
|
}
|
|
func TestContainsNestedMapVerboseEqual(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedContainsNestedMap(popr, false)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
msg := &ContainsNestedMap{}
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
|
|
panic(err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err)
|
|
}
|
|
}
|
|
func TestContainsNestedMap_NestedMapVerboseEqual(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedContainsNestedMap_NestedMap(popr, false)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
msg := &ContainsNestedMap_NestedMap{}
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
|
|
panic(err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err)
|
|
}
|
|
}
|
|
func TestNotPackedVerboseEqual(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedNotPacked(popr, false)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
msg := &NotPacked{}
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
|
|
panic(err)
|
|
}
|
|
if err := p.VerboseEqual(msg); err != nil {
|
|
t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err)
|
|
}
|
|
}
|
|
func TestMessageFace(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedMessage(popr, true)
|
|
msg := p.TestProto()
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("%#v !Face Equal %#v", msg, p)
|
|
}
|
|
}
|
|
func TestNestedFace(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedNested(popr, true)
|
|
msg := p.TestProto()
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("%#v !Face Equal %#v", msg, p)
|
|
}
|
|
}
|
|
func TestAllMapsFace(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedAllMaps(popr, true)
|
|
msg := p.TestProto()
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("%#v !Face Equal %#v", msg, p)
|
|
}
|
|
}
|
|
func TestAllMapsOrderedFace(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedAllMapsOrdered(popr, true)
|
|
msg := p.TestProto()
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("%#v !Face Equal %#v", msg, p)
|
|
}
|
|
}
|
|
func TestMessageWithMapFace(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedMessageWithMap(popr, true)
|
|
msg := p.TestProto()
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("%#v !Face Equal %#v", msg, p)
|
|
}
|
|
}
|
|
func TestFloatingPointFace(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedFloatingPoint(popr, true)
|
|
msg := p.TestProto()
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("%#v !Face Equal %#v", msg, p)
|
|
}
|
|
}
|
|
func TestUint128PairFace(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedUint128Pair(popr, true)
|
|
msg := p.TestProto()
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("%#v !Face Equal %#v", msg, p)
|
|
}
|
|
}
|
|
func TestContainsNestedMapFace(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedContainsNestedMap(popr, true)
|
|
msg := p.TestProto()
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("%#v !Face Equal %#v", msg, p)
|
|
}
|
|
}
|
|
func TestContainsNestedMap_NestedMapFace(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedContainsNestedMap_NestedMap(popr, true)
|
|
msg := p.TestProto()
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("%#v !Face Equal %#v", msg, p)
|
|
}
|
|
}
|
|
func TestNotPackedFace(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedNotPacked(popr, true)
|
|
msg := p.TestProto()
|
|
if !p.Equal(msg) {
|
|
t.Fatalf("%#v !Face Equal %#v", msg, p)
|
|
}
|
|
}
|
|
func TestMessageGoString(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedMessage(popr, false)
|
|
s1 := p.GoString()
|
|
s2 := fmt.Sprintf("%#v", p)
|
|
if s1 != s2 {
|
|
t.Fatalf("GoString want %v got %v", s1, s2)
|
|
}
|
|
_, err := go_parser.ParseExpr(s1)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
func TestNestedGoString(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedNested(popr, false)
|
|
s1 := p.GoString()
|
|
s2 := fmt.Sprintf("%#v", p)
|
|
if s1 != s2 {
|
|
t.Fatalf("GoString want %v got %v", s1, s2)
|
|
}
|
|
_, err := go_parser.ParseExpr(s1)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
func TestAllMapsGoString(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedAllMaps(popr, false)
|
|
s1 := p.GoString()
|
|
s2 := fmt.Sprintf("%#v", p)
|
|
if s1 != s2 {
|
|
t.Fatalf("GoString want %v got %v", s1, s2)
|
|
}
|
|
_, err := go_parser.ParseExpr(s1)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
func TestAllMapsOrderedGoString(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedAllMapsOrdered(popr, false)
|
|
s1 := p.GoString()
|
|
s2 := fmt.Sprintf("%#v", p)
|
|
if s1 != s2 {
|
|
t.Fatalf("GoString want %v got %v", s1, s2)
|
|
}
|
|
_, err := go_parser.ParseExpr(s1)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
func TestMessageWithMapGoString(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedMessageWithMap(popr, false)
|
|
s1 := p.GoString()
|
|
s2 := fmt.Sprintf("%#v", p)
|
|
if s1 != s2 {
|
|
t.Fatalf("GoString want %v got %v", s1, s2)
|
|
}
|
|
_, err := go_parser.ParseExpr(s1)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
func TestFloatingPointGoString(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedFloatingPoint(popr, false)
|
|
s1 := p.GoString()
|
|
s2 := fmt.Sprintf("%#v", p)
|
|
if s1 != s2 {
|
|
t.Fatalf("GoString want %v got %v", s1, s2)
|
|
}
|
|
_, err := go_parser.ParseExpr(s1)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
func TestUint128PairGoString(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedUint128Pair(popr, false)
|
|
s1 := p.GoString()
|
|
s2 := fmt.Sprintf("%#v", p)
|
|
if s1 != s2 {
|
|
t.Fatalf("GoString want %v got %v", s1, s2)
|
|
}
|
|
_, err := go_parser.ParseExpr(s1)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
func TestContainsNestedMapGoString(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedContainsNestedMap(popr, false)
|
|
s1 := p.GoString()
|
|
s2 := fmt.Sprintf("%#v", p)
|
|
if s1 != s2 {
|
|
t.Fatalf("GoString want %v got %v", s1, s2)
|
|
}
|
|
_, err := go_parser.ParseExpr(s1)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
func TestContainsNestedMap_NestedMapGoString(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedContainsNestedMap_NestedMap(popr, false)
|
|
s1 := p.GoString()
|
|
s2 := fmt.Sprintf("%#v", p)
|
|
if s1 != s2 {
|
|
t.Fatalf("GoString want %v got %v", s1, s2)
|
|
}
|
|
_, err := go_parser.ParseExpr(s1)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
func TestNotPackedGoString(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedNotPacked(popr, false)
|
|
s1 := p.GoString()
|
|
s2 := fmt.Sprintf("%#v", p)
|
|
if s1 != s2 {
|
|
t.Fatalf("GoString want %v got %v", s1, s2)
|
|
}
|
|
_, err := go_parser.ParseExpr(s1)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
func TestMessageSize(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedMessage(popr, true)
|
|
size2 := github_com_gogo_protobuf_proto.Size(p)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
size := p.Size()
|
|
if len(dAtA) != size {
|
|
t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA))
|
|
}
|
|
if size2 != size {
|
|
t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2)
|
|
}
|
|
size3 := github_com_gogo_protobuf_proto.Size(p)
|
|
if size3 != size {
|
|
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
|
|
}
|
|
}
|
|
|
|
func BenchmarkMessageSize(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
pops := make([]*Message, 1000)
|
|
for i := 0; i < 1000; i++ {
|
|
pops[i] = NewPopulatedMessage(popr, false)
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
total += pops[i%1000].Size()
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func TestNestedSize(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedNested(popr, true)
|
|
size2 := github_com_gogo_protobuf_proto.Size(p)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
size := p.Size()
|
|
if len(dAtA) != size {
|
|
t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA))
|
|
}
|
|
if size2 != size {
|
|
t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2)
|
|
}
|
|
size3 := github_com_gogo_protobuf_proto.Size(p)
|
|
if size3 != size {
|
|
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
|
|
}
|
|
}
|
|
|
|
func BenchmarkNestedSize(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
pops := make([]*Nested, 1000)
|
|
for i := 0; i < 1000; i++ {
|
|
pops[i] = NewPopulatedNested(popr, false)
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
total += pops[i%1000].Size()
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func TestAllMapsSize(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedAllMaps(popr, true)
|
|
size2 := github_com_gogo_protobuf_proto.Size(p)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
size := p.Size()
|
|
if len(dAtA) != size {
|
|
t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA))
|
|
}
|
|
if size2 != size {
|
|
t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2)
|
|
}
|
|
size3 := github_com_gogo_protobuf_proto.Size(p)
|
|
if size3 != size {
|
|
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
|
|
}
|
|
}
|
|
|
|
func BenchmarkAllMapsSize(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
pops := make([]*AllMaps, 1000)
|
|
for i := 0; i < 1000; i++ {
|
|
pops[i] = NewPopulatedAllMaps(popr, false)
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
total += pops[i%1000].Size()
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func TestAllMapsOrderedSize(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedAllMapsOrdered(popr, true)
|
|
size2 := github_com_gogo_protobuf_proto.Size(p)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
size := p.Size()
|
|
if len(dAtA) != size {
|
|
t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA))
|
|
}
|
|
if size2 != size {
|
|
t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2)
|
|
}
|
|
size3 := github_com_gogo_protobuf_proto.Size(p)
|
|
if size3 != size {
|
|
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
|
|
}
|
|
}
|
|
|
|
func BenchmarkAllMapsOrderedSize(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
pops := make([]*AllMapsOrdered, 1000)
|
|
for i := 0; i < 1000; i++ {
|
|
pops[i] = NewPopulatedAllMapsOrdered(popr, false)
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
total += pops[i%1000].Size()
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func TestMessageWithMapSize(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedMessageWithMap(popr, true)
|
|
size2 := github_com_gogo_protobuf_proto.Size(p)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
size := p.Size()
|
|
if len(dAtA) != size {
|
|
t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA))
|
|
}
|
|
if size2 != size {
|
|
t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2)
|
|
}
|
|
size3 := github_com_gogo_protobuf_proto.Size(p)
|
|
if size3 != size {
|
|
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
|
|
}
|
|
}
|
|
|
|
func BenchmarkMessageWithMapSize(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
pops := make([]*MessageWithMap, 1000)
|
|
for i := 0; i < 1000; i++ {
|
|
pops[i] = NewPopulatedMessageWithMap(popr, false)
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
total += pops[i%1000].Size()
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func TestFloatingPointSize(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedFloatingPoint(popr, true)
|
|
size2 := github_com_gogo_protobuf_proto.Size(p)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
size := p.Size()
|
|
if len(dAtA) != size {
|
|
t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA))
|
|
}
|
|
if size2 != size {
|
|
t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2)
|
|
}
|
|
size3 := github_com_gogo_protobuf_proto.Size(p)
|
|
if size3 != size {
|
|
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
|
|
}
|
|
}
|
|
|
|
func BenchmarkFloatingPointSize(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
pops := make([]*FloatingPoint, 1000)
|
|
for i := 0; i < 1000; i++ {
|
|
pops[i] = NewPopulatedFloatingPoint(popr, false)
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
total += pops[i%1000].Size()
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func TestUint128PairSize(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedUint128Pair(popr, true)
|
|
size2 := github_com_gogo_protobuf_proto.Size(p)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
size := p.Size()
|
|
if len(dAtA) != size {
|
|
t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA))
|
|
}
|
|
if size2 != size {
|
|
t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2)
|
|
}
|
|
size3 := github_com_gogo_protobuf_proto.Size(p)
|
|
if size3 != size {
|
|
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
|
|
}
|
|
}
|
|
|
|
func BenchmarkUint128PairSize(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
pops := make([]*Uint128Pair, 1000)
|
|
for i := 0; i < 1000; i++ {
|
|
pops[i] = NewPopulatedUint128Pair(popr, false)
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
total += pops[i%1000].Size()
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func TestContainsNestedMapSize(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedContainsNestedMap(popr, true)
|
|
size2 := github_com_gogo_protobuf_proto.Size(p)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
size := p.Size()
|
|
if len(dAtA) != size {
|
|
t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA))
|
|
}
|
|
if size2 != size {
|
|
t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2)
|
|
}
|
|
size3 := github_com_gogo_protobuf_proto.Size(p)
|
|
if size3 != size {
|
|
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
|
|
}
|
|
}
|
|
|
|
func BenchmarkContainsNestedMapSize(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
pops := make([]*ContainsNestedMap, 1000)
|
|
for i := 0; i < 1000; i++ {
|
|
pops[i] = NewPopulatedContainsNestedMap(popr, false)
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
total += pops[i%1000].Size()
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func TestContainsNestedMap_NestedMapSize(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedContainsNestedMap_NestedMap(popr, true)
|
|
size2 := github_com_gogo_protobuf_proto.Size(p)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
size := p.Size()
|
|
if len(dAtA) != size {
|
|
t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA))
|
|
}
|
|
if size2 != size {
|
|
t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2)
|
|
}
|
|
size3 := github_com_gogo_protobuf_proto.Size(p)
|
|
if size3 != size {
|
|
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
|
|
}
|
|
}
|
|
|
|
func BenchmarkContainsNestedMap_NestedMapSize(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
pops := make([]*ContainsNestedMap_NestedMap, 1000)
|
|
for i := 0; i < 1000; i++ {
|
|
pops[i] = NewPopulatedContainsNestedMap_NestedMap(popr, false)
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
total += pops[i%1000].Size()
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func TestNotPackedSize(t *testing.T) {
|
|
seed := time.Now().UnixNano()
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
|
p := NewPopulatedNotPacked(popr, true)
|
|
size2 := github_com_gogo_protobuf_proto.Size(p)
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
|
if err != nil {
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
}
|
|
size := p.Size()
|
|
if len(dAtA) != size {
|
|
t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA))
|
|
}
|
|
if size2 != size {
|
|
t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2)
|
|
}
|
|
size3 := github_com_gogo_protobuf_proto.Size(p)
|
|
if size3 != size {
|
|
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
|
|
}
|
|
}
|
|
|
|
func BenchmarkNotPackedSize(b *testing.B) {
|
|
popr := math_rand.New(math_rand.NewSource(616))
|
|
total := 0
|
|
pops := make([]*NotPacked, 1000)
|
|
for i := 0; i < 1000; i++ {
|
|
pops[i] = NewPopulatedNotPacked(popr, false)
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
total += pops[i%1000].Size()
|
|
}
|
|
b.SetBytes(int64(total / b.N))
|
|
}
|
|
|
|
func TestMessageStringer(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedMessage(popr, false)
|
|
s1 := p.String()
|
|
s2 := fmt.Sprintf("%v", p)
|
|
if s1 != s2 {
|
|
t.Fatalf("String want %v got %v", s1, s2)
|
|
}
|
|
}
|
|
func TestNestedStringer(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedNested(popr, false)
|
|
s1 := p.String()
|
|
s2 := fmt.Sprintf("%v", p)
|
|
if s1 != s2 {
|
|
t.Fatalf("String want %v got %v", s1, s2)
|
|
}
|
|
}
|
|
func TestAllMapsStringer(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedAllMaps(popr, false)
|
|
s1 := p.String()
|
|
s2 := fmt.Sprintf("%v", p)
|
|
if s1 != s2 {
|
|
t.Fatalf("String want %v got %v", s1, s2)
|
|
}
|
|
}
|
|
func TestAllMapsOrderedStringer(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedAllMapsOrdered(popr, false)
|
|
s1 := p.String()
|
|
s2 := fmt.Sprintf("%v", p)
|
|
if s1 != s2 {
|
|
t.Fatalf("String want %v got %v", s1, s2)
|
|
}
|
|
}
|
|
func TestMessageWithMapStringer(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedMessageWithMap(popr, false)
|
|
s1 := p.String()
|
|
s2 := fmt.Sprintf("%v", p)
|
|
if s1 != s2 {
|
|
t.Fatalf("String want %v got %v", s1, s2)
|
|
}
|
|
}
|
|
func TestFloatingPointStringer(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedFloatingPoint(popr, false)
|
|
s1 := p.String()
|
|
s2 := fmt.Sprintf("%v", p)
|
|
if s1 != s2 {
|
|
t.Fatalf("String want %v got %v", s1, s2)
|
|
}
|
|
}
|
|
func TestUint128PairStringer(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedUint128Pair(popr, false)
|
|
s1 := p.String()
|
|
s2 := fmt.Sprintf("%v", p)
|
|
if s1 != s2 {
|
|
t.Fatalf("String want %v got %v", s1, s2)
|
|
}
|
|
}
|
|
func TestContainsNestedMapStringer(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedContainsNestedMap(popr, false)
|
|
s1 := p.String()
|
|
s2 := fmt.Sprintf("%v", p)
|
|
if s1 != s2 {
|
|
t.Fatalf("String want %v got %v", s1, s2)
|
|
}
|
|
}
|
|
func TestContainsNestedMap_NestedMapStringer(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedContainsNestedMap_NestedMap(popr, false)
|
|
s1 := p.String()
|
|
s2 := fmt.Sprintf("%v", p)
|
|
if s1 != s2 {
|
|
t.Fatalf("String want %v got %v", s1, s2)
|
|
}
|
|
}
|
|
func TestNotPackedStringer(t *testing.T) {
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
|
p := NewPopulatedNotPacked(popr, false)
|
|
s1 := p.String()
|
|
s2 := fmt.Sprintf("%v", p)
|
|
if s1 != s2 {
|
|
t.Fatalf("String want %v got %v", s1, s2)
|
|
}
|
|
}
|
|
|
|
//These tests are generated by github.com/gogo/protobuf/plugin/testgen
|