Commit 1e0db6da authored by Henry's avatar Henry

godeps: move (go)goprotobuf to github location

parent 99bdf197
...@@ -14,27 +14,21 @@ ...@@ -14,27 +14,21 @@
*/ */
package merkledag_pb package merkledag_pb
import proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto" import proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
import math "math" import math "math"
// discarding unused import gogoproto "code.google.com/p/gogoprotobuf/gogoproto/gogo.pb" // discarding unused import gogoproto "code.google.com/p/gogoprotobuf/gogoproto/gogo.pb"
import io "io" import io "io"
import fmt "fmt" import fmt "fmt"
import code_google_com_p_gogoprotobuf_proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto" import github_com_gogo_protobuf_proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
import fmt1 "fmt"
import strings "strings" import strings "strings"
import reflect "reflect" import reflect "reflect"
import fmt2 "fmt"
import strings1 "strings"
import code_google_com_p_gogoprotobuf_proto1 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto"
import sort "sort" import sort "sort"
import strconv "strconv" import strconv "strconv"
import reflect1 "reflect"
import fmt3 "fmt"
import bytes "bytes" import bytes "bytes"
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
...@@ -143,7 +137,7 @@ func (m *PBLink) Unmarshal(data []byte) error { ...@@ -143,7 +137,7 @@ func (m *PBLink) Unmarshal(data []byte) error {
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.Hash = append(m.Hash, data[index:postIndex]...) m.Hash = append([]byte{}, data[index:postIndex]...)
index = postIndex index = postIndex
case 2: case 2:
if wireType != 2 { if wireType != 2 {
...@@ -195,7 +189,7 @@ func (m *PBLink) Unmarshal(data []byte) error { ...@@ -195,7 +189,7 @@ func (m *PBLink) Unmarshal(data []byte) error {
} }
} }
index -= sizeOfWire index -= sizeOfWire
skippy, err := code_google_com_p_gogoprotobuf_proto.Skip(data[index:]) skippy, err := github_com_gogo_protobuf_proto.Skip(data[index:])
if err != nil { if err != nil {
return err return err
} }
...@@ -270,7 +264,7 @@ func (m *PBNode) Unmarshal(data []byte) error { ...@@ -270,7 +264,7 @@ func (m *PBNode) Unmarshal(data []byte) error {
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.Data = append(m.Data, data[index:postIndex]...) m.Data = append([]byte{}, data[index:postIndex]...)
index = postIndex index = postIndex
default: default:
var sizeOfWire int var sizeOfWire int
...@@ -282,7 +276,7 @@ func (m *PBNode) Unmarshal(data []byte) error { ...@@ -282,7 +276,7 @@ func (m *PBNode) Unmarshal(data []byte) error {
} }
} }
index -= sizeOfWire index -= sizeOfWire
skippy, err := code_google_com_p_gogoprotobuf_proto.Skip(data[index:]) skippy, err := github_com_gogo_protobuf_proto.Skip(data[index:])
if err != nil { if err != nil {
return err return err
} }
...@@ -303,7 +297,7 @@ func (this *PBLink) String() string { ...@@ -303,7 +297,7 @@ func (this *PBLink) String() string {
`Hash:` + valueToStringMerkledag(this.Hash) + `,`, `Hash:` + valueToStringMerkledag(this.Hash) + `,`,
`Name:` + valueToStringMerkledag(this.Name) + `,`, `Name:` + valueToStringMerkledag(this.Name) + `,`,
`Tsize:` + valueToStringMerkledag(this.Tsize) + `,`, `Tsize:` + valueToStringMerkledag(this.Tsize) + `,`,
`XXX_unrecognized:` + fmt1.Sprintf("%v", this.XXX_unrecognized) + `,`, `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
...@@ -313,9 +307,9 @@ func (this *PBNode) String() string { ...@@ -313,9 +307,9 @@ func (this *PBNode) String() string {
return "nil" return "nil"
} }
s := strings.Join([]string{`&PBNode{`, s := strings.Join([]string{`&PBNode{`,
`Links:` + strings.Replace(fmt1.Sprintf("%v", this.Links), "PBLink", "PBLink", 1) + `,`, `Links:` + strings.Replace(fmt.Sprintf("%v", this.Links), "PBLink", "PBLink", 1) + `,`,
`Data:` + valueToStringMerkledag(this.Data) + `,`, `Data:` + valueToStringMerkledag(this.Data) + `,`,
`XXX_unrecognized:` + fmt1.Sprintf("%v", this.XXX_unrecognized) + `,`, `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`, `}`,
}, "") }, "")
return s return s
...@@ -326,7 +320,7 @@ func valueToStringMerkledag(v interface{}) string { ...@@ -326,7 +320,7 @@ func valueToStringMerkledag(v interface{}) string {
return "nil" return "nil"
} }
pv := reflect.Indirect(rv).Interface() pv := reflect.Indirect(rv).Interface()
return fmt1.Sprintf("*%v", pv) return fmt.Sprintf("*%v", pv)
} }
func (m *PBLink) Size() (n int) { func (m *PBLink) Size() (n int) {
var l int var l int
...@@ -347,6 +341,7 @@ func (m *PBLink) Size() (n int) { ...@@ -347,6 +341,7 @@ func (m *PBLink) Size() (n int) {
} }
return n return n
} }
func (m *PBNode) Size() (n int) { func (m *PBNode) Size() (n int) {
var l int var l int
_ = l _ = l
...@@ -434,11 +429,7 @@ type randyMerkledag interface { ...@@ -434,11 +429,7 @@ type randyMerkledag interface {
} }
func randUTF8RuneMerkledag(r randyMerkledag) rune { func randUTF8RuneMerkledag(r randyMerkledag) rune {
res := rune(r.Uint32() % 1112064) return rune(r.Intn(126-43) + 43)
if 55296 <= res {
res += 2047
}
return res
} }
func randStringMerkledag(r randyMerkledag) string { func randStringMerkledag(r randyMerkledag) string {
v6 := r.Intn(100) v6 := r.Intn(100)
...@@ -531,6 +522,7 @@ func (m *PBLink) MarshalTo(data []byte) (n int, err error) { ...@@ -531,6 +522,7 @@ func (m *PBLink) MarshalTo(data []byte) (n int, err error) {
} }
return i, nil return i, nil
} }
func (m *PBNode) Marshal() (data []byte, err error) { func (m *PBNode) Marshal() (data []byte, err error) {
size := m.Size() size := m.Size()
data = make([]byte, size) data = make([]byte, size)
...@@ -569,6 +561,7 @@ func (m *PBNode) MarshalTo(data []byte) (n int, err error) { ...@@ -569,6 +561,7 @@ func (m *PBNode) MarshalTo(data []byte) (n int, err error) {
} }
return i, nil return i, nil
} }
func encodeFixed64Merkledag(data []byte, offset int, v uint64) int { func encodeFixed64Merkledag(data []byte, offset int, v uint64) int {
data[offset] = uint8(v) data[offset] = uint8(v)
data[offset+1] = uint8(v >> 8) data[offset+1] = uint8(v >> 8)
...@@ -600,25 +593,32 @@ func (this *PBLink) GoString() string { ...@@ -600,25 +593,32 @@ func (this *PBLink) GoString() string {
if this == nil { if this == nil {
return "nil" return "nil"
} }
s := strings1.Join([]string{`&merkledag_pb.PBLink{` + `Hash:` + valueToGoStringMerkledag(this.Hash, "byte"), `Name:` + valueToGoStringMerkledag(this.Name, "string"), `Tsize:` + valueToGoStringMerkledag(this.Tsize, "uint64"), `XXX_unrecognized:` + fmt2.Sprintf("%#v", this.XXX_unrecognized) + `}`}, ", ") s := strings.Join([]string{`&merkledag_pb.PBLink{` +
`Hash:` + valueToGoStringMerkledag(this.Hash, "byte"),
`Name:` + valueToGoStringMerkledag(this.Name, "string"),
`Tsize:` + valueToGoStringMerkledag(this.Tsize, "uint64"),
`XXX_unrecognized:` + fmt.Sprintf("%#v", this.XXX_unrecognized) + `}`}, ", ")
return s return s
} }
func (this *PBNode) GoString() string { func (this *PBNode) GoString() string {
if this == nil { if this == nil {
return "nil" return "nil"
} }
s := strings1.Join([]string{`&merkledag_pb.PBNode{` + `Links:` + fmt2.Sprintf("%#v", this.Links), `Data:` + valueToGoStringMerkledag(this.Data, "byte"), `XXX_unrecognized:` + fmt2.Sprintf("%#v", this.XXX_unrecognized) + `}`}, ", ") s := strings.Join([]string{`&merkledag_pb.PBNode{` +
`Links:` + fmt.Sprintf("%#v", this.Links),
`Data:` + valueToGoStringMerkledag(this.Data, "byte"),
`XXX_unrecognized:` + fmt.Sprintf("%#v", this.XXX_unrecognized) + `}`}, ", ")
return s return s
} }
func valueToGoStringMerkledag(v interface{}, typ string) string { func valueToGoStringMerkledag(v interface{}, typ string) string {
rv := reflect1.ValueOf(v) rv := reflect.ValueOf(v)
if rv.IsNil() { if rv.IsNil() {
return "nil" return "nil"
} }
pv := reflect1.Indirect(rv).Interface() pv := reflect.Indirect(rv).Interface()
return fmt2.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv)
} }
func extensionToGoStringMerkledag(e map[int32]code_google_com_p_gogoprotobuf_proto1.Extension) string { func extensionToGoStringMerkledag(e map[int32]github_com_gogo_protobuf_proto.Extension) string {
if e == nil { if e == nil {
return "nil" return "nil"
} }
...@@ -632,7 +632,7 @@ func extensionToGoStringMerkledag(e map[int32]code_google_com_p_gogoprotobuf_pro ...@@ -632,7 +632,7 @@ func extensionToGoStringMerkledag(e map[int32]code_google_com_p_gogoprotobuf_pro
for _, k := range keys { for _, k := range keys {
ss = append(ss, strconv.Itoa(k)+": "+e[int32(k)].GoString()) ss = append(ss, strconv.Itoa(k)+": "+e[int32(k)].GoString())
} }
s += strings1.Join(ss, ",") + "}" s += strings.Join(ss, ",") + "}"
return s return s
} }
func (this *PBLink) VerboseEqual(that interface{}) error { func (this *PBLink) VerboseEqual(that interface{}) error {
...@@ -640,44 +640,44 @@ func (this *PBLink) VerboseEqual(that interface{}) error { ...@@ -640,44 +640,44 @@ func (this *PBLink) VerboseEqual(that interface{}) error {
if this == nil { if this == nil {
return nil return nil
} }
return fmt3.Errorf("that == nil && this != nil") return fmt.Errorf("that == nil && this != nil")
} }
that1, ok := that.(*PBLink) that1, ok := that.(*PBLink)
if !ok { if !ok {
return fmt3.Errorf("that is not of type *PBLink") return fmt.Errorf("that is not of type *PBLink")
} }
if that1 == nil { if that1 == nil {
if this == nil { if this == nil {
return nil return nil
} }
return fmt3.Errorf("that is type *PBLink but is nil && this != nil") return fmt.Errorf("that is type *PBLink but is nil && this != nil")
} else if this == nil { } else if this == nil {
return fmt3.Errorf("that is type *PBLinkbut is not nil && this == nil") return fmt.Errorf("that is type *PBLinkbut is not nil && this == nil")
} }
if !bytes.Equal(this.Hash, that1.Hash) { if !bytes.Equal(this.Hash, that1.Hash) {
return fmt3.Errorf("Hash this(%v) Not Equal that(%v)", this.Hash, that1.Hash) return fmt.Errorf("Hash this(%v) Not Equal that(%v)", this.Hash, that1.Hash)
} }
if this.Name != nil && that1.Name != nil { if this.Name != nil && that1.Name != nil {
if *this.Name != *that1.Name { if *this.Name != *that1.Name {
return fmt3.Errorf("Name this(%v) Not Equal that(%v)", *this.Name, *that1.Name) return fmt.Errorf("Name this(%v) Not Equal that(%v)", *this.Name, *that1.Name)
} }
} else if this.Name != nil { } else if this.Name != nil {
return fmt3.Errorf("this.Name == nil && that.Name != nil") return fmt.Errorf("this.Name == nil && that.Name != nil")
} else if that1.Name != nil { } else if that1.Name != nil {
return fmt3.Errorf("Name this(%v) Not Equal that(%v)", this.Name, that1.Name) return fmt.Errorf("Name this(%v) Not Equal that(%v)", this.Name, that1.Name)
} }
if this.Tsize != nil && that1.Tsize != nil { if this.Tsize != nil && that1.Tsize != nil {
if *this.Tsize != *that1.Tsize { if *this.Tsize != *that1.Tsize {
return fmt3.Errorf("Tsize this(%v) Not Equal that(%v)", *this.Tsize, *that1.Tsize) return fmt.Errorf("Tsize this(%v) Not Equal that(%v)", *this.Tsize, *that1.Tsize)
} }
} else if this.Tsize != nil { } else if this.Tsize != nil {
return fmt3.Errorf("this.Tsize == nil && that.Tsize != nil") return fmt.Errorf("this.Tsize == nil && that.Tsize != nil")
} else if that1.Tsize != nil { } else if that1.Tsize != nil {
return fmt3.Errorf("Tsize this(%v) Not Equal that(%v)", this.Tsize, that1.Tsize) return fmt.Errorf("Tsize this(%v) Not Equal that(%v)", this.Tsize, that1.Tsize)
} }
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
return fmt3.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized) return fmt.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized)
} }
return nil return nil
} }
...@@ -732,34 +732,34 @@ func (this *PBNode) VerboseEqual(that interface{}) error { ...@@ -732,34 +732,34 @@ func (this *PBNode) VerboseEqual(that interface{}) error {
if this == nil { if this == nil {
return nil return nil
} }
return fmt3.Errorf("that == nil && this != nil") return fmt.Errorf("that == nil && this != nil")
} }
that1, ok := that.(*PBNode) that1, ok := that.(*PBNode)
if !ok { if !ok {
return fmt3.Errorf("that is not of type *PBNode") return fmt.Errorf("that is not of type *PBNode")
} }
if that1 == nil { if that1 == nil {
if this == nil { if this == nil {
return nil return nil
} }
return fmt3.Errorf("that is type *PBNode but is nil && this != nil") return fmt.Errorf("that is type *PBNode but is nil && this != nil")
} else if this == nil { } else if this == nil {
return fmt3.Errorf("that is type *PBNodebut is not nil && this == nil") return fmt.Errorf("that is type *PBNodebut is not nil && this == nil")
} }
if len(this.Links) != len(that1.Links) { if len(this.Links) != len(that1.Links) {
return fmt3.Errorf("Links this(%v) Not Equal that(%v)", len(this.Links), len(that1.Links)) return fmt.Errorf("Links this(%v) Not Equal that(%v)", len(this.Links), len(that1.Links))
} }
for i := range this.Links { for i := range this.Links {
if !this.Links[i].Equal(that1.Links[i]) { if !this.Links[i].Equal(that1.Links[i]) {
return fmt3.Errorf("Links this[%v](%v) Not Equal that[%v](%v)", i, this.Links[i], i, that1.Links[i]) return fmt.Errorf("Links this[%v](%v) Not Equal that[%v](%v)", i, this.Links[i], i, that1.Links[i])
} }
} }
if !bytes.Equal(this.Data, that1.Data) { if !bytes.Equal(this.Data, that1.Data) {
return fmt3.Errorf("Data this(%v) Not Equal that(%v)", this.Data, that1.Data) return fmt.Errorf("Data this(%v) Not Equal that(%v)", this.Data, that1.Data)
} }
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
return fmt3.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized) return fmt.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized)
} }
return nil return nil
} }
......
...@@ -17,42 +17,20 @@ package merkledag_pb ...@@ -17,42 +17,20 @@ package merkledag_pb
import testing "testing" import testing "testing"
import math_rand "math/rand" import math_rand "math/rand"
import time "time" import time "time"
import code_google_com_p_gogoprotobuf_proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto" import github_com_gogo_protobuf_proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
import testing1 "testing"
import math_rand1 "math/rand"
import time1 "time"
import encoding_json "encoding/json" import encoding_json "encoding/json"
import testing2 "testing"
import math_rand2 "math/rand"
import time2 "time"
import code_google_com_p_gogoprotobuf_proto1 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto"
import math_rand3 "math/rand"
import time3 "time"
import testing3 "testing"
import fmt "fmt" import fmt "fmt"
import math_rand4 "math/rand"
import time4 "time"
import testing4 "testing"
import code_google_com_p_gogoprotobuf_proto2 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto"
import math_rand5 "math/rand"
import time5 "time"
import testing5 "testing"
import fmt1 "fmt"
import go_parser "go/parser" import go_parser "go/parser"
import math_rand6 "math/rand"
import time6 "time"
import testing6 "testing"
import code_google_com_p_gogoprotobuf_proto3 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto"
func TestPBLinkProto(t *testing.T) { func TestPBLinkProto(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedPBLink(popr, false) p := NewPopulatedPBLink(popr, false)
data, err := code_google_com_p_gogoprotobuf_proto.Marshal(p) data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil { if err != nil {
panic(err) panic(err)
} }
msg := &PBLink{} msg := &PBLink{}
if err := code_google_com_p_gogoprotobuf_proto.Unmarshal(data, msg); err != nil { if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
panic(err) panic(err)
} }
for i := range data { for i := range data {
...@@ -79,7 +57,7 @@ func TestPBLinkMarshalTo(t *testing.T) { ...@@ -79,7 +57,7 @@ func TestPBLinkMarshalTo(t *testing.T) {
panic(err) panic(err)
} }
msg := &PBLink{} msg := &PBLink{}
if err := code_google_com_p_gogoprotobuf_proto.Unmarshal(data, msg); err != nil { if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
panic(err) panic(err)
} }
for i := range data { for i := range data {
...@@ -102,7 +80,7 @@ func BenchmarkPBLinkProtoMarshal(b *testing.B) { ...@@ -102,7 +80,7 @@ func BenchmarkPBLinkProtoMarshal(b *testing.B) {
} }
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
data, err := code_google_com_p_gogoprotobuf_proto.Marshal(pops[i%10000]) data, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000])
if err != nil { if err != nil {
panic(err) panic(err)
} }
...@@ -116,7 +94,7 @@ func BenchmarkPBLinkProtoUnmarshal(b *testing.B) { ...@@ -116,7 +94,7 @@ func BenchmarkPBLinkProtoUnmarshal(b *testing.B) {
total := 0 total := 0
datas := make([][]byte, 10000) datas := make([][]byte, 10000)
for i := 0; i < 10000; i++ { for i := 0; i < 10000; i++ {
data, err := code_google_com_p_gogoprotobuf_proto.Marshal(NewPopulatedPBLink(popr, false)) data, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedPBLink(popr, false))
if err != nil { if err != nil {
panic(err) panic(err)
} }
...@@ -126,7 +104,7 @@ func BenchmarkPBLinkProtoUnmarshal(b *testing.B) { ...@@ -126,7 +104,7 @@ func BenchmarkPBLinkProtoUnmarshal(b *testing.B) {
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
total += len(datas[i%10000]) total += len(datas[i%10000])
if err := code_google_com_p_gogoprotobuf_proto.Unmarshal(datas[i%10000], msg); err != nil { if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil {
panic(err) panic(err)
} }
} }
...@@ -136,12 +114,12 @@ func BenchmarkPBLinkProtoUnmarshal(b *testing.B) { ...@@ -136,12 +114,12 @@ func BenchmarkPBLinkProtoUnmarshal(b *testing.B) {
func TestPBNodeProto(t *testing.T) { func TestPBNodeProto(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedPBNode(popr, false) p := NewPopulatedPBNode(popr, false)
data, err := code_google_com_p_gogoprotobuf_proto.Marshal(p) data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil { if err != nil {
panic(err) panic(err)
} }
msg := &PBNode{} msg := &PBNode{}
if err := code_google_com_p_gogoprotobuf_proto.Unmarshal(data, msg); err != nil { if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
panic(err) panic(err)
} }
for i := range data { for i := range data {
...@@ -168,7 +146,7 @@ func TestPBNodeMarshalTo(t *testing.T) { ...@@ -168,7 +146,7 @@ func TestPBNodeMarshalTo(t *testing.T) {
panic(err) panic(err)
} }
msg := &PBNode{} msg := &PBNode{}
if err := code_google_com_p_gogoprotobuf_proto.Unmarshal(data, msg); err != nil { if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
panic(err) panic(err)
} }
for i := range data { for i := range data {
...@@ -191,7 +169,7 @@ func BenchmarkPBNodeProtoMarshal(b *testing.B) { ...@@ -191,7 +169,7 @@ func BenchmarkPBNodeProtoMarshal(b *testing.B) {
} }
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
data, err := code_google_com_p_gogoprotobuf_proto.Marshal(pops[i%10000]) data, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000])
if err != nil { if err != nil {
panic(err) panic(err)
} }
...@@ -205,7 +183,7 @@ func BenchmarkPBNodeProtoUnmarshal(b *testing.B) { ...@@ -205,7 +183,7 @@ func BenchmarkPBNodeProtoUnmarshal(b *testing.B) {
total := 0 total := 0
datas := make([][]byte, 10000) datas := make([][]byte, 10000)
for i := 0; i < 10000; i++ { for i := 0; i < 10000; i++ {
data, err := code_google_com_p_gogoprotobuf_proto.Marshal(NewPopulatedPBNode(popr, false)) data, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedPBNode(popr, false))
if err != nil { if err != nil {
panic(err) panic(err)
} }
...@@ -215,15 +193,15 @@ func BenchmarkPBNodeProtoUnmarshal(b *testing.B) { ...@@ -215,15 +193,15 @@ func BenchmarkPBNodeProtoUnmarshal(b *testing.B) {
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
total += len(datas[i%10000]) total += len(datas[i%10000])
if err := code_google_com_p_gogoprotobuf_proto.Unmarshal(datas[i%10000], msg); err != nil { if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil {
panic(err) panic(err)
} }
} }
b.SetBytes(int64(total / b.N)) b.SetBytes(int64(total / b.N))
} }
func TestPBLinkJSON(t *testing1.T) { func TestPBLinkJSON(t *testing.T) {
popr := math_rand1.New(math_rand1.NewSource(time1.Now().UnixNano())) popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedPBLink(popr, true) p := NewPopulatedPBLink(popr, true)
jsondata, err := encoding_json.Marshal(p) jsondata, err := encoding_json.Marshal(p)
if err != nil { if err != nil {
...@@ -241,8 +219,8 @@ func TestPBLinkJSON(t *testing1.T) { ...@@ -241,8 +219,8 @@ func TestPBLinkJSON(t *testing1.T) {
t.Fatalf("%#v !Json Equal %#v", msg, p) t.Fatalf("%#v !Json Equal %#v", msg, p)
} }
} }
func TestPBNodeJSON(t *testing1.T) { func TestPBNodeJSON(t *testing.T) {
popr := math_rand1.New(math_rand1.NewSource(time1.Now().UnixNano())) popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedPBNode(popr, true) p := NewPopulatedPBNode(popr, true)
jsondata, err := encoding_json.Marshal(p) jsondata, err := encoding_json.Marshal(p)
if err != nil { if err != nil {
...@@ -260,12 +238,12 @@ func TestPBNodeJSON(t *testing1.T) { ...@@ -260,12 +238,12 @@ func TestPBNodeJSON(t *testing1.T) {
t.Fatalf("%#v !Json Equal %#v", msg, p) t.Fatalf("%#v !Json Equal %#v", msg, p)
} }
} }
func TestPBLinkProtoText(t *testing2.T) { func TestPBLinkProtoText(t *testing.T) {
popr := math_rand2.New(math_rand2.NewSource(time2.Now().UnixNano())) popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedPBLink(popr, true) p := NewPopulatedPBLink(popr, true)
data := code_google_com_p_gogoprotobuf_proto1.MarshalTextString(p) data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &PBLink{} msg := &PBLink{}
if err := code_google_com_p_gogoprotobuf_proto1.UnmarshalText(data, msg); err != nil { if err := github_com_gogo_protobuf_proto.UnmarshalText(data, msg); err != nil {
panic(err) panic(err)
} }
if err := p.VerboseEqual(msg); err != nil { if err := p.VerboseEqual(msg); err != nil {
...@@ -276,12 +254,12 @@ func TestPBLinkProtoText(t *testing2.T) { ...@@ -276,12 +254,12 @@ func TestPBLinkProtoText(t *testing2.T) {
} }
} }
func TestPBLinkProtoCompactText(t *testing2.T) { func TestPBLinkProtoCompactText(t *testing.T) {
popr := math_rand2.New(math_rand2.NewSource(time2.Now().UnixNano())) popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedPBLink(popr, true) p := NewPopulatedPBLink(popr, true)
data := code_google_com_p_gogoprotobuf_proto1.CompactTextString(p) data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &PBLink{} msg := &PBLink{}
if err := code_google_com_p_gogoprotobuf_proto1.UnmarshalText(data, msg); err != nil { if err := github_com_gogo_protobuf_proto.UnmarshalText(data, msg); err != nil {
panic(err) panic(err)
} }
if err := p.VerboseEqual(msg); err != nil { if err := p.VerboseEqual(msg); err != nil {
...@@ -292,12 +270,12 @@ func TestPBLinkProtoCompactText(t *testing2.T) { ...@@ -292,12 +270,12 @@ func TestPBLinkProtoCompactText(t *testing2.T) {
} }
} }
func TestPBNodeProtoText(t *testing2.T) { func TestPBNodeProtoText(t *testing.T) {
popr := math_rand2.New(math_rand2.NewSource(time2.Now().UnixNano())) popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedPBNode(popr, true) p := NewPopulatedPBNode(popr, true)
data := code_google_com_p_gogoprotobuf_proto1.MarshalTextString(p) data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &PBNode{} msg := &PBNode{}
if err := code_google_com_p_gogoprotobuf_proto1.UnmarshalText(data, msg); err != nil { if err := github_com_gogo_protobuf_proto.UnmarshalText(data, msg); err != nil {
panic(err) panic(err)
} }
if err := p.VerboseEqual(msg); err != nil { if err := p.VerboseEqual(msg); err != nil {
...@@ -308,12 +286,12 @@ func TestPBNodeProtoText(t *testing2.T) { ...@@ -308,12 +286,12 @@ func TestPBNodeProtoText(t *testing2.T) {
} }
} }
func TestPBNodeProtoCompactText(t *testing2.T) { func TestPBNodeProtoCompactText(t *testing.T) {
popr := math_rand2.New(math_rand2.NewSource(time2.Now().UnixNano())) popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedPBNode(popr, true) p := NewPopulatedPBNode(popr, true)
data := code_google_com_p_gogoprotobuf_proto1.CompactTextString(p) data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &PBNode{} msg := &PBNode{}
if err := code_google_com_p_gogoprotobuf_proto1.UnmarshalText(data, msg); err != nil { if err := github_com_gogo_protobuf_proto.UnmarshalText(data, msg); err != nil {
panic(err) panic(err)
} }
if err := p.VerboseEqual(msg); err != nil { if err := p.VerboseEqual(msg); err != nil {
...@@ -324,8 +302,8 @@ func TestPBNodeProtoCompactText(t *testing2.T) { ...@@ -324,8 +302,8 @@ func TestPBNodeProtoCompactText(t *testing2.T) {
} }
} }
func TestPBLinkStringer(t *testing3.T) { func TestPBLinkStringer(t *testing.T) {
popr := math_rand3.New(math_rand3.NewSource(time3.Now().UnixNano())) popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedPBLink(popr, false) p := NewPopulatedPBLink(popr, false)
s1 := p.String() s1 := p.String()
s2 := fmt.Sprintf("%v", p) s2 := fmt.Sprintf("%v", p)
...@@ -333,8 +311,8 @@ func TestPBLinkStringer(t *testing3.T) { ...@@ -333,8 +311,8 @@ func TestPBLinkStringer(t *testing3.T) {
t.Fatalf("String want %v got %v", s1, s2) t.Fatalf("String want %v got %v", s1, s2)
} }
} }
func TestPBNodeStringer(t *testing3.T) { func TestPBNodeStringer(t *testing.T) {
popr := math_rand3.New(math_rand3.NewSource(time3.Now().UnixNano())) popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedPBNode(popr, false) p := NewPopulatedPBNode(popr, false)
s1 := p.String() s1 := p.String()
s2 := fmt.Sprintf("%v", p) s2 := fmt.Sprintf("%v", p)
...@@ -342,11 +320,11 @@ func TestPBNodeStringer(t *testing3.T) { ...@@ -342,11 +320,11 @@ func TestPBNodeStringer(t *testing3.T) {
t.Fatalf("String want %v got %v", s1, s2) t.Fatalf("String want %v got %v", s1, s2)
} }
} }
func TestPBLinkSize(t *testing4.T) { func TestPBLinkSize(t *testing.T) {
popr := math_rand4.New(math_rand4.NewSource(time4.Now().UnixNano())) popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedPBLink(popr, true) p := NewPopulatedPBLink(popr, true)
size2 := code_google_com_p_gogoprotobuf_proto2.Size(p) size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := code_google_com_p_gogoprotobuf_proto2.Marshal(p) data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil { if err != nil {
panic(err) panic(err)
} }
...@@ -357,14 +335,14 @@ func TestPBLinkSize(t *testing4.T) { ...@@ -357,14 +335,14 @@ func TestPBLinkSize(t *testing4.T) {
if size2 != size { if size2 != size {
t.Fatalf("size %v != before marshal proto.Size %v", size, size2) t.Fatalf("size %v != before marshal proto.Size %v", size, size2)
} }
size3 := code_google_com_p_gogoprotobuf_proto2.Size(p) size3 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size { if size3 != size {
t.Fatalf("size %v != after marshal proto.Size %v", size, size3) t.Fatalf("size %v != after marshal proto.Size %v", size, size3)
} }
} }
func BenchmarkPBLinkSize(b *testing4.B) { func BenchmarkPBLinkSize(b *testing.B) {
popr := math_rand4.New(math_rand4.NewSource(616)) popr := math_rand.New(math_rand.NewSource(616))
total := 0 total := 0
pops := make([]*PBLink, 1000) pops := make([]*PBLink, 1000)
for i := 0; i < 1000; i++ { for i := 0; i < 1000; i++ {
...@@ -377,11 +355,11 @@ func BenchmarkPBLinkSize(b *testing4.B) { ...@@ -377,11 +355,11 @@ func BenchmarkPBLinkSize(b *testing4.B) {
b.SetBytes(int64(total / b.N)) b.SetBytes(int64(total / b.N))
} }
func TestPBNodeSize(t *testing4.T) { func TestPBNodeSize(t *testing.T) {
popr := math_rand4.New(math_rand4.NewSource(time4.Now().UnixNano())) popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedPBNode(popr, true) p := NewPopulatedPBNode(popr, true)
size2 := code_google_com_p_gogoprotobuf_proto2.Size(p) size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := code_google_com_p_gogoprotobuf_proto2.Marshal(p) data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil { if err != nil {
panic(err) panic(err)
} }
...@@ -392,14 +370,14 @@ func TestPBNodeSize(t *testing4.T) { ...@@ -392,14 +370,14 @@ func TestPBNodeSize(t *testing4.T) {
if size2 != size { if size2 != size {
t.Fatalf("size %v != before marshal proto.Size %v", size, size2) t.Fatalf("size %v != before marshal proto.Size %v", size, size2)
} }
size3 := code_google_com_p_gogoprotobuf_proto2.Size(p) size3 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size { if size3 != size {
t.Fatalf("size %v != after marshal proto.Size %v", size, size3) t.Fatalf("size %v != after marshal proto.Size %v", size, size3)
} }
} }
func BenchmarkPBNodeSize(b *testing4.B) { func BenchmarkPBNodeSize(b *testing.B) {
popr := math_rand4.New(math_rand4.NewSource(616)) popr := math_rand.New(math_rand.NewSource(616))
total := 0 total := 0
pops := make([]*PBNode, 1000) pops := make([]*PBNode, 1000)
for i := 0; i < 1000; i++ { for i := 0; i < 1000; i++ {
...@@ -412,11 +390,11 @@ func BenchmarkPBNodeSize(b *testing4.B) { ...@@ -412,11 +390,11 @@ func BenchmarkPBNodeSize(b *testing4.B) {
b.SetBytes(int64(total / b.N)) b.SetBytes(int64(total / b.N))
} }
func TestPBLinkGoString(t *testing5.T) { func TestPBLinkGoString(t *testing.T) {
popr := math_rand5.New(math_rand5.NewSource(time5.Now().UnixNano())) popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedPBLink(popr, false) p := NewPopulatedPBLink(popr, false)
s1 := p.GoString() s1 := p.GoString()
s2 := fmt1.Sprintf("%#v", p) s2 := fmt.Sprintf("%#v", p)
if s1 != s2 { if s1 != s2 {
t.Fatalf("GoString want %v got %v", s1, s2) t.Fatalf("GoString want %v got %v", s1, s2)
} }
...@@ -425,11 +403,11 @@ func TestPBLinkGoString(t *testing5.T) { ...@@ -425,11 +403,11 @@ func TestPBLinkGoString(t *testing5.T) {
panic(err) panic(err)
} }
} }
func TestPBNodeGoString(t *testing5.T) { func TestPBNodeGoString(t *testing.T) {
popr := math_rand5.New(math_rand5.NewSource(time5.Now().UnixNano())) popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedPBNode(popr, false) p := NewPopulatedPBNode(popr, false)
s1 := p.GoString() s1 := p.GoString()
s2 := fmt1.Sprintf("%#v", p) s2 := fmt.Sprintf("%#v", p)
if s1 != s2 { if s1 != s2 {
t.Fatalf("GoString want %v got %v", s1, s2) t.Fatalf("GoString want %v got %v", s1, s2)
} }
...@@ -438,30 +416,30 @@ func TestPBNodeGoString(t *testing5.T) { ...@@ -438,30 +416,30 @@ func TestPBNodeGoString(t *testing5.T) {
panic(err) panic(err)
} }
} }
func TestPBLinkVerboseEqual(t *testing6.T) { func TestPBLinkVerboseEqual(t *testing.T) {
popr := math_rand6.New(math_rand6.NewSource(time6.Now().UnixNano())) popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedPBLink(popr, false) p := NewPopulatedPBLink(popr, false)
data, err := code_google_com_p_gogoprotobuf_proto3.Marshal(p) data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil { if err != nil {
panic(err) panic(err)
} }
msg := &PBLink{} msg := &PBLink{}
if err := code_google_com_p_gogoprotobuf_proto3.Unmarshal(data, msg); err != nil { if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
panic(err) panic(err)
} }
if err := p.VerboseEqual(msg); err != nil { if err := p.VerboseEqual(msg); err != nil {
t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err) t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err)
} }
} }
func TestPBNodeVerboseEqual(t *testing6.T) { func TestPBNodeVerboseEqual(t *testing.T) {
popr := math_rand6.New(math_rand6.NewSource(time6.Now().UnixNano())) popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedPBNode(popr, false) p := NewPopulatedPBNode(popr, false)
data, err := code_google_com_p_gogoprotobuf_proto3.Marshal(p) data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil { if err != nil {
panic(err) panic(err)
} }
msg := &PBNode{} msg := &PBNode{}
if err := code_google_com_p_gogoprotobuf_proto3.Unmarshal(data, msg); err != nil { if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
panic(err) panic(err)
} }
if err := p.VerboseEqual(msg); err != nil { if err := p.VerboseEqual(msg); err != nil {
...@@ -469,4 +447,4 @@ func TestPBNodeVerboseEqual(t *testing6.T) { ...@@ -469,4 +447,4 @@ func TestPBNodeVerboseEqual(t *testing6.T) {
} }
} }
//These tests are generated by code.google.com/p/gogoprotobuf/plugin/testgen //These tests are generated by github.com/gogo/protobuf/plugin/testgen
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment