2018-07-14 11:48:41 -04:00
|
|
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
|
|
|
// source: sortkeys/sortable.proto
|
|
|
|
|
|
|
|
package sortkeys
|
|
|
|
|
|
|
|
import testing "testing"
|
2018-07-15 17:48:35 -04:00
|
|
|
import math_rand "math/rand"
|
2018-07-14 11:48:41 -04:00
|
|
|
import time "time"
|
2018-07-15 17:48:35 -04:00
|
|
|
import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
|
|
|
|
import github_com_gogo_protobuf_jsonpb "github.com/gogo/protobuf/jsonpb"
|
2018-07-14 11:48:41 -04:00
|
|
|
import fmt "fmt"
|
2018-07-15 17:48:35 -04:00
|
|
|
import go_parser "go/parser"
|
|
|
|
import proto "github.com/gogo/protobuf/proto"
|
2018-07-14 11:48:41 -04:00
|
|
|
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 TestObjectProto(t *testing.T) {
|
|
|
|
seed := time.Now().UnixNano()
|
2018-07-15 17:48:35 -04:00
|
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
2018-07-14 11:48:41 -04:00
|
|
|
p := NewPopulatedObject(popr, false)
|
2018-07-15 17:48:35 -04:00
|
|
|
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
2018-07-14 11:48:41 -04:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
|
|
}
|
|
|
|
msg := &Object{}
|
2018-07-15 17:48:35 -04:00
|
|
|
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
|
2018-07-14 11:48:41 -04:00
|
|
|
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 !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
|
2018-07-15 17:48:35 -04:00
|
|
|
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
|
2018-07-14 11:48:41 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestObjectJSON(t *testing.T) {
|
|
|
|
seed := time.Now().UnixNano()
|
2018-07-15 17:48:35 -04:00
|
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
2018-07-14 11:48:41 -04:00
|
|
|
p := NewPopulatedObject(popr, true)
|
2018-07-15 17:48:35 -04:00
|
|
|
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
|
2018-07-14 11:48:41 -04:00
|
|
|
jsondata, err := marshaler.MarshalToString(p)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
|
|
}
|
|
|
|
msg := &Object{}
|
2018-07-15 17:48:35 -04:00
|
|
|
err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg)
|
2018-07-14 11:48:41 -04:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
|
|
}
|
|
|
|
if !p.Equal(msg) {
|
|
|
|
t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func TestObjectProtoText(t *testing.T) {
|
|
|
|
seed := time.Now().UnixNano()
|
2018-07-15 17:48:35 -04:00
|
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
2018-07-14 11:48:41 -04:00
|
|
|
p := NewPopulatedObject(popr, true)
|
2018-07-15 17:48:35 -04:00
|
|
|
dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p)
|
2018-07-14 11:48:41 -04:00
|
|
|
msg := &Object{}
|
2018-07-15 17:48:35 -04:00
|
|
|
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
|
2018-07-14 11:48:41 -04:00
|
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
|
|
}
|
|
|
|
if !p.Equal(msg) {
|
|
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestObjectProtoCompactText(t *testing.T) {
|
|
|
|
seed := time.Now().UnixNano()
|
2018-07-15 17:48:35 -04:00
|
|
|
popr := math_rand.New(math_rand.NewSource(seed))
|
2018-07-14 11:48:41 -04:00
|
|
|
p := NewPopulatedObject(popr, true)
|
2018-07-15 17:48:35 -04:00
|
|
|
dAtA := github_com_gogo_protobuf_proto.CompactTextString(p)
|
2018-07-14 11:48:41 -04:00
|
|
|
msg := &Object{}
|
2018-07-15 17:48:35 -04:00
|
|
|
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
|
2018-07-14 11:48:41 -04:00
|
|
|
t.Fatalf("seed = %d, err = %v", seed, err)
|
|
|
|
}
|
|
|
|
if !p.Equal(msg) {
|
|
|
|
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestObjectGoString(t *testing.T) {
|
2018-07-15 17:48:35 -04:00
|
|
|
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
|
2018-07-14 11:48:41 -04:00
|
|
|
p := NewPopulatedObject(popr, false)
|
|
|
|
s1 := p.GoString()
|
|
|
|
s2 := fmt.Sprintf("%#v", p)
|
|
|
|
if s1 != s2 {
|
|
|
|
t.Fatalf("GoString want %v got %v", s1, s2)
|
|
|
|
}
|
2018-07-15 17:48:35 -04:00
|
|
|
_, err := go_parser.ParseExpr(s1)
|
2018-07-14 11:48:41 -04:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//These tests are generated by github.com/gogo/protobuf/plugin/testgen
|