mirror of
https://github.com/genuinetools/reg.git
synced 2024-08-24 23:20:23 -04:00
808 lines
22 KiB
Go
808 lines
22 KiB
Go
![]() |
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||
|
// source: stdtypes.proto
|
||
|
|
||
|
/*
|
||
|
Package stdtypes is a generated protocol buffer package.
|
||
|
|
||
|
It is generated from these files:
|
||
|
stdtypes.proto
|
||
|
|
||
|
It has these top-level messages:
|
||
|
StdTypes
|
||
|
RepStdTypes
|
||
|
MapStdTypes
|
||
|
OneofStdTypes
|
||
|
*/
|
||
|
package stdtypes
|
||
|
|
||
|
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"
|
||
|
import _ "github.com/gogo/protobuf/types"
|
||
|
import _ "github.com/gogo/protobuf/types"
|
||
|
|
||
|
// Reference imports to suppress errors if they are not otherwise used.
|
||
|
var _ = proto.Marshal
|
||
|
var _ = fmt.Errorf
|
||
|
var _ = math.Inf
|
||
|
|
||
|
func TestStdTypesProto(t *testing.T) {
|
||
|
seed := time.Now().UnixNano()
|
||
|
popr := rand.New(rand.NewSource(seed))
|
||
|
p := NewPopulatedStdTypes(popr, false)
|
||
|
dAtA, err := proto.Marshal(p)
|
||
|
if err != nil {
|
||
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
||
|
}
|
||
|
msg := &StdTypes{}
|
||
|
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 BenchmarkStdTypesProtoMarshal(b *testing.B) {
|
||
|
popr := rand.New(rand.NewSource(616))
|
||
|
total := 0
|
||
|
pops := make([]*StdTypes, 10000)
|
||
|
for i := 0; i < 10000; i++ {
|
||
|
pops[i] = NewPopulatedStdTypes(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 BenchmarkStdTypesProtoUnmarshal(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(NewPopulatedStdTypes(popr, false))
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
datas[i] = dAtA
|
||
|
}
|
||
|
msg := &StdTypes{}
|
||
|
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 TestRepStdTypesProto(t *testing.T) {
|
||
|
seed := time.Now().UnixNano()
|
||
|
popr := rand.New(rand.NewSource(seed))
|
||
|
p := NewPopulatedRepStdTypes(popr, false)
|
||
|
dAtA, err := proto.Marshal(p)
|
||
|
if err != nil {
|
||
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
||
|
}
|
||
|
msg := &RepStdTypes{}
|
||
|
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 BenchmarkRepStdTypesProtoMarshal(b *testing.B) {
|
||
|
popr := rand.New(rand.NewSource(616))
|
||
|
total := 0
|
||
|
pops := make([]*RepStdTypes, 10000)
|
||
|
for i := 0; i < 10000; i++ {
|
||
|
pops[i] = NewPopulatedRepStdTypes(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 BenchmarkRepStdTypesProtoUnmarshal(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(NewPopulatedRepStdTypes(popr, false))
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
datas[i] = dAtA
|
||
|
}
|
||
|
msg := &RepStdTypes{}
|
||
|
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 TestMapStdTypesProto(t *testing.T) {
|
||
|
seed := time.Now().UnixNano()
|
||
|
popr := rand.New(rand.NewSource(seed))
|
||
|
p := NewPopulatedMapStdTypes(popr, false)
|
||
|
dAtA, err := proto.Marshal(p)
|
||
|
if err != nil {
|
||
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
||
|
}
|
||
|
msg := &MapStdTypes{}
|
||
|
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 BenchmarkMapStdTypesProtoMarshal(b *testing.B) {
|
||
|
popr := rand.New(rand.NewSource(616))
|
||
|
total := 0
|
||
|
pops := make([]*MapStdTypes, 10000)
|
||
|
for i := 0; i < 10000; i++ {
|
||
|
pops[i] = NewPopulatedMapStdTypes(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 BenchmarkMapStdTypesProtoUnmarshal(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(NewPopulatedMapStdTypes(popr, false))
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
datas[i] = dAtA
|
||
|
}
|
||
|
msg := &MapStdTypes{}
|
||
|
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 TestOneofStdTypesProto(t *testing.T) {
|
||
|
seed := time.Now().UnixNano()
|
||
|
popr := rand.New(rand.NewSource(seed))
|
||
|
p := NewPopulatedOneofStdTypes(popr, false)
|
||
|
dAtA, err := proto.Marshal(p)
|
||
|
if err != nil {
|
||
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
||
|
}
|
||
|
msg := &OneofStdTypes{}
|
||
|
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 BenchmarkOneofStdTypesProtoMarshal(b *testing.B) {
|
||
|
popr := rand.New(rand.NewSource(616))
|
||
|
total := 0
|
||
|
pops := make([]*OneofStdTypes, 10000)
|
||
|
for i := 0; i < 10000; i++ {
|
||
|
pops[i] = NewPopulatedOneofStdTypes(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 BenchmarkOneofStdTypesProtoUnmarshal(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(NewPopulatedOneofStdTypes(popr, false))
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
datas[i] = dAtA
|
||
|
}
|
||
|
msg := &OneofStdTypes{}
|
||
|
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 TestStdTypesJSON(t *testing.T) {
|
||
|
seed := time.Now().UnixNano()
|
||
|
popr := rand.New(rand.NewSource(seed))
|
||
|
p := NewPopulatedStdTypes(popr, true)
|
||
|
marshaler := jsonpb.Marshaler{}
|
||
|
jsondata, err := marshaler.MarshalToString(p)
|
||
|
if err != nil {
|
||
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
||
|
}
|
||
|
msg := &StdTypes{}
|
||
|
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 TestRepStdTypesJSON(t *testing.T) {
|
||
|
seed := time.Now().UnixNano()
|
||
|
popr := rand.New(rand.NewSource(seed))
|
||
|
p := NewPopulatedRepStdTypes(popr, true)
|
||
|
marshaler := jsonpb.Marshaler{}
|
||
|
jsondata, err := marshaler.MarshalToString(p)
|
||
|
if err != nil {
|
||
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
||
|
}
|
||
|
msg := &RepStdTypes{}
|
||
|
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 TestMapStdTypesJSON(t *testing.T) {
|
||
|
seed := time.Now().UnixNano()
|
||
|
popr := rand.New(rand.NewSource(seed))
|
||
|
p := NewPopulatedMapStdTypes(popr, true)
|
||
|
marshaler := jsonpb.Marshaler{}
|
||
|
jsondata, err := marshaler.MarshalToString(p)
|
||
|
if err != nil {
|
||
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
||
|
}
|
||
|
msg := &MapStdTypes{}
|
||
|
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 TestOneofStdTypesJSON(t *testing.T) {
|
||
|
seed := time.Now().UnixNano()
|
||
|
popr := rand.New(rand.NewSource(seed))
|
||
|
p := NewPopulatedOneofStdTypes(popr, true)
|
||
|
marshaler := jsonpb.Marshaler{}
|
||
|
jsondata, err := marshaler.MarshalToString(p)
|
||
|
if err != nil {
|
||
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
||
|
}
|
||
|
msg := &OneofStdTypes{}
|
||
|
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 TestStdTypesProtoText(t *testing.T) {
|
||
|
seed := time.Now().UnixNano()
|
||
|
popr := rand.New(rand.NewSource(seed))
|
||
|
p := NewPopulatedStdTypes(popr, true)
|
||
|
dAtA := proto.MarshalTextString(p)
|
||
|
msg := &StdTypes{}
|
||
|
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 TestStdTypesProtoCompactText(t *testing.T) {
|
||
|
seed := time.Now().UnixNano()
|
||
|
popr := rand.New(rand.NewSource(seed))
|
||
|
p := NewPopulatedStdTypes(popr, true)
|
||
|
dAtA := proto.CompactTextString(p)
|
||
|
msg := &StdTypes{}
|
||
|
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 TestRepStdTypesProtoText(t *testing.T) {
|
||
|
seed := time.Now().UnixNano()
|
||
|
popr := rand.New(rand.NewSource(seed))
|
||
|
p := NewPopulatedRepStdTypes(popr, true)
|
||
|
dAtA := proto.MarshalTextString(p)
|
||
|
msg := &RepStdTypes{}
|
||
|
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 TestRepStdTypesProtoCompactText(t *testing.T) {
|
||
|
seed := time.Now().UnixNano()
|
||
|
popr := rand.New(rand.NewSource(seed))
|
||
|
p := NewPopulatedRepStdTypes(popr, true)
|
||
|
dAtA := proto.CompactTextString(p)
|
||
|
msg := &RepStdTypes{}
|
||
|
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 TestMapStdTypesProtoText(t *testing.T) {
|
||
|
seed := time.Now().UnixNano()
|
||
|
popr := rand.New(rand.NewSource(seed))
|
||
|
p := NewPopulatedMapStdTypes(popr, true)
|
||
|
dAtA := proto.MarshalTextString(p)
|
||
|
msg := &MapStdTypes{}
|
||
|
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 TestMapStdTypesProtoCompactText(t *testing.T) {
|
||
|
seed := time.Now().UnixNano()
|
||
|
popr := rand.New(rand.NewSource(seed))
|
||
|
p := NewPopulatedMapStdTypes(popr, true)
|
||
|
dAtA := proto.CompactTextString(p)
|
||
|
msg := &MapStdTypes{}
|
||
|
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 TestOneofStdTypesProtoText(t *testing.T) {
|
||
|
seed := time.Now().UnixNano()
|
||
|
popr := rand.New(rand.NewSource(seed))
|
||
|
p := NewPopulatedOneofStdTypes(popr, true)
|
||
|
dAtA := proto.MarshalTextString(p)
|
||
|
msg := &OneofStdTypes{}
|
||
|
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 TestOneofStdTypesProtoCompactText(t *testing.T) {
|
||
|
seed := time.Now().UnixNano()
|
||
|
popr := rand.New(rand.NewSource(seed))
|
||
|
p := NewPopulatedOneofStdTypes(popr, true)
|
||
|
dAtA := proto.CompactTextString(p)
|
||
|
msg := &OneofStdTypes{}
|
||
|
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 TestStdTypesVerboseEqual(t *testing.T) {
|
||
|
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||
|
p := NewPopulatedStdTypes(popr, false)
|
||
|
dAtA, err := proto.Marshal(p)
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
msg := &StdTypes{}
|
||
|
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 TestRepStdTypesVerboseEqual(t *testing.T) {
|
||
|
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||
|
p := NewPopulatedRepStdTypes(popr, false)
|
||
|
dAtA, err := proto.Marshal(p)
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
msg := &RepStdTypes{}
|
||
|
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 TestMapStdTypesVerboseEqual(t *testing.T) {
|
||
|
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||
|
p := NewPopulatedMapStdTypes(popr, false)
|
||
|
dAtA, err := proto.Marshal(p)
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
msg := &MapStdTypes{}
|
||
|
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 TestOneofStdTypesVerboseEqual(t *testing.T) {
|
||
|
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||
|
p := NewPopulatedOneofStdTypes(popr, false)
|
||
|
dAtA, err := proto.Marshal(p)
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
msg := &OneofStdTypes{}
|
||
|
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 TestStdTypesGoString(t *testing.T) {
|
||
|
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||
|
p := NewPopulatedStdTypes(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 TestRepStdTypesGoString(t *testing.T) {
|
||
|
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||
|
p := NewPopulatedRepStdTypes(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 TestMapStdTypesGoString(t *testing.T) {
|
||
|
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||
|
p := NewPopulatedMapStdTypes(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 TestOneofStdTypesGoString(t *testing.T) {
|
||
|
popr := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||
|
p := NewPopulatedOneofStdTypes(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 TestStdTypesSize(t *testing.T) {
|
||
|
seed := time.Now().UnixNano()
|
||
|
popr := rand.New(rand.NewSource(seed))
|
||
|
p := NewPopulatedStdTypes(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 BenchmarkStdTypesSize(b *testing.B) {
|
||
|
popr := rand.New(rand.NewSource(616))
|
||
|
total := 0
|
||
|
pops := make([]*StdTypes, 1000)
|
||
|
for i := 0; i < 1000; i++ {
|
||
|
pops[i] = NewPopulatedStdTypes(popr, false)
|
||
|
}
|
||
|
b.ResetTimer()
|
||
|
for i := 0; i < b.N; i++ {
|
||
|
total += pops[i%1000].Size()
|
||
|
}
|
||
|
b.SetBytes(int64(total / b.N))
|
||
|
}
|
||
|
|
||
|
func TestRepStdTypesSize(t *testing.T) {
|
||
|
seed := time.Now().UnixNano()
|
||
|
popr := rand.New(rand.NewSource(seed))
|
||
|
p := NewPopulatedRepStdTypes(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 BenchmarkRepStdTypesSize(b *testing.B) {
|
||
|
popr := rand.New(rand.NewSource(616))
|
||
|
total := 0
|
||
|
pops := make([]*RepStdTypes, 1000)
|
||
|
for i := 0; i < 1000; i++ {
|
||
|
pops[i] = NewPopulatedRepStdTypes(popr, false)
|
||
|
}
|
||
|
b.ResetTimer()
|
||
|
for i := 0; i < b.N; i++ {
|
||
|
total += pops[i%1000].Size()
|
||
|
}
|
||
|
b.SetBytes(int64(total / b.N))
|
||
|
}
|
||
|
|
||
|
func TestMapStdTypesSize(t *testing.T) {
|
||
|
seed := time.Now().UnixNano()
|
||
|
popr := rand.New(rand.NewSource(seed))
|
||
|
p := NewPopulatedMapStdTypes(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 BenchmarkMapStdTypesSize(b *testing.B) {
|
||
|
popr := rand.New(rand.NewSource(616))
|
||
|
total := 0
|
||
|
pops := make([]*MapStdTypes, 1000)
|
||
|
for i := 0; i < 1000; i++ {
|
||
|
pops[i] = NewPopulatedMapStdTypes(popr, false)
|
||
|
}
|
||
|
b.ResetTimer()
|
||
|
for i := 0; i < b.N; i++ {
|
||
|
total += pops[i%1000].Size()
|
||
|
}
|
||
|
b.SetBytes(int64(total / b.N))
|
||
|
}
|
||
|
|
||
|
func TestOneofStdTypesSize(t *testing.T) {
|
||
|
seed := time.Now().UnixNano()
|
||
|
popr := rand.New(rand.NewSource(seed))
|
||
|
p := NewPopulatedOneofStdTypes(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 BenchmarkOneofStdTypesSize(b *testing.B) {
|
||
|
popr := rand.New(rand.NewSource(616))
|
||
|
total := 0
|
||
|
pops := make([]*OneofStdTypes, 1000)
|
||
|
for i := 0; i < 1000; i++ {
|
||
|
pops[i] = NewPopulatedOneofStdTypes(popr, false)
|
||
|
}
|
||
|
b.ResetTimer()
|
||
|
for i := 0; i < b.N; i++ {
|
||
|
total += pops[i%1000].Size()
|
||
|
}
|
||
|
b.SetBytes(int64(total / b.N))
|
||
|
}
|
||
|
|
||
|
//These tests are generated by github.com/gogo/protobuf/plugin/testgen
|