syncthing/vendor/github.com/gogo/protobuf/test/example/examplepb_test.go
Jakob Borg 916ec63af6 cmd/stdiscosrv: New discovery server (fixes #4618)
This is a new revision of the discovery server. Relevant changes and
non-changes:

- Protocol towards clients is unchanged.

- Recommended large scale design is still to be deployed nehind nginx (I
  tested, and it's still a lot faster at terminating TLS).

- Database backend is leveldb again, only. It scales enough, is easy to
  setup, and we don't need any backend to take care of.

- Server supports replication. This is a simple TCP channel - protect it
  with a firewall when deploying over the internet. (We deploy this within
  the same datacenter, and with firewall.) Any incoming client announces
  are sent over the replication channel(s) to other peer discosrvs.
  Incoming replication changes are applied to the database as if they came
  from clients, but without the TLS/certificate overhead.

- Metrics are exposed using the prometheus library, when enabled.

- The database values and replication protocol is protobuf, because JSON
  was quite CPU intensive when I tried that and benchmarked it.

- The "Retry-After" value for failed lookups gets slowly increased from
  a default of 120 seconds, by 5 seconds for each failed lookup,
  independently by each discosrv. This lowers the query load over time for
  clients that are never seen. The Retry-After maxes out at 3600 after a
  couple of weeks of this increase. The number of failed lookups is
  stored in the database, now and then (avoiding making each lookup a
  database put).

All in all this means clients can be pointed towards a cluster using
just multiple A / AAAA records to gain both load sharing and redundancy
(if one is down, clients will talk to the remaining ones).

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4648
2018-01-14 08:52:31 +00:00

1671 lines
42 KiB
Go

// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: example.proto
/*
Package test is a generated protocol buffer package.
It is generated from these files:
example.proto
It has these top-level messages:
A
B
C
U
E
R
CastType
*/
package test
import testing "testing"
import rand "math/rand"
import time "time"
import proto "github.com/gogo/protobuf/proto"
import jsonpb "github.com/gogo/protobuf/jsonpb"
import fmt "fmt"
import parser "go/parser"
import math "math"
import _ "github.com/gogo/protobuf/gogoproto"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
func TestAProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedA(popr, false)
dAtA, err := proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &A{}
if err := 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
_ = proto.Unmarshal(littlefuzz, msg)
}
}
func TestAMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedA(popr, false)
size := p.Size()
dAtA := make([]byte, size)
for i := range dAtA {
dAtA[i] = byte(popr.Intn(256))
}
_, err := p.MarshalTo(dAtA)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &A{}
if err := proto.Unmarshal(dAtA, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
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)
}
}
func BenchmarkAProtoMarshal(b *testing.B) {
popr := rand.New(rand.NewSource(616))
total := 0
pops := make([]*A, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedA(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
dAtA, err := proto.Marshal(pops[i%10000])
if err != nil {
panic(err)
}
total += len(dAtA)
}
b.SetBytes(int64(total / b.N))
}
func BenchmarkAProtoUnmarshal(b *testing.B) {
popr := rand.New(rand.NewSource(616))
total := 0
datas := make([][]byte, 10000)
for i := 0; i < 10000; i++ {
dAtA, err := proto.Marshal(NewPopulatedA(popr, false))
if err != nil {
panic(err)
}
datas[i] = dAtA
}
msg := &A{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += len(datas[i%10000])
if err := proto.Unmarshal(datas[i%10000], msg); err != nil {
panic(err)
}
}
b.SetBytes(int64(total / b.N))
}
func TestBProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedB(popr, false)
dAtA, err := proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &B{}
if err := 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
_ = proto.Unmarshal(littlefuzz, msg)
}
}
func TestBMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedB(popr, false)
size := p.Size()
dAtA := make([]byte, size)
for i := range dAtA {
dAtA[i] = byte(popr.Intn(256))
}
_, err := p.MarshalTo(dAtA)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &B{}
if err := proto.Unmarshal(dAtA, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
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)
}
}
func BenchmarkBProtoMarshal(b *testing.B) {
popr := rand.New(rand.NewSource(616))
total := 0
pops := make([]*B, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedB(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
dAtA, err := proto.Marshal(pops[i%10000])
if err != nil {
panic(err)
}
total += len(dAtA)
}
b.SetBytes(int64(total / b.N))
}
func BenchmarkBProtoUnmarshal(b *testing.B) {
popr := rand.New(rand.NewSource(616))
total := 0
datas := make([][]byte, 10000)
for i := 0; i < 10000; i++ {
dAtA, err := proto.Marshal(NewPopulatedB(popr, false))
if err != nil {
panic(err)
}
datas[i] = dAtA
}
msg := &B{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += len(datas[i%10000])
if err := proto.Unmarshal(datas[i%10000], msg); err != nil {
panic(err)
}
}
b.SetBytes(int64(total / b.N))
}
func TestCProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedC(popr, false)
dAtA, err := proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &C{}
if err := 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
_ = proto.Unmarshal(littlefuzz, msg)
}
}
func TestCMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedC(popr, false)
size := p.Size()
dAtA := make([]byte, size)
for i := range dAtA {
dAtA[i] = byte(popr.Intn(256))
}
_, err := p.MarshalTo(dAtA)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &C{}
if err := proto.Unmarshal(dAtA, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
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)
}
}
func BenchmarkCProtoMarshal(b *testing.B) {
popr := rand.New(rand.NewSource(616))
total := 0
pops := make([]*C, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedC(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
dAtA, err := proto.Marshal(pops[i%10000])
if err != nil {
panic(err)
}
total += len(dAtA)
}
b.SetBytes(int64(total / b.N))
}
func BenchmarkCProtoUnmarshal(b *testing.B) {
popr := rand.New(rand.NewSource(616))
total := 0
datas := make([][]byte, 10000)
for i := 0; i < 10000; i++ {
dAtA, err := proto.Marshal(NewPopulatedC(popr, false))
if err != nil {
panic(err)
}
datas[i] = dAtA
}
msg := &C{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += len(datas[i%10000])
if err := proto.Unmarshal(datas[i%10000], msg); err != nil {
panic(err)
}
}
b.SetBytes(int64(total / b.N))
}
func TestUProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedU(popr, false)
dAtA, err := proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &U{}
if err := 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
_ = proto.Unmarshal(littlefuzz, msg)
}
}
func TestUMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedU(popr, false)
size := p.Size()
dAtA := make([]byte, size)
for i := range dAtA {
dAtA[i] = byte(popr.Intn(256))
}
_, err := p.MarshalTo(dAtA)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &U{}
if err := proto.Unmarshal(dAtA, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
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)
}
}
func BenchmarkUProtoMarshal(b *testing.B) {
popr := rand.New(rand.NewSource(616))
total := 0
pops := make([]*U, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedU(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
dAtA, err := proto.Marshal(pops[i%10000])
if err != nil {
panic(err)
}
total += len(dAtA)
}
b.SetBytes(int64(total / b.N))
}
func BenchmarkUProtoUnmarshal(b *testing.B) {
popr := rand.New(rand.NewSource(616))
total := 0
datas := make([][]byte, 10000)
for i := 0; i < 10000; i++ {
dAtA, err := proto.Marshal(NewPopulatedU(popr, false))
if err != nil {
panic(err)
}
datas[i] = dAtA
}
msg := &U{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += len(datas[i%10000])
if err := proto.Unmarshal(datas[i%10000], msg); err != nil {
panic(err)
}
}
b.SetBytes(int64(total / b.N))
}
func TestEProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedE(popr, false)
dAtA, err := proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &E{}
if err := 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
_ = proto.Unmarshal(littlefuzz, msg)
}
}
func TestEMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedE(popr, false)
size := p.Size()
dAtA := make([]byte, size)
for i := range dAtA {
dAtA[i] = byte(popr.Intn(256))
}
_, err := p.MarshalTo(dAtA)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &E{}
if err := proto.Unmarshal(dAtA, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
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)
}
}
func BenchmarkEProtoMarshal(b *testing.B) {
popr := rand.New(rand.NewSource(616))
total := 0
pops := make([]*E, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedE(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
dAtA, err := proto.Marshal(pops[i%10000])
if err != nil {
panic(err)
}
total += len(dAtA)
}
b.SetBytes(int64(total / b.N))
}
func BenchmarkEProtoUnmarshal(b *testing.B) {
popr := rand.New(rand.NewSource(616))
total := 0
datas := make([][]byte, 10000)
for i := 0; i < 10000; i++ {
dAtA, err := proto.Marshal(NewPopulatedE(popr, false))
if err != nil {
panic(err)
}
datas[i] = dAtA
}
msg := &E{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += len(datas[i%10000])
if err := proto.Unmarshal(datas[i%10000], msg); err != nil {
panic(err)
}
}
b.SetBytes(int64(total / b.N))
}
func TestRProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedR(popr, false)
dAtA, err := proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &R{}
if err := 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
_ = proto.Unmarshal(littlefuzz, msg)
}
}
func TestRMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedR(popr, false)
size := p.Size()
dAtA := make([]byte, size)
for i := range dAtA {
dAtA[i] = byte(popr.Intn(256))
}
_, err := p.MarshalTo(dAtA)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &R{}
if err := proto.Unmarshal(dAtA, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
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)
}
}
func BenchmarkRProtoMarshal(b *testing.B) {
popr := rand.New(rand.NewSource(616))
total := 0
pops := make([]*R, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedR(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
dAtA, err := proto.Marshal(pops[i%10000])
if err != nil {
panic(err)
}
total += len(dAtA)
}
b.SetBytes(int64(total / b.N))
}
func BenchmarkRProtoUnmarshal(b *testing.B) {
popr := rand.New(rand.NewSource(616))
total := 0
datas := make([][]byte, 10000)
for i := 0; i < 10000; i++ {
dAtA, err := proto.Marshal(NewPopulatedR(popr, false))
if err != nil {
panic(err)
}
datas[i] = dAtA
}
msg := &R{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += len(datas[i%10000])
if err := proto.Unmarshal(datas[i%10000], msg); err != nil {
panic(err)
}
}
b.SetBytes(int64(total / b.N))
}
func TestCastTypeProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedCastType(popr, false)
dAtA, err := proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &CastType{}
if err := 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
_ = proto.Unmarshal(littlefuzz, msg)
}
}
func TestCastTypeMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedCastType(popr, false)
size := p.Size()
dAtA := make([]byte, size)
for i := range dAtA {
dAtA[i] = byte(popr.Intn(256))
}
_, err := p.MarshalTo(dAtA)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &CastType{}
if err := proto.Unmarshal(dAtA, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
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)
}
}
func BenchmarkCastTypeProtoMarshal(b *testing.B) {
popr := rand.New(rand.NewSource(616))
total := 0
pops := make([]*CastType, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedCastType(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
dAtA, err := proto.Marshal(pops[i%10000])
if err != nil {
panic(err)
}
total += len(dAtA)
}
b.SetBytes(int64(total / b.N))
}
func BenchmarkCastTypeProtoUnmarshal(b *testing.B) {
popr := rand.New(rand.NewSource(616))
total := 0
datas := make([][]byte, 10000)
for i := 0; i < 10000; i++ {
dAtA, err := proto.Marshal(NewPopulatedCastType(popr, false))
if err != nil {
panic(err)
}
datas[i] = dAtA
}
msg := &CastType{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += len(datas[i%10000])
if err := proto.Unmarshal(datas[i%10000], msg); err != nil {
panic(err)
}
}
b.SetBytes(int64(total / b.N))
}
func TestAJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedA(popr, true)
marshaler := jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &A{}
err = 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 TestBJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedB(popr, true)
marshaler := jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &B{}
err = 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 TestCJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedC(popr, true)
marshaler := jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &C{}
err = 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 TestUJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedU(popr, true)
marshaler := jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &U{}
err = 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 TestEJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedE(popr, true)
marshaler := jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &E{}
err = 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 TestRJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedR(popr, true)
marshaler := jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &R{}
err = 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 TestCastTypeJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedCastType(popr, true)
marshaler := jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &CastType{}
err = 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 TestAProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedA(popr, true)
dAtA := proto.MarshalTextString(p)
msg := &A{}
if err := 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 TestAProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedA(popr, true)
dAtA := proto.CompactTextString(p)
msg := &A{}
if err := 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 TestBProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedB(popr, true)
dAtA := proto.MarshalTextString(p)
msg := &B{}
if err := 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 TestBProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedB(popr, true)
dAtA := proto.CompactTextString(p)
msg := &B{}
if err := 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 TestCProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedC(popr, true)
dAtA := proto.MarshalTextString(p)
msg := &C{}
if err := 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 TestCProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedC(popr, true)
dAtA := proto.CompactTextString(p)
msg := &C{}
if err := 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 TestUProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedU(popr, true)
dAtA := proto.MarshalTextString(p)
msg := &U{}
if err := 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 TestUProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedU(popr, true)
dAtA := proto.CompactTextString(p)
msg := &U{}
if err := 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 TestEProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedE(popr, true)
dAtA := proto.MarshalTextString(p)
msg := &E{}
if err := 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 TestEProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedE(popr, true)
dAtA := proto.CompactTextString(p)
msg := &E{}
if err := 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 TestRProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedR(popr, true)
dAtA := proto.MarshalTextString(p)
msg := &R{}
if err := 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 TestRProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedR(popr, true)
dAtA := proto.CompactTextString(p)
msg := &R{}
if err := 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 TestCastTypeProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedCastType(popr, true)
dAtA := proto.MarshalTextString(p)
msg := &CastType{}
if err := 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 TestCastTypeProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedCastType(popr, true)
dAtA := proto.CompactTextString(p)
msg := &CastType{}
if err := 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 TestExampleDescription(t *testing.T) {
ExampleDescription()
}
func TestAVerboseEqual(t *testing.T) {
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedA(popr, false)
dAtA, err := proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &A{}
if err := 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 TestBVerboseEqual(t *testing.T) {
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedB(popr, false)
dAtA, err := proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &B{}
if err := 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 TestCVerboseEqual(t *testing.T) {
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedC(popr, false)
dAtA, err := proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &C{}
if err := 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 TestUVerboseEqual(t *testing.T) {
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedU(popr, false)
dAtA, err := proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &U{}
if err := 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 TestEVerboseEqual(t *testing.T) {
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedE(popr, false)
dAtA, err := proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &E{}
if err := 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 TestRVerboseEqual(t *testing.T) {
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedR(popr, false)
dAtA, err := proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &R{}
if err := 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 TestCastTypeVerboseEqual(t *testing.T) {
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastType(popr, false)
dAtA, err := proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &CastType{}
if err := 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 TestAFace(t *testing.T) {
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedA(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestAGoString(t *testing.T) {
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedA(popr, false)
s1 := p.GoString()
s2 := fmt.Sprintf("%#v", p)
if s1 != s2 {
t.Fatalf("GoString want %v got %v", s1, s2)
}
_, err := parser.ParseExpr(s1)
if err != nil {
t.Fatal(err)
}
}
func TestBGoString(t *testing.T) {
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedB(popr, false)
s1 := p.GoString()
s2 := fmt.Sprintf("%#v", p)
if s1 != s2 {
t.Fatalf("GoString want %v got %v", s1, s2)
}
_, err := parser.ParseExpr(s1)
if err != nil {
t.Fatal(err)
}
}
func TestCGoString(t *testing.T) {
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedC(popr, false)
s1 := p.GoString()
s2 := fmt.Sprintf("%#v", p)
if s1 != s2 {
t.Fatalf("GoString want %v got %v", s1, s2)
}
_, err := parser.ParseExpr(s1)
if err != nil {
t.Fatal(err)
}
}
func TestUGoString(t *testing.T) {
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedU(popr, false)
s1 := p.GoString()
s2 := fmt.Sprintf("%#v", p)
if s1 != s2 {
t.Fatalf("GoString want %v got %v", s1, s2)
}
_, err := parser.ParseExpr(s1)
if err != nil {
t.Fatal(err)
}
}
func TestEGoString(t *testing.T) {
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedE(popr, false)
s1 := p.GoString()
s2 := fmt.Sprintf("%#v", p)
if s1 != s2 {
t.Fatalf("GoString want %v got %v", s1, s2)
}
_, err := parser.ParseExpr(s1)
if err != nil {
t.Fatal(err)
}
}
func TestRGoString(t *testing.T) {
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedR(popr, false)
s1 := p.GoString()
s2 := fmt.Sprintf("%#v", p)
if s1 != s2 {
t.Fatalf("GoString want %v got %v", s1, s2)
}
_, err := parser.ParseExpr(s1)
if err != nil {
t.Fatal(err)
}
}
func TestCastTypeGoString(t *testing.T) {
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastType(popr, false)
s1 := p.GoString()
s2 := fmt.Sprintf("%#v", p)
if s1 != s2 {
t.Fatalf("GoString want %v got %v", s1, s2)
}
_, err := parser.ParseExpr(s1)
if err != nil {
t.Fatal(err)
}
}
func TestASize(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedA(popr, true)
size2 := proto.Size(p)
dAtA, err := 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 := proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkASize(b *testing.B) {
popr := rand.New(rand.NewSource(616))
total := 0
pops := make([]*A, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedA(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestBSize(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedB(popr, true)
size2 := proto.Size(p)
dAtA, err := 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 := proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkBSize(b *testing.B) {
popr := rand.New(rand.NewSource(616))
total := 0
pops := make([]*B, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedB(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestCSize(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedC(popr, true)
size2 := proto.Size(p)
dAtA, err := 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 := proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkCSize(b *testing.B) {
popr := rand.New(rand.NewSource(616))
total := 0
pops := make([]*C, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedC(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestUSize(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedU(popr, true)
size2 := proto.Size(p)
dAtA, err := 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 := proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkUSize(b *testing.B) {
popr := rand.New(rand.NewSource(616))
total := 0
pops := make([]*U, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedU(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestESize(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedE(popr, true)
size2 := proto.Size(p)
dAtA, err := 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 := proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkESize(b *testing.B) {
popr := rand.New(rand.NewSource(616))
total := 0
pops := make([]*E, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedE(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestRSize(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedR(popr, true)
size2 := proto.Size(p)
dAtA, err := 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 := proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkRSize(b *testing.B) {
popr := rand.New(rand.NewSource(616))
total := 0
pops := make([]*R, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedR(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestCastTypeSize(t *testing.T) {
seed := time.Now().UnixNano()
popr := rand.New(rand.NewSource(seed))
p := NewPopulatedCastType(popr, true)
size2 := proto.Size(p)
dAtA, err := 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 := proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkCastTypeSize(b *testing.B) {
popr := rand.New(rand.NewSource(616))
total := 0
pops := make([]*CastType, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedCastType(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestAStringer(t *testing.T) {
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedA(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
func TestBStringer(t *testing.T) {
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedB(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
func TestCStringer(t *testing.T) {
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedC(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
func TestUStringer(t *testing.T) {
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedU(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
func TestEStringer(t *testing.T) {
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedE(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
func TestRStringer(t *testing.T) {
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedR(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
func TestCastTypeStringer(t *testing.T) {
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastType(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
func TestUOnlyOne(t *testing.T) {
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedU(popr, true)
v := p.GetValue()
msg := &U{}
if !msg.SetValue(v) {
t.Fatalf("OnlyOne: Could not set Value")
}
if !p.Equal(msg) {
t.Fatalf("%#v !OnlyOne Equal %#v", msg, p)
}
}
//These tests are generated by github.com/gogo/protobuf/plugin/testgen