/Godeps/_workspace/src/github.com/gogo/protobuf/test/unmarshalmerge/unmarshalmergepb_test.go
https://gitlab.com/JamesClonk/firehose-to-syslog · Go · 477 lines · 443 code · 19 blank · 15 comment · 141 complexity · b3997b105d198c0fb20064a14ab3df96 MD5 · raw file
- // Code generated by protoc-gen-gogo.
- // source: unmarshalmerge.proto
- // DO NOT EDIT!
- /*
- Package unmarshalmerge is a generated protocol buffer package.
- It is generated from these files:
- unmarshalmerge.proto
- It has these top-level messages:
- Big
- BigUnsafe
- Sub
- */
- package unmarshalmerge
- import testing "testing"
- import math_rand "math/rand"
- import time "time"
- import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
- import encoding_json "encoding/json"
- import fmt "fmt"
- import go_parser "go/parser"
- func TestBigProto(t *testing.T) {
- popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
- p := NewPopulatedBig(popr, false)
- data, err := github_com_gogo_protobuf_proto.Marshal(p)
- if err != nil {
- panic(err)
- }
- msg := &Big{}
- if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
- panic(err)
- }
- for i := range data {
- data[i] = byte(popr.Intn(256))
- }
- if err := p.VerboseEqual(msg); err != nil {
- t.Fatalf("%#v !VerboseProto %#v, since %v", msg, p, err)
- }
- if !p.Equal(msg) {
- t.Fatalf("%#v !Proto %#v", msg, p)
- }
- }
- func BenchmarkBigProtoMarshal(b *testing.B) {
- popr := math_rand.New(math_rand.NewSource(616))
- total := 0
- pops := make([]*Big, 10000)
- for i := 0; i < 10000; i++ {
- pops[i] = NewPopulatedBig(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 BenchmarkBigProtoUnmarshal(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(NewPopulatedBig(popr, false))
- if err != nil {
- panic(err)
- }
- datas[i] = data
- }
- msg := &Big{}
- 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 TestBigUnsafeProto(t *testing.T) {
- popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
- p := NewPopulatedBigUnsafe(popr, false)
- data, err := github_com_gogo_protobuf_proto.Marshal(p)
- if err != nil {
- panic(err)
- }
- msg := &BigUnsafe{}
- if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
- panic(err)
- }
- for i := range data {
- data[i] = byte(popr.Intn(256))
- }
- if err := p.VerboseEqual(msg); err != nil {
- t.Fatalf("%#v !VerboseProto %#v, since %v", msg, p, err)
- }
- if !p.Equal(msg) {
- t.Fatalf("%#v !Proto %#v", msg, p)
- }
- }
- func BenchmarkBigUnsafeProtoMarshal(b *testing.B) {
- popr := math_rand.New(math_rand.NewSource(616))
- total := 0
- pops := make([]*BigUnsafe, 10000)
- for i := 0; i < 10000; i++ {
- pops[i] = NewPopulatedBigUnsafe(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 BenchmarkBigUnsafeProtoUnmarshal(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(NewPopulatedBigUnsafe(popr, false))
- if err != nil {
- panic(err)
- }
- datas[i] = data
- }
- msg := &BigUnsafe{}
- 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 TestSubProto(t *testing.T) {
- popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
- p := NewPopulatedSub(popr, false)
- data, err := github_com_gogo_protobuf_proto.Marshal(p)
- if err != nil {
- panic(err)
- }
- msg := &Sub{}
- if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
- panic(err)
- }
- for i := range data {
- data[i] = byte(popr.Intn(256))
- }
- if err := p.VerboseEqual(msg); err != nil {
- t.Fatalf("%#v !VerboseProto %#v, since %v", msg, p, err)
- }
- if !p.Equal(msg) {
- t.Fatalf("%#v !Proto %#v", msg, p)
- }
- }
- func BenchmarkSubProtoMarshal(b *testing.B) {
- popr := math_rand.New(math_rand.NewSource(616))
- total := 0
- pops := make([]*Sub, 10000)
- for i := 0; i < 10000; i++ {
- pops[i] = NewPopulatedSub(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 BenchmarkSubProtoUnmarshal(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(NewPopulatedSub(popr, false))
- if err != nil {
- panic(err)
- }
- datas[i] = data
- }
- msg := &Sub{}
- 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 TestBigJSON(t *testing.T) {
- popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
- p := NewPopulatedBig(popr, true)
- jsondata, err := encoding_json.Marshal(p)
- if err != nil {
- panic(err)
- }
- msg := &Big{}
- err = encoding_json.Unmarshal(jsondata, msg)
- if err != nil {
- panic(err)
- }
- if err := p.VerboseEqual(msg); err != nil {
- t.Fatalf("%#v !VerboseProto %#v, since %v", msg, p, err)
- }
- if !p.Equal(msg) {
- t.Fatalf("%#v !Json Equal %#v", msg, p)
- }
- }
- func TestBigUnsafeJSON(t *testing.T) {
- popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
- p := NewPopulatedBigUnsafe(popr, true)
- jsondata, err := encoding_json.Marshal(p)
- if err != nil {
- panic(err)
- }
- msg := &BigUnsafe{}
- err = encoding_json.Unmarshal(jsondata, msg)
- if err != nil {
- panic(err)
- }
- if err := p.VerboseEqual(msg); err != nil {
- t.Fatalf("%#v !VerboseProto %#v, since %v", msg, p, err)
- }
- if !p.Equal(msg) {
- t.Fatalf("%#v !Json Equal %#v", msg, p)
- }
- }
- func TestSubJSON(t *testing.T) {
- popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
- p := NewPopulatedSub(popr, true)
- jsondata, err := encoding_json.Marshal(p)
- if err != nil {
- panic(err)
- }
- msg := &Sub{}
- err = encoding_json.Unmarshal(jsondata, msg)
- if err != nil {
- panic(err)
- }
- if err := p.VerboseEqual(msg); err != nil {
- t.Fatalf("%#v !VerboseProto %#v, since %v", msg, p, err)
- }
- if !p.Equal(msg) {
- t.Fatalf("%#v !Json Equal %#v", msg, p)
- }
- }
- func TestBigProtoText(t *testing.T) {
- popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
- p := NewPopulatedBig(popr, true)
- data := github_com_gogo_protobuf_proto.MarshalTextString(p)
- msg := &Big{}
- if err := github_com_gogo_protobuf_proto.UnmarshalText(data, msg); err != nil {
- panic(err)
- }
- if err := p.VerboseEqual(msg); err != nil {
- t.Fatalf("%#v !VerboseProto %#v, since %v", msg, p, err)
- }
- if !p.Equal(msg) {
- t.Fatalf("%#v !Proto %#v", msg, p)
- }
- }
- func TestBigProtoCompactText(t *testing.T) {
- popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
- p := NewPopulatedBig(popr, true)
- data := github_com_gogo_protobuf_proto.CompactTextString(p)
- msg := &Big{}
- if err := github_com_gogo_protobuf_proto.UnmarshalText(data, msg); err != nil {
- panic(err)
- }
- if err := p.VerboseEqual(msg); err != nil {
- t.Fatalf("%#v !VerboseProto %#v, since %v", msg, p, err)
- }
- if !p.Equal(msg) {
- t.Fatalf("%#v !Proto %#v", msg, p)
- }
- }
- func TestBigUnsafeProtoText(t *testing.T) {
- popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
- p := NewPopulatedBigUnsafe(popr, true)
- data := github_com_gogo_protobuf_proto.MarshalTextString(p)
- msg := &BigUnsafe{}
- if err := github_com_gogo_protobuf_proto.UnmarshalText(data, msg); err != nil {
- panic(err)
- }
- if err := p.VerboseEqual(msg); err != nil {
- t.Fatalf("%#v !VerboseProto %#v, since %v", msg, p, err)
- }
- if !p.Equal(msg) {
- t.Fatalf("%#v !Proto %#v", msg, p)
- }
- }
- func TestBigUnsafeProtoCompactText(t *testing.T) {
- popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
- p := NewPopulatedBigUnsafe(popr, true)
- data := github_com_gogo_protobuf_proto.CompactTextString(p)
- msg := &BigUnsafe{}
- if err := github_com_gogo_protobuf_proto.UnmarshalText(data, msg); err != nil {
- panic(err)
- }
- if err := p.VerboseEqual(msg); err != nil {
- t.Fatalf("%#v !VerboseProto %#v, since %v", msg, p, err)
- }
- if !p.Equal(msg) {
- t.Fatalf("%#v !Proto %#v", msg, p)
- }
- }
- func TestSubProtoText(t *testing.T) {
- popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
- p := NewPopulatedSub(popr, true)
- data := github_com_gogo_protobuf_proto.MarshalTextString(p)
- msg := &Sub{}
- if err := github_com_gogo_protobuf_proto.UnmarshalText(data, msg); err != nil {
- panic(err)
- }
- if err := p.VerboseEqual(msg); err != nil {
- t.Fatalf("%#v !VerboseProto %#v, since %v", msg, p, err)
- }
- if !p.Equal(msg) {
- t.Fatalf("%#v !Proto %#v", msg, p)
- }
- }
- func TestSubProtoCompactText(t *testing.T) {
- popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
- p := NewPopulatedSub(popr, true)
- data := github_com_gogo_protobuf_proto.CompactTextString(p)
- msg := &Sub{}
- if err := github_com_gogo_protobuf_proto.UnmarshalText(data, msg); err != nil {
- panic(err)
- }
- if err := p.VerboseEqual(msg); err != nil {
- t.Fatalf("%#v !VerboseProto %#v, since %v", msg, p, err)
- }
- if !p.Equal(msg) {
- t.Fatalf("%#v !Proto %#v", msg, p)
- }
- }
- func TestBigStringer(t *testing.T) {
- popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
- p := NewPopulatedBig(popr, false)
- s1 := p.String()
- s2 := fmt.Sprintf("%v", p)
- if s1 != s2 {
- t.Fatalf("String want %v got %v", s1, s2)
- }
- }
- func TestBigUnsafeStringer(t *testing.T) {
- popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
- p := NewPopulatedBigUnsafe(popr, false)
- s1 := p.String()
- s2 := fmt.Sprintf("%v", p)
- if s1 != s2 {
- t.Fatalf("String want %v got %v", s1, s2)
- }
- }
- func TestSubStringer(t *testing.T) {
- popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
- p := NewPopulatedSub(popr, false)
- s1 := p.String()
- s2 := fmt.Sprintf("%v", p)
- if s1 != s2 {
- t.Fatalf("String want %v got %v", s1, s2)
- }
- }
- func TestBigGoString(t *testing.T) {
- popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
- p := NewPopulatedBig(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 {
- panic(err)
- }
- }
- func TestBigUnsafeGoString(t *testing.T) {
- popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
- p := NewPopulatedBigUnsafe(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 {
- panic(err)
- }
- }
- func TestSubGoString(t *testing.T) {
- popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
- p := NewPopulatedSub(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 {
- panic(err)
- }
- }
- func TestBigVerboseEqual(t *testing.T) {
- popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
- p := NewPopulatedBig(popr, false)
- data, err := github_com_gogo_protobuf_proto.Marshal(p)
- if err != nil {
- panic(err)
- }
- msg := &Big{}
- 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 TestBigUnsafeVerboseEqual(t *testing.T) {
- popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
- p := NewPopulatedBigUnsafe(popr, false)
- data, err := github_com_gogo_protobuf_proto.Marshal(p)
- if err != nil {
- panic(err)
- }
- msg := &BigUnsafe{}
- 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 TestSubVerboseEqual(t *testing.T) {
- popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
- p := NewPopulatedSub(popr, false)
- data, err := github_com_gogo_protobuf_proto.Marshal(p)
- if err != nil {
- panic(err)
- }
- msg := &Sub{}
- 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)
- }
- }
- //These tests are generated by github.com/gogo/protobuf/plugin/testgen