// Code generated by protoc-gen-gogo. // source: merkledag.proto // DO NOT EDIT! /* Package merkledag_pb is a generated protocol buffer package. It is generated from these files: merkledag.proto It has these top-level messages: PBLink PBNode */ package merkledag_pb import testing "testing" import math_rand "math/rand" import time "time" import github_com_gogo_protobuf_proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/proto" import encoding_json "encoding/json" import fmt "fmt" import go_parser "go/parser" func TestPBLinkProto(t *testing.T) { popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) p := NewPopulatedPBLink(popr, false) data, err := github_com_gogo_protobuf_proto.Marshal(p) if err != nil { panic(err) } msg := &PBLink{} 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 TestPBLinkMarshalTo(t *testing.T) { popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) p := NewPopulatedPBLink(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 { panic(err) } msg := &PBLink{} 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 BenchmarkPBLinkProtoMarshal(b *testing.B) { popr := math_rand.New(math_rand.NewSource(616)) total := 0 pops := make([]*PBLink, 10000) for i := 0; i < 10000; i++ { pops[i] = NewPopulatedPBLink(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 BenchmarkPBLinkProtoUnmarshal(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(NewPopulatedPBLink(popr, false)) if err != nil { panic(err) } datas[i] = data } msg := &PBLink{} 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 TestPBNodeProto(t *testing.T) { popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) p := NewPopulatedPBNode(popr, false) data, err := github_com_gogo_protobuf_proto.Marshal(p) if err != nil { panic(err) } msg := &PBNode{} 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 TestPBNodeMarshalTo(t *testing.T) { popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) p := NewPopulatedPBNode(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 { panic(err) } msg := &PBNode{} 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 BenchmarkPBNodeProtoMarshal(b *testing.B) { popr := math_rand.New(math_rand.NewSource(616)) total := 0 pops := make([]*PBNode, 10000) for i := 0; i < 10000; i++ { pops[i] = NewPopulatedPBNode(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 BenchmarkPBNodeProtoUnmarshal(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(NewPopulatedPBNode(popr, false)) if err != nil { panic(err) } datas[i] = data } msg := &PBNode{} 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 TestPBLinkJSON(t *testing.T) { popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) p := NewPopulatedPBLink(popr, true) jsondata, err := encoding_json.Marshal(p) if err != nil { panic(err) } msg := &PBLink{} 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 TestPBNodeJSON(t *testing.T) { popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) p := NewPopulatedPBNode(popr, true) jsondata, err := encoding_json.Marshal(p) if err != nil { panic(err) } msg := &PBNode{} 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 TestPBLinkProtoText(t *testing.T) { popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) p := NewPopulatedPBLink(popr, true) data := github_com_gogo_protobuf_proto.MarshalTextString(p) msg := &PBLink{} 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 TestPBLinkProtoCompactText(t *testing.T) { popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) p := NewPopulatedPBLink(popr, true) data := github_com_gogo_protobuf_proto.CompactTextString(p) msg := &PBLink{} 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 TestPBNodeProtoText(t *testing.T) { popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) p := NewPopulatedPBNode(popr, true) data := github_com_gogo_protobuf_proto.MarshalTextString(p) msg := &PBNode{} 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 TestPBNodeProtoCompactText(t *testing.T) { popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) p := NewPopulatedPBNode(popr, true) data := github_com_gogo_protobuf_proto.CompactTextString(p) msg := &PBNode{} 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 TestPBLinkStringer(t *testing.T) { popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) p := NewPopulatedPBLink(popr, false) s1 := p.String() s2 := fmt.Sprintf("%v", p) if s1 != s2 { t.Fatalf("String want %v got %v", s1, s2) } } func TestPBNodeStringer(t *testing.T) { popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) p := NewPopulatedPBNode(popr, false) s1 := p.String() s2 := fmt.Sprintf("%v", p) if s1 != s2 { t.Fatalf("String want %v got %v", s1, s2) } } func TestPBLinkSize(t *testing.T) { popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) p := NewPopulatedPBLink(popr, true) size2 := github_com_gogo_protobuf_proto.Size(p) data, err := github_com_gogo_protobuf_proto.Marshal(p) if err != nil { panic(err) } size := p.Size() if len(data) != size { t.Fatalf("size %v != marshalled size %v", size, len(data)) } if size2 != size { t.Fatalf("size %v != before marshal proto.Size %v", size, size2) } size3 := github_com_gogo_protobuf_proto.Size(p) if size3 != size { t.Fatalf("size %v != after marshal proto.Size %v", size, size3) } } func BenchmarkPBLinkSize(b *testing.B) { popr := math_rand.New(math_rand.NewSource(616)) total := 0 pops := make([]*PBLink, 1000) for i := 0; i < 1000; i++ { pops[i] = NewPopulatedPBLink(popr, false) } b.ResetTimer() for i := 0; i < b.N; i++ { total += pops[i%1000].Size() } b.SetBytes(int64(total / b.N)) } func TestPBNodeSize(t *testing.T) { popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) p := NewPopulatedPBNode(popr, true) size2 := github_com_gogo_protobuf_proto.Size(p) data, err := github_com_gogo_protobuf_proto.Marshal(p) if err != nil { panic(err) } size := p.Size() if len(data) != size { t.Fatalf("size %v != marshalled size %v", size, len(data)) } if size2 != size { t.Fatalf("size %v != before marshal proto.Size %v", size, size2) } size3 := github_com_gogo_protobuf_proto.Size(p) if size3 != size { t.Fatalf("size %v != after marshal proto.Size %v", size, size3) } } func BenchmarkPBNodeSize(b *testing.B) { popr := math_rand.New(math_rand.NewSource(616)) total := 0 pops := make([]*PBNode, 1000) for i := 0; i < 1000; i++ { pops[i] = NewPopulatedPBNode(popr, false) } b.ResetTimer() for i := 0; i < b.N; i++ { total += pops[i%1000].Size() } b.SetBytes(int64(total / b.N)) } func TestPBLinkGoString(t *testing.T) { popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) p := NewPopulatedPBLink(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 TestPBNodeGoString(t *testing.T) { popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) p := NewPopulatedPBNode(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 TestPBLinkVerboseEqual(t *testing.T) { popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) p := NewPopulatedPBLink(popr, false) data, err := github_com_gogo_protobuf_proto.Marshal(p) if err != nil { panic(err) } msg := &PBLink{} 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 TestPBNodeVerboseEqual(t *testing.T) { popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) p := NewPopulatedPBNode(popr, false) data, err := github_com_gogo_protobuf_proto.Marshal(p) if err != nil { panic(err) } msg := &PBNode{} 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