Switch to github.com/golang/dep for vendoring

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
Mrunal Patel 2017-01-31 16:45:59 -08:00
parent d6ab91be27
commit 8e5b17cf13
15431 changed files with 3971413 additions and 8881 deletions

1
vendor/github.com/gogo/protobuf/test/.gitignore generated vendored Normal file
View file

@ -0,0 +1 @@
*.dat

44
vendor/github.com/gogo/protobuf/test/Makefile generated vendored Normal file
View file

@ -0,0 +1,44 @@
# Protocol Buffers for Go with Gadgets
#
# Copyright (c) 2013, The GoGo Authors. All rights reserved.
# http://github.com/gogo/protobuf
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
regenerate:
go install github.com/gogo/protobuf/protoc-gen-combo
protoc --gogo_out=. --proto_path=../:../../../../:../protobuf/:. thetest.proto
protoc-gen-combo --default=false --proto_path=../:../../../../:../protobuf/:. thetest.proto
cp uuid.go ./combos/both/
cp uuid.go ./combos/marshaler/
cp uuid.go ./combos/unmarshaler/
cp uuid.go ./combos/unsafeboth/
cp uuid.go ./combos/unsafemarshaler/
cp uuid.go ./combos/unsafeunmarshaler/
cp bug_test.go ./combos/both/
cp bug_test.go ./combos/marshaler/
cp bug_test.go ./combos/unmarshaler/
cp bug_test.go ./combos/unsafeboth/
cp bug_test.go ./combos/unsafemarshaler/
cp bug_test.go ./combos/unsafeunmarshaler/

View file

@ -0,0 +1,30 @@
# Protocol Buffers for Go with Gadgets
#
# Copyright (c) 2013, The GoGo Authors. All rights reserved.
# http://github.com/gogo/protobuf
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
regenerate:
(protoc --proto_path=../../../../../:../../protobuf/:. --gogo_out=. asym.proto)

View file

@ -0,0 +1,626 @@
// Code generated by protoc-gen-gogo.
// source: asym.proto
// DO NOT EDIT!
/*
Package asym is a generated protocol buffer package.
It is generated from these files:
asym.proto
It has these top-level messages:
M
MyType
*/
package asym
import proto "github.com/gogo/protobuf/proto"
import fmt "fmt"
import math "math"
import _ "github.com/gogo/protobuf/gogoproto"
import bytes "bytes"
import io "io"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type M struct {
Arr []MyType `protobuf:"bytes,1,rep,name=arr,customtype=MyType" json:"arr"`
XXX_unrecognized []byte `json:"-"`
}
func (m *M) Reset() { *m = M{} }
func (m *M) String() string { return proto.CompactTextString(m) }
func (*M) ProtoMessage() {}
func (*M) Descriptor() ([]byte, []int) { return fileDescriptorAsym, []int{0} }
type MyType struct {
XXX_unrecognized []byte `json:"-"`
}
func (m *MyType) Reset() { *m = MyType{} }
func (m *MyType) String() string { return proto.CompactTextString(m) }
func (*MyType) ProtoMessage() {}
func (*MyType) Descriptor() ([]byte, []int) { return fileDescriptorAsym, []int{1} }
func init() {
proto.RegisterType((*M)(nil), "asym.M")
proto.RegisterType((*MyType)(nil), "asym.MyType")
}
func (this *M) VerboseEqual(that interface{}) error {
if that == nil {
if this == nil {
return nil
}
return fmt.Errorf("that == nil && this != nil")
}
that1, ok := that.(*M)
if !ok {
that2, ok := that.(M)
if ok {
that1 = &that2
} else {
return fmt.Errorf("that is not of type *M")
}
}
if that1 == nil {
if this == nil {
return nil
}
return fmt.Errorf("that is type *M but is nil && this != nil")
} else if this == nil {
return fmt.Errorf("that is type *M but is not nil && this == nil")
}
if len(this.Arr) != len(that1.Arr) {
return fmt.Errorf("Arr this(%v) Not Equal that(%v)", len(this.Arr), len(that1.Arr))
}
for i := range this.Arr {
if !this.Arr[i].Equal(that1.Arr[i]) {
return fmt.Errorf("Arr this[%v](%v) Not Equal that[%v](%v)", i, this.Arr[i], i, that1.Arr[i])
}
}
if !bytes.Equal(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
}
func (this *M) Equal(that interface{}) bool {
if that == nil {
if this == nil {
return true
}
return false
}
that1, ok := that.(*M)
if !ok {
that2, ok := that.(M)
if ok {
that1 = &that2
} else {
return false
}
}
if that1 == nil {
if this == nil {
return true
}
return false
} else if this == nil {
return false
}
if len(this.Arr) != len(that1.Arr) {
return false
}
for i := range this.Arr {
if !this.Arr[i].Equal(that1.Arr[i]) {
return false
}
}
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
return false
}
return true
}
func (this *MyType) VerboseEqual(that interface{}) error {
if that == nil {
if this == nil {
return nil
}
return fmt.Errorf("that == nil && this != nil")
}
that1, ok := that.(*MyType)
if !ok {
that2, ok := that.(MyType)
if ok {
that1 = &that2
} else {
return fmt.Errorf("that is not of type *MyType")
}
}
if that1 == nil {
if this == nil {
return nil
}
return fmt.Errorf("that is type *MyType but is nil && this != nil")
} else if this == nil {
return fmt.Errorf("that is type *MyType but is not nil && this == nil")
}
if !bytes.Equal(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
}
func (this *MyType) Equal(that interface{}) bool {
if that == nil {
if this == nil {
return true
}
return false
}
that1, ok := that.(*MyType)
if !ok {
that2, ok := that.(MyType)
if ok {
that1 = &that2
} else {
return false
}
}
if that1 == nil {
if this == nil {
return true
}
return false
} else if this == nil {
return false
}
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
return false
}
return true
}
func (m *M) Marshal() (data []byte, err error) {
size := m.Size()
data = make([]byte, size)
n, err := m.MarshalTo(data)
if err != nil {
return nil, err
}
return data[:n], nil
}
func (m *M) MarshalTo(data []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if len(m.Arr) > 0 {
for _, msg := range m.Arr {
data[i] = 0xa
i++
i = encodeVarintAsym(data, i, uint64(msg.Size()))
n, err := msg.MarshalTo(data[i:])
if err != nil {
return 0, err
}
i += n
}
}
if m.XXX_unrecognized != nil {
i += copy(data[i:], m.XXX_unrecognized)
}
return i, nil
}
func encodeFixed64Asym(data []byte, offset int, v uint64) int {
data[offset] = uint8(v)
data[offset+1] = uint8(v >> 8)
data[offset+2] = uint8(v >> 16)
data[offset+3] = uint8(v >> 24)
data[offset+4] = uint8(v >> 32)
data[offset+5] = uint8(v >> 40)
data[offset+6] = uint8(v >> 48)
data[offset+7] = uint8(v >> 56)
return offset + 8
}
func encodeFixed32Asym(data []byte, offset int, v uint32) int {
data[offset] = uint8(v)
data[offset+1] = uint8(v >> 8)
data[offset+2] = uint8(v >> 16)
data[offset+3] = uint8(v >> 24)
return offset + 4
}
func encodeVarintAsym(data []byte, offset int, v uint64) int {
for v >= 1<<7 {
data[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
data[offset] = uint8(v)
return offset + 1
}
func NewPopulatedM(r randyAsym, easy bool) *M {
this := &M{}
if r.Intn(10) != 0 {
v1 := r.Intn(10)
this.Arr = make([]MyType, v1)
for i := 0; i < v1; i++ {
v2 := NewPopulatedMyType(r)
this.Arr[i] = *v2
}
}
if !easy && r.Intn(10) != 0 {
this.XXX_unrecognized = randUnrecognizedAsym(r, 2)
}
return this
}
type randyAsym interface {
Float32() float32
Float64() float64
Int63() int64
Int31() int32
Uint32() uint32
Intn(n int) int
}
func randUTF8RuneAsym(r randyAsym) rune {
ru := r.Intn(62)
if ru < 10 {
return rune(ru + 48)
} else if ru < 36 {
return rune(ru + 55)
}
return rune(ru + 61)
}
func randStringAsym(r randyAsym) string {
v3 := r.Intn(100)
tmps := make([]rune, v3)
for i := 0; i < v3; i++ {
tmps[i] = randUTF8RuneAsym(r)
}
return string(tmps)
}
func randUnrecognizedAsym(r randyAsym, maxFieldNumber int) (data []byte) {
l := r.Intn(5)
for i := 0; i < l; i++ {
wire := r.Intn(4)
if wire == 3 {
wire = 5
}
fieldNumber := maxFieldNumber + r.Intn(100)
data = randFieldAsym(data, r, fieldNumber, wire)
}
return data
}
func randFieldAsym(data []byte, r randyAsym, fieldNumber int, wire int) []byte {
key := uint32(fieldNumber)<<3 | uint32(wire)
switch wire {
case 0:
data = encodeVarintPopulateAsym(data, uint64(key))
v4 := r.Int63()
if r.Intn(2) == 0 {
v4 *= -1
}
data = encodeVarintPopulateAsym(data, uint64(v4))
case 1:
data = encodeVarintPopulateAsym(data, uint64(key))
data = append(data, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
case 2:
data = encodeVarintPopulateAsym(data, uint64(key))
ll := r.Intn(100)
data = encodeVarintPopulateAsym(data, uint64(ll))
for j := 0; j < ll; j++ {
data = append(data, byte(r.Intn(256)))
}
default:
data = encodeVarintPopulateAsym(data, uint64(key))
data = append(data, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
}
return data
}
func encodeVarintPopulateAsym(data []byte, v uint64) []byte {
for v >= 1<<7 {
data = append(data, uint8(uint64(v)&0x7f|0x80))
v >>= 7
}
data = append(data, uint8(v))
return data
}
func (m *M) Size() (n int) {
var l int
_ = l
if len(m.Arr) > 0 {
for _, e := range m.Arr {
l = e.Size()
n += 1 + l + sovAsym(uint64(l))
}
}
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n
}
func sovAsym(x uint64) (n int) {
for {
n++
x >>= 7
if x == 0 {
break
}
}
return n
}
func sozAsym(x uint64) (n int) {
return sovAsym(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *M) Unmarshal(data []byte) error {
l := len(data)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAsym
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := data[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: M: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: M: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Arr", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAsym
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := data[iNdEx]
iNdEx++
byteLen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthAsym
}
postIndex := iNdEx + byteLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
var v MyType
m.Arr = append(m.Arr, v)
if err := m.Arr[len(m.Arr)-1].Unmarshal(data[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipAsym(data[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthAsym
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...)
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *MyType) Unmarshal(data []byte) error {
l := len(data)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAsym
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := data[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: MyType: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: MyType: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
default:
iNdEx = preIndex
skippy, err := skipAsym(data[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthAsym
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...)
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipAsym(data []byte) (n int, err error) {
l := len(data)
iNdEx := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowAsym
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := data[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowAsym
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if data[iNdEx-1] < 0x80 {
break
}
}
return iNdEx, nil
case 1:
iNdEx += 8
return iNdEx, nil
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowAsym
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := data[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
iNdEx += length
if length < 0 {
return 0, ErrInvalidLengthAsym
}
return iNdEx, nil
case 3:
for {
var innerWire uint64
var start int = iNdEx
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowAsym
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := data[iNdEx]
iNdEx++
innerWire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
innerWireType := int(innerWire & 0x7)
if innerWireType == 4 {
break
}
next, err := skipAsym(data[start:])
if err != nil {
return 0, err
}
iNdEx = start + next
}
return iNdEx, nil
case 4:
return iNdEx, nil
case 5:
iNdEx += 4
return iNdEx, nil
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
}
panic("unreachable")
}
var (
ErrInvalidLengthAsym = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowAsym = fmt.Errorf("proto: integer overflow")
)
func init() { proto.RegisterFile("asym.proto", fileDescriptorAsym) }
var fileDescriptorAsym = []byte{
// 163 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xe2, 0x4a, 0x2c, 0xae, 0xcc,
0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x01, 0xb1, 0xa5, 0x74, 0xd3, 0x33, 0x4b, 0x32,
0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0xd3, 0xf3, 0xd3, 0xf3, 0xf5, 0xc1, 0x92, 0x49, 0xa5,
0x69, 0x60, 0x1e, 0x98, 0x03, 0x66, 0x41, 0x34, 0x29, 0xa9, 0x72, 0x31, 0xfa, 0x0a, 0x29, 0x70,
0x31, 0x27, 0x16, 0x15, 0x49, 0x30, 0x2a, 0x30, 0x6b, 0xf0, 0x38, 0xf1, 0x9d, 0xb8, 0x27, 0xcf,
0x70, 0xeb, 0x9e, 0x3c, 0x9b, 0x6f, 0x65, 0x48, 0x65, 0x41, 0x6a, 0x10, 0x48, 0x4a, 0x49, 0x8a,
0x0b, 0xca, 0xb5, 0x12, 0xd8, 0xb1, 0x40, 0x9e, 0xe1, 0xc7, 0x02, 0x79, 0x86, 0x8e, 0x85, 0xf2,
0x0c, 0x0b, 0x16, 0xca, 0x33, 0x38, 0xc9, 0x3c, 0x78, 0x28, 0xc7, 0xf8, 0xe3, 0xa1, 0x1c, 0xe3,
0x8a, 0x47, 0x72, 0x8c, 0x3b, 0x1e, 0xc9, 0x31, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c,
0xe3, 0x83, 0x47, 0x72, 0x8c, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9c, 0x0b, 0x12, 0x6c, 0xa2,
0x00, 0x00, 0x00,
}

View file

@ -0,0 +1,52 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2015, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package asym;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
option (gogoproto.marshaler_all) = true;
option (gogoproto.sizer_all) = true;
option (gogoproto.unmarshaler_all) = true;
option (gogoproto.populate_all) = true;
option (gogoproto.testgen_all) = true;
message M {
repeated bytes arr = 1 [(gogoproto.customtype) = "MyType", (gogoproto.nullable) = false];
}
message MyType {
option (gogoproto.marshaler) = false;
option (gogoproto.sizer) = false;
option (gogoproto.populate) = false;
option (gogoproto.testgen) = false;
}

View file

@ -0,0 +1,40 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package asym
import (
"testing"
)
func TestAsym(t *testing.T) {
m := &M{[]MyType{{}, {}}, nil}
if err := m.VerboseEqual(m); err != nil {
t.Fatalf("should be equal: %v", err)
}
}

View file

@ -0,0 +1,186 @@
// Code generated by protoc-gen-gogo.
// source: asym.proto
// DO NOT EDIT!
/*
Package asym is a generated protocol buffer package.
It is generated from these files:
asym.proto
It has these top-level messages:
M
MyType
*/
package asym
import testing "testing"
import math_rand "math/rand"
import time "time"
import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
import github_com_gogo_protobuf_jsonpb "github.com/gogo/protobuf/jsonpb"
import proto "github.com/gogo/protobuf/proto"
import fmt "fmt"
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 TestMProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedM(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &M{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func TestMMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedM(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 {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &M{}
if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
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)
}
}
func TestMJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedM(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &M{}
err = github_com_gogo_protobuf_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 TestMProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedM(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &M{}
if err := github_com_gogo_protobuf_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 TestMProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedM(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &M{}
if err := github_com_gogo_protobuf_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 TestMVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedM(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &M{}
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 TestMSize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedM(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
//These tests are generated by github.com/gogo/protobuf/plugin/testgen

View file

@ -0,0 +1,64 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package asym
func NewPopulatedMyType(r randyAsym) *MyType {
this := &MyType{}
return this
}
func (m MyType) Marshal() (data []byte, err error) {
size := m.Size()
data = make([]byte, size)
n, err := m.MarshalTo(data)
if err != nil {
return nil, err
}
return data[:n], nil
}
func (m *MyType) MarshalTo(data []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.XXX_unrecognized != nil {
i += copy(data[i:], m.XXX_unrecognized)
}
return i, nil
}
func (m *MyType) Size() (n int) {
var l int
_ = l
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n
}

252
vendor/github.com/gogo/protobuf/test/bug_test.go generated vendored Normal file
View file

@ -0,0 +1,252 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package test
import (
"fmt"
"math"
"math/rand"
"testing"
"time"
"github.com/gogo/protobuf/proto"
)
//http://code.google.com/p/goprotobuf/issues/detail?id=39
func TestBugUint32VarintSize(t *testing.T) {
temp := uint32(math.MaxUint32)
n := &NinOptNative{}
n.Field5 = &temp
data, err := proto.Marshal(n)
if err != nil {
panic(err)
}
if len(data) != 6 {
t.Fatalf("data should be length 6, but its %#v", data)
}
}
func TestBugZeroLengthSliceSize(t *testing.T) {
n := &NinRepPackedNative{
Field8: []int64{},
}
size := n.Size()
data, err := proto.Marshal(n)
if err != nil {
panic(err)
}
if len(data) != size {
t.Fatalf("expected %v, but got %v", len(data), size)
}
}
//http://code.google.com/p/goprotobuf/issues/detail?id=40
func TestBugPackedProtoSize(t *testing.T) {
n := &NinRepPackedNative{
Field4: []int64{172960727389894724, 2360337516664475010, 860833876131988189, 9068073014890763245, 7794843386260381831, 4023536436053141786, 8992311247496919020, 4330096163611305776, 4490411416244976467, 7873947349172707443, 2754969595834279669, 1360667855926938684, 4771480785172657389, 4875578924966668055, 8070579869808877481, 9128179594766551001, 4630419407064527516, 863844540220372892, 8208727650143073487, 7086117356301045838, 7779695211931506151, 5493835345187563535, 9119767633370806007, 9054342025895349248, 1887303228838508438, 7624573031734528281, 1874668389749611225, 3517684643468970593, 6677697606628877758, 7293473953189936168, 444475066704085538, 8594971141363049302, 1146643249094989673, 733393306232853371, 7721178528893916886, 7784452000911004429, 6436373110242711440, 6897422461738321237, 8772249155667732778, 6211871464311393541, 3061903718310406883, 7845488913176136641, 8342255034663902574, 3443058984649725748, 8410801047334832902, 7496541071517841153, 4305416923521577765, 7814967600020476457, 8671843803465481186, 3490266370361096855, 1447425664719091336, 653218597262334239, 8306243902880091940, 7851896059762409081, 5936760560798954978, 5755724498441478025, 7022701569985035966, 3707709584811468220, 529069456924666920, 7986469043681522462, 3092513330689518836, 5103541550470476202, 3577384161242626406, 3733428084624703294, 8388690542440473117, 3262468785346149388, 8788358556558007570, 5476276940198542020, 7277903243119461239, 5065861426928605020, 7533460976202697734, 1749213838654236956, 557497603941617931, 5496307611456481108, 6444547750062831720, 6992758776744205596, 7356719693428537399, 2896328872476734507, 381447079530132038, 598300737753233118, 3687980626612697715, 7240924191084283349, 8172414415307971170, 4847024388701257185, 2081764168600256551, 3394217778539123488, 6244660626429310923, 8301712215675381614, 5360615125359461174, 8410140945829785773, 3152963269026381373, 6197275282781459633, 4419829061407546410, 6262035523070047537, 2837207483933463885, 2158105736666826128, 8150764172235490711},
Field7: []int32{249451845, 1409974015, 393609128, 435232428, 1817529040, 91769006, 861170933, 1556185603, 1568580279, 1236375273, 512276621, 693633711, 967580535, 1950715977, 853431462, 1362390253, 159591204, 111900629, 322985263, 279671129, 1592548430, 465651370, 733849989, 1172059400, 1574824441, 263541092, 1271612397, 1520584358, 467078791, 117698716, 1098255064, 2054264846, 1766452305, 1267576395, 1557505617, 1187833560, 956187431, 1970977586, 1160235159, 1610259028, 489585797, 459139078, 566263183, 954319278, 1545018565, 1753946743, 948214318, 422878159, 883926576, 1424009347, 824732372, 1290433180, 80297942, 417294230, 1402647904, 2078392782, 220505045, 787368129, 463781454, 293083578, 808156928, 293976361},
Field9: []uint32{0xaa4976e8, 0x3da8cc4c, 0x8c470d83, 0x344d964e, 0x5b90925, 0xa4c4d34e, 0x666eff19, 0xc238e552, 0x9be53bb6, 0x56364245, 0x33ee079d, 0x96bf0ede, 0x7941b74f, 0xdb07cb47, 0x6d76d827, 0x9b211d5d, 0x2798adb6, 0xe48b0c3b, 0x87061b21, 0x48f4e4d2, 0x3e5d5c12, 0x5ee91288, 0x336d4f35, 0xe1d44941, 0xc065548d, 0x2953d73f, 0x873af451, 0xfc769db, 0x9f1bf8da, 0x9baafdfc, 0xf1d3d770, 0x5bb5d2b4, 0xc2c67c48, 0x6845c4c1, 0xa48f32b0, 0xbb04bb70, 0xa5b1ca36, 0x8d98356a, 0x2171f654, 0x5ae279b0, 0x6c4a3d6b, 0x4fff5468, 0xcf9bf851, 0x68513614, 0xdbecd9b0, 0x9553ed3c, 0xa494a736, 0x42205438, 0xbf8e5caa, 0xd3283c6, 0x76d20788, 0x9179826f, 0x96b24f85, 0xbc2eacf4, 0xe4afae0b, 0x4bca85cb, 0x35e63b5b, 0xd7ccee0c, 0x2b506bb9, 0xe78e9f44, 0x9ad232f1, 0x99a37335, 0xa5d6ffc8},
Field11: []uint64{0x53c01ebc, 0x4fb85ba6, 0x8805eea1, 0xb20ec896, 0x93b63410, 0xec7c9492, 0x50765a28, 0x19592106, 0x2ecc59b3, 0x39cd474f, 0xe4c9e47, 0x444f48c5, 0xe7731d32, 0xf3f43975, 0x603caedd, 0xbb05a1af, 0xa808e34e, 0x88580b07, 0x4c96bbd1, 0x730b4ab9, 0xed126e2b, 0x6db48205, 0x154ba1b9, 0xc26bfb6a, 0x389aa052, 0x869d966c, 0x7c86b366, 0xcc8edbcd, 0xfa8d6dad, 0xcf5857d9, 0x2d9cda0f, 0x1218a0b8, 0x41bf997, 0xf0ca65ac, 0xa610d4b9, 0x8d362e28, 0xb7212d87, 0x8e0fe109, 0xbee041d9, 0x759be2f6, 0x35fef4f3, 0xaeacdb71, 0x10888852, 0xf4e28117, 0xe2a14812, 0x73b748dc, 0xd1c3c6b2, 0xfef41bf0, 0xc9b43b62, 0x810e4faa, 0xcaa41c06, 0x1893fe0d, 0xedc7c850, 0xd12b9eaa, 0x467ee1a9, 0xbe84756b, 0xda7b1680, 0xdc069ffe, 0xf1e7e9f9, 0xb3d95370, 0xa92b77df, 0x5693ac41, 0xd04b7287, 0x27aebf15, 0x837b316e, 0x4dbe2263, 0xbab70c67, 0x547dab21, 0x3c346c1f, 0xb8ef0e4e, 0xfe2d03ce, 0xe1d75955, 0xfec1306, 0xba35c23e, 0xb784ed04, 0x2a4e33aa, 0x7e19d09a, 0x3827c1fe, 0xf3a51561, 0xef765e2b, 0xb044256c, 0x62b322be, 0xf34d56be, 0xeb71b369, 0xffe1294f, 0x237fe8d0, 0x77a1473b, 0x239e1196, 0xdd19bf3d, 0x82c91fe1, 0x95361c57, 0xffea3f1b, 0x1a094c84},
Field12: []int64{8308420747267165049, 3664160795077875961, 7868970059161834817, 7237335984251173739, 5254748003907196506, 3362259627111837480, 430460752854552122, 5119635556501066533, 1277716037866233522, 9185775384759813768, 833932430882717888, 7986528304451297640, 6792233378368656337, 2074207091120609721, 1788723326198279432, 7756514594746453657, 2283775964901597324, 3061497730110517191, 7733947890656120277, 626967303632386244, 7822928600388582821, 3489658753000061230, 168869995163005961, 248814782163480763, 477885608911386247, 4198422415674133867, 3379354662797976109, 9925112544736939, 1486335136459138480, 4561560414032850671, 1010864164014091267, 186722821683803084, 5106357936724819318, 1298160820191228988, 4675403242419953145, 7130634540106489752, 7101280006672440929, 7176058292431955718, 9109875054097770321, 6810974877085322872, 4736707874303993641, 8993135362721382187, 6857881554990254283, 3704748883307461680, 1099360832887634994, 5207691918707192633, 5984721695043995243},
}
size := proto.Size(n)
data, err := proto.Marshal(n)
if err != nil {
panic(err)
}
if len(data) != size {
t.Fatalf("expected %v, but got %v diff is %v", len(data), size, len(data)-size)
}
}
func testSize(m interface {
proto.Message
Size() int
}, desc string, expected int) ([]byte, error) {
data, err := proto.Marshal(m)
if err != nil {
return nil, err
}
protoSize := proto.Size(m)
mSize := m.Size()
lenData := len(data)
if protoSize != mSize || protoSize != lenData || mSize != lenData {
return nil, fmt.Errorf("%s proto.Size(m){%d} != m.Size(){%d} != len(data){%d}", desc, protoSize, mSize, lenData)
}
if got := protoSize; got != expected {
return nil, fmt.Errorf("%s proto.Size(m) got %d expected %d", desc, got, expected)
}
if got := mSize; got != expected {
return nil, fmt.Errorf("%s m.Size() got %d expected %d", desc, got, expected)
}
if got := lenData; got != expected {
return nil, fmt.Errorf("%s len(data) got %d expected %d", desc, got, expected)
}
return data, nil
}
func TestInt32Int64Compatibility(t *testing.T) {
//test nullable int32 and int64
data1, err := testSize(&NinOptNative{
Field3: proto.Int32(-1),
}, "nullable", 11)
if err != nil {
t.Error(err)
}
//change marshaled data1 to unmarshal into 4th field which is an int64
data1[0] = uint8(uint32(4 /*fieldNumber*/)<<3 | uint32(0 /*wireType*/))
u1 := &NinOptNative{}
if err = proto.Unmarshal(data1, u1); err != nil {
t.Error(err)
}
if !u1.Equal(&NinOptNative{
Field4: proto.Int64(-1),
}) {
t.Error("nullable unmarshaled int32 is not the same int64")
}
//test non-nullable int32 and int64
data2, err := testSize(&NidOptNative{
Field3: -1,
}, "non nullable", 67)
if err != nil {
t.Error(err)
}
//change marshaled data2 to unmarshal into 4th field which is an int64
field3 := uint8(uint32(3 /*fieldNumber*/)<<3 | uint32(0 /*wireType*/))
field4 := uint8(uint32(4 /*fieldNumber*/)<<3 | uint32(0 /*wireType*/))
for i, c := range data2 {
if c == field4 {
data2[i] = field3
} else if c == field3 {
data2[i] = field4
}
}
u2 := &NidOptNative{}
if err = proto.Unmarshal(data2, u2); err != nil {
t.Error(err)
}
if !u2.Equal(&NidOptNative{
Field4: -1,
}) {
t.Error("non nullable unmarshaled int32 is not the same int64")
}
//test packed repeated int32 and int64
m4 := &NinRepPackedNative{
Field3: []int32{-1},
}
data4, err := testSize(m4, "packed", 12)
if err != nil {
t.Error(err)
}
u4 := &NinRepPackedNative{}
if err := proto.Unmarshal(data4, u4); err != nil {
t.Error(err)
}
if err := u4.VerboseEqual(m4); err != nil {
t.Fatalf("%#v", u4)
}
//test repeated int32 and int64
if _, err := testSize(&NinRepNative{
Field3: []int32{-1},
}, "repeated", 11); err != nil {
t.Error(err)
}
t.Logf("tested all")
}
func TestRepeatedExtensionsMsgsIssue161(t *testing.T) {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
rep := 10
nins := make([]*NinOptNative, rep)
for i := range nins {
nins[i] = NewPopulatedNinOptNative(r, true)
}
input := &MyExtendable{}
if err := proto.SetExtension(input, E_FieldE, nins); err != nil {
t.Fatal(err)
}
data, err := proto.Marshal(input)
if err != nil {
t.Fatal(err)
}
output := &MyExtendable{}
if err := proto.Unmarshal(data, output); err != nil {
t.Fatal(err)
}
if !input.Equal(output) {
t.Fatal("expected equal")
}
data2, err2 := proto.Marshal(output)
if err2 != nil {
t.Fatal(err2)
}
if len(data) != len(data2) {
t.Fatal("expected equal length buffers")
}
}
func TestRepeatedExtensionsFieldsIssue161(t *testing.T) {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
rep := 10
ints := make([]int64, rep)
for i := range ints {
ints[i] = r.Int63()
}
input := &MyExtendable{}
if err := proto.SetExtension(input, E_FieldD, ints); err != nil {
t.Fatal(err)
}
data, err := proto.Marshal(input)
if err != nil {
t.Fatal(err)
}
output := &MyExtendable{}
if err := proto.Unmarshal(data, output); err != nil {
t.Fatal(err)
}
if !input.Equal(output) {
t.Fatal("expected equal")
}
data2, err2 := proto.Marshal(output)
if err2 != nil {
t.Fatal(err2)
}
if len(data) != len(data2) {
t.Fatal("expected equal length buffers")
}
}

31
vendor/github.com/gogo/protobuf/test/casttype/Makefile generated vendored Normal file
View file

@ -0,0 +1,31 @@
# Protocol Buffers for Go with Gadgets
#
# Copyright (c) 2015, The GoGo Authors. All rights reserved.
# http://github.com/gogo/protobuf
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
regenerate:
go install github.com/gogo/protobuf/protoc-gen-combo
protoc-gen-combo --version="3.0.0" --proto_path=../../../../../:../../protobuf/:. casttype.proto

View file

@ -0,0 +1,79 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2015, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package casttype;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.goproto_enum_prefix_all) = false;
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
option (gogoproto.stringer_all) = true;
option (gogoproto.gostring_all) = true;
option (gogoproto.face_all) = true;
option (gogoproto.description_all) = true;
option (gogoproto.testgen_all) = true;
option (gogoproto.populate_all) = true;
option (gogoproto.benchgen_all) = true;
option (gogoproto.unmarshaler_all) = false;
option (gogoproto.marshaler_all) = false;
option (gogoproto.sizer_all) = true;
option (gogoproto.goproto_enum_stringer_all) = false;
option (gogoproto.enum_stringer_all) = true;
option (gogoproto.unsafe_marshaler_all) = false;
option (gogoproto.unsafe_unmarshaler_all) = false;
message Castaway {
optional int64 Int32Ptr = 1 [(gogoproto.casttype) = "int32"];
optional int64 Int32 = 2 [(gogoproto.casttype) = "int32", (gogoproto.nullable) = false];
optional uint64 MyUint64Ptr = 3 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyUint64Type"];
optional uint64 MyUint64 = 4 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyUint64Type", (gogoproto.nullable) = false];
optional float MyFloat32Ptr = 5 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat32Type"];
optional float MyFloat32 = 6 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat32Type", (gogoproto.nullable) = false];
optional double MyFloat64Ptr = 7 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat64Type"];
optional double MyFloat64 = 8 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat64Type", (gogoproto.nullable) = false];
optional bytes MyBytes = 9 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.Bytes"];
optional bytes NormalBytes = 10;
repeated uint64 MyUint64s = 11 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyUint64Type"];
map<string,uint64> MyMap = 12 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyMapType"];
map<string,uint64> MyCustomMap = 13 [(gogoproto.castkey) = "github.com/gogo/protobuf/test/casttype.MyStringType", (gogoproto.castvalue) = "github.com/gogo/protobuf/test/casttype.MyUint64Type"];
map<int32,Wilson> MyNullableMap = 14 [(gogoproto.castkey) = "github.com/gogo/protobuf/test/casttype.MyInt32Type"];
map<int32,Wilson> MyEmbeddedMap = 15 [(gogoproto.castkey) = "github.com/gogo/protobuf/test/casttype.MyInt32Type", (gogoproto.nullable) = false];
}
message Wilson {
optional int64 Int64 = 1;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,79 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2015, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package casttype;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.goproto_enum_prefix_all) = false;
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
option (gogoproto.stringer_all) = true;
option (gogoproto.gostring_all) = true;
option (gogoproto.face_all) = true;
option (gogoproto.description_all) = true;
option (gogoproto.testgen_all) = true;
option (gogoproto.populate_all) = true;
option (gogoproto.benchgen_all) = true;
option (gogoproto.unmarshaler_all) = true;
option (gogoproto.marshaler_all) = true;
option (gogoproto.sizer_all) = true;
option (gogoproto.goproto_enum_stringer_all) = false;
option (gogoproto.enum_stringer_all) = true;
option (gogoproto.unsafe_marshaler_all) = false;
option (gogoproto.unsafe_unmarshaler_all) = false;
message Castaway {
optional int64 Int32Ptr = 1 [(gogoproto.casttype) = "int32"];
optional int64 Int32 = 2 [(gogoproto.casttype) = "int32", (gogoproto.nullable) = false];
optional uint64 MyUint64Ptr = 3 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyUint64Type"];
optional uint64 MyUint64 = 4 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyUint64Type", (gogoproto.nullable) = false];
optional float MyFloat32Ptr = 5 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat32Type"];
optional float MyFloat32 = 6 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat32Type", (gogoproto.nullable) = false];
optional double MyFloat64Ptr = 7 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat64Type"];
optional double MyFloat64 = 8 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat64Type", (gogoproto.nullable) = false];
optional bytes MyBytes = 9 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.Bytes"];
optional bytes NormalBytes = 10;
repeated uint64 MyUint64s = 11 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyUint64Type"];
map<string,uint64> MyMap = 12 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyMapType"];
map<string,uint64> MyCustomMap = 13 [(gogoproto.castkey) = "github.com/gogo/protobuf/test/casttype.MyStringType", (gogoproto.castvalue) = "github.com/gogo/protobuf/test/casttype.MyUint64Type"];
map<int32,Wilson> MyNullableMap = 14 [(gogoproto.castkey) = "github.com/gogo/protobuf/test/casttype.MyInt32Type"];
map<int32,Wilson> MyEmbeddedMap = 15 [(gogoproto.castkey) = "github.com/gogo/protobuf/test/casttype.MyInt32Type", (gogoproto.nullable) = false];
}
message Wilson {
optional int64 Int64 = 1;
}

View file

@ -0,0 +1,513 @@
// Code generated by protoc-gen-gogo.
// source: combos/both/casttype.proto
// DO NOT EDIT!
/*
Package casttype is a generated protocol buffer package.
It is generated from these files:
combos/both/casttype.proto
It has these top-level messages:
Castaway
Wilson
*/
package casttype
import testing "testing"
import math_rand "math/rand"
import time "time"
import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
import github_com_gogo_protobuf_jsonpb "github.com/gogo/protobuf/jsonpb"
import fmt "fmt"
import go_parser "go/parser"
import proto "github.com/gogo/protobuf/proto"
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 TestCastawayProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func TestCastawayMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(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 {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
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)
}
}
func BenchmarkCastawayProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedCastaway(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 BenchmarkCastawayProtoUnmarshal(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(NewPopulatedCastaway(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Castaway{}
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 TestWilsonProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func TestWilsonMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(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 {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
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)
}
}
func BenchmarkWilsonProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedWilson(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 BenchmarkWilsonProtoUnmarshal(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(NewPopulatedWilson(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Wilson{}
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 TestCastawayJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
err = github_com_gogo_protobuf_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 TestWilsonJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
err = github_com_gogo_protobuf_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 TestCastawayProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestCastawayProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestCasttypeDescription(t *testing.T) {
CasttypeDescription()
}
func TestCastawayVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Castaway{}
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 TestWilsonVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Wilson{}
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 TestCastawayFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestWilsonFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestCastawayGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(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 TestWilsonGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(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 TestCastawaySize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkCastawaySize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedCastaway(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestWilsonSize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkWilsonSize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedWilson(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestCastawayStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
func TestWilsonStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
//These tests are generated by github.com/gogo/protobuf/plugin/testgen

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,79 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2015, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package casttype;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.goproto_enum_prefix_all) = false;
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
option (gogoproto.stringer_all) = true;
option (gogoproto.gostring_all) = true;
option (gogoproto.face_all) = true;
option (gogoproto.description_all) = true;
option (gogoproto.testgen_all) = true;
option (gogoproto.populate_all) = true;
option (gogoproto.benchgen_all) = true;
option (gogoproto.unmarshaler_all) = false;
option (gogoproto.marshaler_all) = true;
option (gogoproto.sizer_all) = true;
option (gogoproto.goproto_enum_stringer_all) = false;
option (gogoproto.enum_stringer_all) = true;
option (gogoproto.unsafe_marshaler_all) = false;
option (gogoproto.unsafe_unmarshaler_all) = false;
message Castaway {
optional int64 Int32Ptr = 1 [(gogoproto.casttype) = "int32"];
optional int64 Int32 = 2 [(gogoproto.casttype) = "int32", (gogoproto.nullable) = false];
optional uint64 MyUint64Ptr = 3 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyUint64Type"];
optional uint64 MyUint64 = 4 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyUint64Type", (gogoproto.nullable) = false];
optional float MyFloat32Ptr = 5 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat32Type"];
optional float MyFloat32 = 6 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat32Type", (gogoproto.nullable) = false];
optional double MyFloat64Ptr = 7 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat64Type"];
optional double MyFloat64 = 8 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat64Type", (gogoproto.nullable) = false];
optional bytes MyBytes = 9 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.Bytes"];
optional bytes NormalBytes = 10;
repeated uint64 MyUint64s = 11 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyUint64Type"];
map<string,uint64> MyMap = 12 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyMapType"];
map<string,uint64> MyCustomMap = 13 [(gogoproto.castkey) = "github.com/gogo/protobuf/test/casttype.MyStringType", (gogoproto.castvalue) = "github.com/gogo/protobuf/test/casttype.MyUint64Type"];
map<int32,Wilson> MyNullableMap = 14 [(gogoproto.castkey) = "github.com/gogo/protobuf/test/casttype.MyInt32Type"];
map<int32,Wilson> MyEmbeddedMap = 15 [(gogoproto.castkey) = "github.com/gogo/protobuf/test/casttype.MyInt32Type", (gogoproto.nullable) = false];
}
message Wilson {
optional int64 Int64 = 1;
}

View file

@ -0,0 +1,513 @@
// Code generated by protoc-gen-gogo.
// source: combos/marshaler/casttype.proto
// DO NOT EDIT!
/*
Package casttype is a generated protocol buffer package.
It is generated from these files:
combos/marshaler/casttype.proto
It has these top-level messages:
Castaway
Wilson
*/
package casttype
import testing "testing"
import math_rand "math/rand"
import time "time"
import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
import github_com_gogo_protobuf_jsonpb "github.com/gogo/protobuf/jsonpb"
import fmt "fmt"
import go_parser "go/parser"
import proto "github.com/gogo/protobuf/proto"
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 TestCastawayProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func TestCastawayMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(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 {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
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)
}
}
func BenchmarkCastawayProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedCastaway(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 BenchmarkCastawayProtoUnmarshal(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(NewPopulatedCastaway(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Castaway{}
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 TestWilsonProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func TestWilsonMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(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 {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
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)
}
}
func BenchmarkWilsonProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedWilson(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 BenchmarkWilsonProtoUnmarshal(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(NewPopulatedWilson(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Wilson{}
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 TestCastawayJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
err = github_com_gogo_protobuf_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 TestWilsonJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
err = github_com_gogo_protobuf_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 TestCastawayProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestCastawayProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestCasttypeDescription(t *testing.T) {
CasttypeDescription()
}
func TestCastawayVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Castaway{}
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 TestWilsonVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Wilson{}
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 TestCastawayFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestWilsonFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestCastawayGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(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 TestWilsonGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(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 TestCastawaySize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkCastawaySize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedCastaway(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestWilsonSize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkWilsonSize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedWilson(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestCastawayStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
func TestWilsonStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
//These tests are generated by github.com/gogo/protobuf/plugin/testgen

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,79 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2015, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package casttype;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.goproto_enum_prefix_all) = false;
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
option (gogoproto.stringer_all) = true;
option (gogoproto.gostring_all) = true;
option (gogoproto.face_all) = true;
option (gogoproto.description_all) = true;
option (gogoproto.testgen_all) = true;
option (gogoproto.populate_all) = true;
option (gogoproto.benchgen_all) = true;
option (gogoproto.unmarshaler_all) = false;
option (gogoproto.marshaler_all) = false;
option (gogoproto.sizer_all) = true;
option (gogoproto.goproto_enum_stringer_all) = false;
option (gogoproto.enum_stringer_all) = true;
option (gogoproto.unsafe_marshaler_all) = false;
option (gogoproto.unsafe_unmarshaler_all) = false;
message Castaway {
optional int64 Int32Ptr = 1 [(gogoproto.casttype) = "int32"];
optional int64 Int32 = 2 [(gogoproto.casttype) = "int32", (gogoproto.nullable) = false];
optional uint64 MyUint64Ptr = 3 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyUint64Type"];
optional uint64 MyUint64 = 4 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyUint64Type", (gogoproto.nullable) = false];
optional float MyFloat32Ptr = 5 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat32Type"];
optional float MyFloat32 = 6 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat32Type", (gogoproto.nullable) = false];
optional double MyFloat64Ptr = 7 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat64Type"];
optional double MyFloat64 = 8 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat64Type", (gogoproto.nullable) = false];
optional bytes MyBytes = 9 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.Bytes"];
optional bytes NormalBytes = 10;
repeated uint64 MyUint64s = 11 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyUint64Type"];
map<string,uint64> MyMap = 12 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyMapType"];
map<string,uint64> MyCustomMap = 13 [(gogoproto.castkey) = "github.com/gogo/protobuf/test/casttype.MyStringType", (gogoproto.castvalue) = "github.com/gogo/protobuf/test/casttype.MyUint64Type"];
map<int32,Wilson> MyNullableMap = 14 [(gogoproto.castkey) = "github.com/gogo/protobuf/test/casttype.MyInt32Type"];
map<int32,Wilson> MyEmbeddedMap = 15 [(gogoproto.castkey) = "github.com/gogo/protobuf/test/casttype.MyInt32Type", (gogoproto.nullable) = false];
}
message Wilson {
optional int64 Int64 = 1;
}

View file

@ -0,0 +1,457 @@
// Code generated by protoc-gen-gogo.
// source: combos/neither/casttype.proto
// DO NOT EDIT!
/*
Package casttype is a generated protocol buffer package.
It is generated from these files:
combos/neither/casttype.proto
It has these top-level messages:
Castaway
Wilson
*/
package casttype
import testing "testing"
import math_rand "math/rand"
import time "time"
import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
import github_com_gogo_protobuf_jsonpb "github.com/gogo/protobuf/jsonpb"
import fmt "fmt"
import go_parser "go/parser"
import proto "github.com/gogo/protobuf/proto"
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 TestCastawayProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func BenchmarkCastawayProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedCastaway(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 BenchmarkCastawayProtoUnmarshal(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(NewPopulatedCastaway(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Castaway{}
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 TestWilsonProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func BenchmarkWilsonProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedWilson(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 BenchmarkWilsonProtoUnmarshal(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(NewPopulatedWilson(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Wilson{}
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 TestCastawayJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
err = github_com_gogo_protobuf_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 TestWilsonJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
err = github_com_gogo_protobuf_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 TestCastawayProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestCastawayProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestCasttypeDescription(t *testing.T) {
CasttypeDescription()
}
func TestCastawayVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Castaway{}
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 TestWilsonVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Wilson{}
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 TestCastawayFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestWilsonFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestCastawayGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(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 TestWilsonGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(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 TestCastawaySize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkCastawaySize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedCastaway(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestWilsonSize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkWilsonSize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedWilson(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestCastawayStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
func TestWilsonStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
//These tests are generated by github.com/gogo/protobuf/plugin/testgen

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,79 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2015, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package casttype;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.goproto_enum_prefix_all) = false;
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
option (gogoproto.stringer_all) = true;
option (gogoproto.gostring_all) = true;
option (gogoproto.face_all) = true;
option (gogoproto.description_all) = true;
option (gogoproto.testgen_all) = true;
option (gogoproto.populate_all) = true;
option (gogoproto.benchgen_all) = true;
option (gogoproto.unmarshaler_all) = true;
option (gogoproto.marshaler_all) = false;
option (gogoproto.sizer_all) = true;
option (gogoproto.goproto_enum_stringer_all) = false;
option (gogoproto.enum_stringer_all) = true;
option (gogoproto.unsafe_marshaler_all) = false;
option (gogoproto.unsafe_unmarshaler_all) = false;
message Castaway {
optional int64 Int32Ptr = 1 [(gogoproto.casttype) = "int32"];
optional int64 Int32 = 2 [(gogoproto.casttype) = "int32", (gogoproto.nullable) = false];
optional uint64 MyUint64Ptr = 3 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyUint64Type"];
optional uint64 MyUint64 = 4 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyUint64Type", (gogoproto.nullable) = false];
optional float MyFloat32Ptr = 5 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat32Type"];
optional float MyFloat32 = 6 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat32Type", (gogoproto.nullable) = false];
optional double MyFloat64Ptr = 7 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat64Type"];
optional double MyFloat64 = 8 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat64Type", (gogoproto.nullable) = false];
optional bytes MyBytes = 9 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.Bytes"];
optional bytes NormalBytes = 10;
repeated uint64 MyUint64s = 11 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyUint64Type"];
map<string,uint64> MyMap = 12 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyMapType"];
map<string,uint64> MyCustomMap = 13 [(gogoproto.castkey) = "github.com/gogo/protobuf/test/casttype.MyStringType", (gogoproto.castvalue) = "github.com/gogo/protobuf/test/casttype.MyUint64Type"];
map<int32,Wilson> MyNullableMap = 14 [(gogoproto.castkey) = "github.com/gogo/protobuf/test/casttype.MyInt32Type"];
map<int32,Wilson> MyEmbeddedMap = 15 [(gogoproto.castkey) = "github.com/gogo/protobuf/test/casttype.MyInt32Type", (gogoproto.nullable) = false];
}
message Wilson {
optional int64 Int64 = 1;
}

View file

@ -0,0 +1,457 @@
// Code generated by protoc-gen-gogo.
// source: combos/unmarshaler/casttype.proto
// DO NOT EDIT!
/*
Package casttype is a generated protocol buffer package.
It is generated from these files:
combos/unmarshaler/casttype.proto
It has these top-level messages:
Castaway
Wilson
*/
package casttype
import testing "testing"
import math_rand "math/rand"
import time "time"
import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
import github_com_gogo_protobuf_jsonpb "github.com/gogo/protobuf/jsonpb"
import fmt "fmt"
import go_parser "go/parser"
import proto "github.com/gogo/protobuf/proto"
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 TestCastawayProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func BenchmarkCastawayProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedCastaway(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 BenchmarkCastawayProtoUnmarshal(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(NewPopulatedCastaway(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Castaway{}
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 TestWilsonProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func BenchmarkWilsonProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedWilson(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 BenchmarkWilsonProtoUnmarshal(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(NewPopulatedWilson(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Wilson{}
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 TestCastawayJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
err = github_com_gogo_protobuf_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 TestWilsonJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
err = github_com_gogo_protobuf_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 TestCastawayProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestCastawayProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestCasttypeDescription(t *testing.T) {
CasttypeDescription()
}
func TestCastawayVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Castaway{}
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 TestWilsonVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Wilson{}
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 TestCastawayFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestWilsonFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestCastawayGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(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 TestWilsonGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(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 TestCastawaySize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkCastawaySize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedCastaway(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestWilsonSize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkWilsonSize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedWilson(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestCastawayStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
func TestWilsonStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
//These tests are generated by github.com/gogo/protobuf/plugin/testgen

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,79 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2015, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package casttype;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.goproto_enum_prefix_all) = false;
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
option (gogoproto.stringer_all) = true;
option (gogoproto.gostring_all) = true;
option (gogoproto.face_all) = true;
option (gogoproto.description_all) = true;
option (gogoproto.testgen_all) = true;
option (gogoproto.populate_all) = true;
option (gogoproto.benchgen_all) = true;
option (gogoproto.unmarshaler_all) = false;
option (gogoproto.marshaler_all) = false;
option (gogoproto.sizer_all) = true;
option (gogoproto.goproto_enum_stringer_all) = false;
option (gogoproto.enum_stringer_all) = true;
option (gogoproto.unsafe_marshaler_all) = true;
option (gogoproto.unsafe_unmarshaler_all) = true;
message Castaway {
optional int64 Int32Ptr = 1 [(gogoproto.casttype) = "int32"];
optional int64 Int32 = 2 [(gogoproto.casttype) = "int32", (gogoproto.nullable) = false];
optional uint64 MyUint64Ptr = 3 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyUint64Type"];
optional uint64 MyUint64 = 4 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyUint64Type", (gogoproto.nullable) = false];
optional float MyFloat32Ptr = 5 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat32Type"];
optional float MyFloat32 = 6 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat32Type", (gogoproto.nullable) = false];
optional double MyFloat64Ptr = 7 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat64Type"];
optional double MyFloat64 = 8 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat64Type", (gogoproto.nullable) = false];
optional bytes MyBytes = 9 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.Bytes"];
optional bytes NormalBytes = 10;
repeated uint64 MyUint64s = 11 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyUint64Type"];
map<string,uint64> MyMap = 12 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyMapType"];
map<string,uint64> MyCustomMap = 13 [(gogoproto.castkey) = "github.com/gogo/protobuf/test/casttype.MyStringType", (gogoproto.castvalue) = "github.com/gogo/protobuf/test/casttype.MyUint64Type"];
map<int32,Wilson> MyNullableMap = 14 [(gogoproto.castkey) = "github.com/gogo/protobuf/test/casttype.MyInt32Type"];
map<int32,Wilson> MyEmbeddedMap = 15 [(gogoproto.castkey) = "github.com/gogo/protobuf/test/casttype.MyInt32Type", (gogoproto.nullable) = false];
}
message Wilson {
optional int64 Int64 = 1;
}

View file

@ -0,0 +1,513 @@
// Code generated by protoc-gen-gogo.
// source: combos/unsafeboth/casttype.proto
// DO NOT EDIT!
/*
Package casttype is a generated protocol buffer package.
It is generated from these files:
combos/unsafeboth/casttype.proto
It has these top-level messages:
Castaway
Wilson
*/
package casttype
import testing "testing"
import math_rand "math/rand"
import time "time"
import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
import github_com_gogo_protobuf_jsonpb "github.com/gogo/protobuf/jsonpb"
import fmt "fmt"
import go_parser "go/parser"
import proto "github.com/gogo/protobuf/proto"
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 TestCastawayProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func TestCastawayMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(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 {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
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)
}
}
func BenchmarkCastawayProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedCastaway(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 BenchmarkCastawayProtoUnmarshal(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(NewPopulatedCastaway(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Castaway{}
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 TestWilsonProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func TestWilsonMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(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 {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
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)
}
}
func BenchmarkWilsonProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedWilson(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 BenchmarkWilsonProtoUnmarshal(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(NewPopulatedWilson(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Wilson{}
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 TestCastawayJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
err = github_com_gogo_protobuf_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 TestWilsonJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
err = github_com_gogo_protobuf_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 TestCastawayProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestCastawayProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestCasttypeDescription(t *testing.T) {
CasttypeDescription()
}
func TestCastawayVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Castaway{}
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 TestWilsonVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Wilson{}
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 TestCastawayFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestWilsonFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestCastawayGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(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 TestWilsonGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(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 TestCastawaySize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkCastawaySize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedCastaway(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestWilsonSize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkWilsonSize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedWilson(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestCastawayStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
func TestWilsonStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
//These tests are generated by github.com/gogo/protobuf/plugin/testgen

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,79 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2015, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package casttype;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.goproto_enum_prefix_all) = false;
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
option (gogoproto.stringer_all) = true;
option (gogoproto.gostring_all) = true;
option (gogoproto.face_all) = true;
option (gogoproto.description_all) = true;
option (gogoproto.testgen_all) = true;
option (gogoproto.populate_all) = true;
option (gogoproto.benchgen_all) = true;
option (gogoproto.unmarshaler_all) = false;
option (gogoproto.marshaler_all) = false;
option (gogoproto.sizer_all) = true;
option (gogoproto.goproto_enum_stringer_all) = false;
option (gogoproto.enum_stringer_all) = true;
option (gogoproto.unsafe_marshaler_all) = true;
option (gogoproto.unsafe_unmarshaler_all) = false;
message Castaway {
optional int64 Int32Ptr = 1 [(gogoproto.casttype) = "int32"];
optional int64 Int32 = 2 [(gogoproto.casttype) = "int32", (gogoproto.nullable) = false];
optional uint64 MyUint64Ptr = 3 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyUint64Type"];
optional uint64 MyUint64 = 4 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyUint64Type", (gogoproto.nullable) = false];
optional float MyFloat32Ptr = 5 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat32Type"];
optional float MyFloat32 = 6 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat32Type", (gogoproto.nullable) = false];
optional double MyFloat64Ptr = 7 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat64Type"];
optional double MyFloat64 = 8 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat64Type", (gogoproto.nullable) = false];
optional bytes MyBytes = 9 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.Bytes"];
optional bytes NormalBytes = 10;
repeated uint64 MyUint64s = 11 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyUint64Type"];
map<string,uint64> MyMap = 12 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyMapType"];
map<string,uint64> MyCustomMap = 13 [(gogoproto.castkey) = "github.com/gogo/protobuf/test/casttype.MyStringType", (gogoproto.castvalue) = "github.com/gogo/protobuf/test/casttype.MyUint64Type"];
map<int32,Wilson> MyNullableMap = 14 [(gogoproto.castkey) = "github.com/gogo/protobuf/test/casttype.MyInt32Type"];
map<int32,Wilson> MyEmbeddedMap = 15 [(gogoproto.castkey) = "github.com/gogo/protobuf/test/casttype.MyInt32Type", (gogoproto.nullable) = false];
}
message Wilson {
optional int64 Int64 = 1;
}

View file

@ -0,0 +1,513 @@
// Code generated by protoc-gen-gogo.
// source: combos/unsafemarshaler/casttype.proto
// DO NOT EDIT!
/*
Package casttype is a generated protocol buffer package.
It is generated from these files:
combos/unsafemarshaler/casttype.proto
It has these top-level messages:
Castaway
Wilson
*/
package casttype
import testing "testing"
import math_rand "math/rand"
import time "time"
import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
import github_com_gogo_protobuf_jsonpb "github.com/gogo/protobuf/jsonpb"
import fmt "fmt"
import go_parser "go/parser"
import proto "github.com/gogo/protobuf/proto"
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 TestCastawayProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func TestCastawayMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(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 {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
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)
}
}
func BenchmarkCastawayProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedCastaway(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 BenchmarkCastawayProtoUnmarshal(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(NewPopulatedCastaway(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Castaway{}
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 TestWilsonProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func TestWilsonMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(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 {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
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)
}
}
func BenchmarkWilsonProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedWilson(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 BenchmarkWilsonProtoUnmarshal(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(NewPopulatedWilson(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Wilson{}
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 TestCastawayJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
err = github_com_gogo_protobuf_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 TestWilsonJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
err = github_com_gogo_protobuf_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 TestCastawayProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestCastawayProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestCasttypeDescription(t *testing.T) {
CasttypeDescription()
}
func TestCastawayVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Castaway{}
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 TestWilsonVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Wilson{}
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 TestCastawayFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestWilsonFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestCastawayGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(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 TestWilsonGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(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 TestCastawaySize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkCastawaySize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedCastaway(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestWilsonSize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkWilsonSize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedWilson(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestCastawayStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
func TestWilsonStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
//These tests are generated by github.com/gogo/protobuf/plugin/testgen

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,79 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2015, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package casttype;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.goproto_enum_prefix_all) = false;
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
option (gogoproto.stringer_all) = true;
option (gogoproto.gostring_all) = true;
option (gogoproto.face_all) = true;
option (gogoproto.description_all) = true;
option (gogoproto.testgen_all) = true;
option (gogoproto.populate_all) = true;
option (gogoproto.benchgen_all) = true;
option (gogoproto.unmarshaler_all) = false;
option (gogoproto.marshaler_all) = false;
option (gogoproto.sizer_all) = true;
option (gogoproto.goproto_enum_stringer_all) = false;
option (gogoproto.enum_stringer_all) = true;
option (gogoproto.unsafe_marshaler_all) = false;
option (gogoproto.unsafe_unmarshaler_all) = true;
message Castaway {
optional int64 Int32Ptr = 1 [(gogoproto.casttype) = "int32"];
optional int64 Int32 = 2 [(gogoproto.casttype) = "int32", (gogoproto.nullable) = false];
optional uint64 MyUint64Ptr = 3 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyUint64Type"];
optional uint64 MyUint64 = 4 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyUint64Type", (gogoproto.nullable) = false];
optional float MyFloat32Ptr = 5 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat32Type"];
optional float MyFloat32 = 6 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat32Type", (gogoproto.nullable) = false];
optional double MyFloat64Ptr = 7 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat64Type"];
optional double MyFloat64 = 8 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyFloat64Type", (gogoproto.nullable) = false];
optional bytes MyBytes = 9 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.Bytes"];
optional bytes NormalBytes = 10;
repeated uint64 MyUint64s = 11 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyUint64Type"];
map<string,uint64> MyMap = 12 [(gogoproto.casttype) = "github.com/gogo/protobuf/test/casttype.MyMapType"];
map<string,uint64> MyCustomMap = 13 [(gogoproto.castkey) = "github.com/gogo/protobuf/test/casttype.MyStringType", (gogoproto.castvalue) = "github.com/gogo/protobuf/test/casttype.MyUint64Type"];
map<int32,Wilson> MyNullableMap = 14 [(gogoproto.castkey) = "github.com/gogo/protobuf/test/casttype.MyInt32Type"];
map<int32,Wilson> MyEmbeddedMap = 15 [(gogoproto.castkey) = "github.com/gogo/protobuf/test/casttype.MyInt32Type", (gogoproto.nullable) = false];
}
message Wilson {
optional int64 Int64 = 1;
}

View file

@ -0,0 +1,457 @@
// Code generated by protoc-gen-gogo.
// source: combos/unsafeunmarshaler/casttype.proto
// DO NOT EDIT!
/*
Package casttype is a generated protocol buffer package.
It is generated from these files:
combos/unsafeunmarshaler/casttype.proto
It has these top-level messages:
Castaway
Wilson
*/
package casttype
import testing "testing"
import math_rand "math/rand"
import time "time"
import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
import github_com_gogo_protobuf_jsonpb "github.com/gogo/protobuf/jsonpb"
import fmt "fmt"
import go_parser "go/parser"
import proto "github.com/gogo/protobuf/proto"
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 TestCastawayProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func BenchmarkCastawayProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedCastaway(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 BenchmarkCastawayProtoUnmarshal(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(NewPopulatedCastaway(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Castaway{}
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 TestWilsonProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func BenchmarkWilsonProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedWilson(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 BenchmarkWilsonProtoUnmarshal(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(NewPopulatedWilson(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Wilson{}
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 TestCastawayJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
err = github_com_gogo_protobuf_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 TestWilsonJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
err = github_com_gogo_protobuf_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 TestCastawayProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestCastawayProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestCasttypeDescription(t *testing.T) {
CasttypeDescription()
}
func TestCastawayVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Castaway{}
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 TestWilsonVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Wilson{}
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 TestCastawayFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestWilsonFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestCastawayGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(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 TestWilsonGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(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 TestCastawaySize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkCastawaySize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedCastaway(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestWilsonSize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkWilsonSize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedWilson(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestCastawayStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
func TestWilsonStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
//These tests are generated by github.com/gogo/protobuf/plugin/testgen

View file

@ -0,0 +1,59 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package casttype
import (
"encoding/json"
)
type MyInt32Type int32
type MyFloat32Type float32
type MyUint64Type uint64
type MyFloat64Type float64
type Bytes []byte
func (this Bytes) MarshalJSON() ([]byte, error) {
return json.Marshal([]byte(this))
}
func (this *Bytes) UnmarshalJSON(data []byte) error {
v := new([]byte)
err := json.Unmarshal(data, v)
if err != nil {
return err
}
*this = *v
return nil
}
type MyStringType string
type MyMapType map[string]uint64

View file

@ -0,0 +1,39 @@
# Protocol Buffers for Go with Gadgets
#
# Copyright (c) 2013, The GoGo Authors. All rights reserved.
# http://github.com/gogo/protobuf
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
regenerate:
rm -rf combos
go install github.com/gogo/protobuf/protoc-gen-combo
protoc-min-version --version="3.0.0" --gogo_out=. --proto_path=../../../../../:../../protobuf/:. castvalue.proto
protoc-gen-combo --default=false --version="3.0.0" --proto_path=../../../../../:../../protobuf/:. castvalue.proto
cp mytypes.go ./combos/both/ || true
cp mytypes.go ./combos/marshaler/ || true
cp mytypes.go ./combos/unmarshaler/ || true
cp mytypes.go ./combos/unsafeboth/ || true
cp mytypes.go ./combos/unsafemarshaler/ || true
cp mytypes.go ./combos/unsafeunmarshaler/ || true

View file

@ -0,0 +1,866 @@
// Code generated by protoc-gen-gogo.
// source: castvalue.proto
// DO NOT EDIT!
/*
Package castvalue is a generated protocol buffer package.
It is generated from these files:
castvalue.proto
It has these top-level messages:
Castaway
Wilson
*/
package castvalue
import proto "github.com/gogo/protobuf/proto"
import fmt "fmt"
import math "math"
import _ "github.com/gogo/protobuf/gogoproto"
import github_com_gogo_protobuf_protoc_gen_gogo_descriptor "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
import compress_gzip "compress/gzip"
import bytes "bytes"
import io_ioutil "io/ioutil"
import strings "strings"
import sort "sort"
import strconv "strconv"
import reflect "reflect"
import github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type Castaway struct {
CastMapValueMessage map[int32]MyWilson `protobuf:"bytes,1,rep,name=CastMapValueMessage,json=castMapValueMessage,castvalue=MyWilson,castvaluetype=castvalue.Wilson" json:"CastMapValueMessage" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
CastMapValueMessageNullable map[int32]*MyWilson `protobuf:"bytes,2,rep,name=CastMapValueMessageNullable,json=castMapValueMessageNullable,castvalue=MyWilson,castvaluetype=castvalue.Wilson" json:"CastMapValueMessageNullable,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
XXX_unrecognized []byte `json:"-"`
}
func (m *Castaway) Reset() { *m = Castaway{} }
func (*Castaway) ProtoMessage() {}
func (*Castaway) Descriptor() ([]byte, []int) { return fileDescriptorCastvalue, []int{0} }
type Wilson struct {
Int64 *int64 `protobuf:"varint,1,opt,name=Int64,json=int64" json:"Int64,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *Wilson) Reset() { *m = Wilson{} }
func (*Wilson) ProtoMessage() {}
func (*Wilson) Descriptor() ([]byte, []int) { return fileDescriptorCastvalue, []int{1} }
func init() {
proto.RegisterType((*Castaway)(nil), "castvalue.Castaway")
proto.RegisterType((*Wilson)(nil), "castvalue.Wilson")
}
func (this *Castaway) Description() (desc *github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet) {
return CastvalueDescription()
}
func (this *Wilson) Description() (desc *github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet) {
return CastvalueDescription()
}
func CastvalueDescription() (desc *github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet) {
d := &github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet{}
var gzipped = []byte{
// 3507 bytes of a gzipped FileDescriptorSet
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xcc, 0x5a, 0x5d, 0x6c, 0x1b, 0x57,
0x76, 0xd6, 0xf0, 0x47, 0x22, 0x0f, 0x29, 0x6a, 0x74, 0xa5, 0xc8, 0xb4, 0x9c, 0xd0, 0xb2, 0x92,
0xac, 0x15, 0x67, 0x57, 0xde, 0x3a, 0xb6, 0x63, 0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 0x3a, 0xe4, 0x0f, 0x5a, 0x09, 0x52, 0x21, 0x7e, 0x93,
0xec, 0x89, 0xff, 0x0c, 0xa3, 0x3f, 0xd1, 0xc9, 0xf6, 0xbf, 0xa4, 0x28, 0x73, 0x99, 0x33, 0xe3,
0x21, 0xeb, 0xc4, 0xc3, 0xf8, 0x7c, 0x31, 0x76, 0x41, 0x99, 0xc6, 0x30, 0x13, 0x65, 0xe9, 0xff,
0xf1, 0x11, 0xb3, 0x05, 0x18, 0xe6, 0x42, 0x34, 0x09, 0xc9, 0x65, 0xdb, 0x3f, 0x7f, 0x96, 0x51,
0xc5, 0xb5, 0xa4, 0x49, 0x07, 0x0b, 0x2b, 0xef, 0xde, 0x2f, 0x0c, 0xbd, 0x77, 0xbf, 0x30, 0xf4,
0x77, 0xf7, 0x0b, 0x43, 0xef, 0xdf, 0x2f, 0x28, 0x1f, 0xde, 0x2f, 0x28, 0x1f, 0xdf, 0x2f, 0x28,
0x9f, 0xdc, 0x2f, 0x28, 0xf7, 0xf6, 0x0b, 0xca, 0xeb, 0xfb, 0x05, 0xe5, 0xcd, 0xfd, 0x82, 0xf2,
0xa7, 0xfb, 0x05, 0xe5, 0xed, 0xfd, 0x82, 0xf2, 0xee, 0x7e, 0x61, 0xe8, 0xbd, 0xfd, 0xc2, 0xd0,
0xfb, 0xfb, 0x05, 0xe5, 0xc3, 0xfd, 0xc2, 0xd0, 0xc7, 0xfb, 0x05, 0xe5, 0x93, 0xfd, 0xc2, 0xd0,
0xbd, 0x7f, 0x2a, 0x0c, 0xfd, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf8, 0x6d, 0x34, 0xdd, 0xea,
0x2c, 0x00, 0x00,
}
r := bytes.NewReader(gzipped)
gzipr, err := compress_gzip.NewReader(r)
if err != nil {
panic(err)
}
ungzipped, err := io_ioutil.ReadAll(gzipr)
if err != nil {
panic(err)
}
if err := github_com_gogo_protobuf_proto.Unmarshal(ungzipped, d); err != nil {
panic(err)
}
return d
}
func (this *Castaway) VerboseEqual(that interface{}) error {
if that == nil {
if this == nil {
return nil
}
return fmt.Errorf("that == nil && this != nil")
}
that1, ok := that.(*Castaway)
if !ok {
that2, ok := that.(Castaway)
if ok {
that1 = &that2
} else {
return fmt.Errorf("that is not of type *Castaway")
}
}
if that1 == nil {
if this == nil {
return nil
}
return fmt.Errorf("that is type *Castaway but is nil && this != nil")
} else if this == nil {
return fmt.Errorf("that is type *Castaway but is not nil && this == nil")
}
if len(this.CastMapValueMessage) != len(that1.CastMapValueMessage) {
return fmt.Errorf("CastMapValueMessage this(%v) Not Equal that(%v)", len(this.CastMapValueMessage), len(that1.CastMapValueMessage))
}
for i := range this.CastMapValueMessage {
a := (Wilson)(this.CastMapValueMessage[i])
b := (Wilson)(that1.CastMapValueMessage[i])
if !(&a).Equal(&b) {
return fmt.Errorf("CastMapValueMessage this[%v](%v) Not Equal that[%v](%v)", i, this.CastMapValueMessage[i], i, that1.CastMapValueMessage[i])
}
}
if len(this.CastMapValueMessageNullable) != len(that1.CastMapValueMessageNullable) {
return fmt.Errorf("CastMapValueMessageNullable this(%v) Not Equal that(%v)", len(this.CastMapValueMessageNullable), len(that1.CastMapValueMessageNullable))
}
for i := range this.CastMapValueMessageNullable {
a := (*Wilson)(this.CastMapValueMessageNullable[i])
b := (*Wilson)(that1.CastMapValueMessageNullable[i])
if !a.Equal(b) {
return fmt.Errorf("CastMapValueMessageNullable this[%v](%v) Not Equal that[%v](%v)", i, this.CastMapValueMessageNullable[i], i, that1.CastMapValueMessageNullable[i])
}
}
if !bytes.Equal(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
}
func (this *Castaway) Equal(that interface{}) bool {
if that == nil {
if this == nil {
return true
}
return false
}
that1, ok := that.(*Castaway)
if !ok {
that2, ok := that.(Castaway)
if ok {
that1 = &that2
} else {
return false
}
}
if that1 == nil {
if this == nil {
return true
}
return false
} else if this == nil {
return false
}
if len(this.CastMapValueMessage) != len(that1.CastMapValueMessage) {
return false
}
for i := range this.CastMapValueMessage {
a := (Wilson)(this.CastMapValueMessage[i])
b := (Wilson)(that1.CastMapValueMessage[i])
if !(&a).Equal(&b) {
return false
}
}
if len(this.CastMapValueMessageNullable) != len(that1.CastMapValueMessageNullable) {
return false
}
for i := range this.CastMapValueMessageNullable {
a := (*Wilson)(this.CastMapValueMessageNullable[i])
b := (*Wilson)(that1.CastMapValueMessageNullable[i])
if !a.Equal(b) {
return false
}
}
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
return false
}
return true
}
func (this *Wilson) VerboseEqual(that interface{}) error {
if that == nil {
if this == nil {
return nil
}
return fmt.Errorf("that == nil && this != nil")
}
that1, ok := that.(*Wilson)
if !ok {
that2, ok := that.(Wilson)
if ok {
that1 = &that2
} else {
return fmt.Errorf("that is not of type *Wilson")
}
}
if that1 == nil {
if this == nil {
return nil
}
return fmt.Errorf("that is type *Wilson but is nil && this != nil")
} else if this == nil {
return fmt.Errorf("that is type *Wilson but is not nil && this == nil")
}
if this.Int64 != nil && that1.Int64 != nil {
if *this.Int64 != *that1.Int64 {
return fmt.Errorf("Int64 this(%v) Not Equal that(%v)", *this.Int64, *that1.Int64)
}
} else if this.Int64 != nil {
return fmt.Errorf("this.Int64 == nil && that.Int64 != nil")
} else if that1.Int64 != nil {
return fmt.Errorf("Int64 this(%v) Not Equal that(%v)", this.Int64, that1.Int64)
}
if !bytes.Equal(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
}
func (this *Wilson) Equal(that interface{}) bool {
if that == nil {
if this == nil {
return true
}
return false
}
that1, ok := that.(*Wilson)
if !ok {
that2, ok := that.(Wilson)
if ok {
that1 = &that2
} else {
return false
}
}
if that1 == nil {
if this == nil {
return true
}
return false
} else if this == nil {
return false
}
if this.Int64 != nil && that1.Int64 != nil {
if *this.Int64 != *that1.Int64 {
return false
}
} else if this.Int64 != nil {
return false
} else if that1.Int64 != nil {
return false
}
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
return false
}
return true
}
type CastawayFace interface {
Proto() github_com_gogo_protobuf_proto.Message
GetCastMapValueMessage() map[int32]MyWilson
GetCastMapValueMessageNullable() map[int32]*MyWilson
}
func (this *Castaway) Proto() github_com_gogo_protobuf_proto.Message {
return this
}
func (this *Castaway) TestProto() github_com_gogo_protobuf_proto.Message {
return NewCastawayFromFace(this)
}
func (this *Castaway) GetCastMapValueMessage() map[int32]MyWilson {
return this.CastMapValueMessage
}
func (this *Castaway) GetCastMapValueMessageNullable() map[int32]*MyWilson {
return this.CastMapValueMessageNullable
}
func NewCastawayFromFace(that CastawayFace) *Castaway {
this := &Castaway{}
this.CastMapValueMessage = that.GetCastMapValueMessage()
this.CastMapValueMessageNullable = that.GetCastMapValueMessageNullable()
return this
}
type WilsonFace interface {
Proto() github_com_gogo_protobuf_proto.Message
GetInt64() *int64
}
func (this *Wilson) Proto() github_com_gogo_protobuf_proto.Message {
return this
}
func (this *Wilson) TestProto() github_com_gogo_protobuf_proto.Message {
return NewWilsonFromFace(this)
}
func (this *Wilson) GetInt64() *int64 {
return this.Int64
}
func NewWilsonFromFace(that WilsonFace) *Wilson {
this := &Wilson{}
this.Int64 = that.GetInt64()
return this
}
func (this *Castaway) GoString() string {
if this == nil {
return "nil"
}
s := make([]string, 0, 6)
s = append(s, "&castvalue.Castaway{")
keysForCastMapValueMessage := make([]int32, 0, len(this.CastMapValueMessage))
for k := range this.CastMapValueMessage {
keysForCastMapValueMessage = append(keysForCastMapValueMessage, k)
}
github_com_gogo_protobuf_sortkeys.Int32s(keysForCastMapValueMessage)
mapStringForCastMapValueMessage := "map[int32]MyWilson{"
for _, k := range keysForCastMapValueMessage {
mapStringForCastMapValueMessage += fmt.Sprintf("%#v: %#v,", k, this.CastMapValueMessage[k])
}
mapStringForCastMapValueMessage += "}"
if this.CastMapValueMessage != nil {
s = append(s, "CastMapValueMessage: "+mapStringForCastMapValueMessage+",\n")
}
keysForCastMapValueMessageNullable := make([]int32, 0, len(this.CastMapValueMessageNullable))
for k := range this.CastMapValueMessageNullable {
keysForCastMapValueMessageNullable = append(keysForCastMapValueMessageNullable, k)
}
github_com_gogo_protobuf_sortkeys.Int32s(keysForCastMapValueMessageNullable)
mapStringForCastMapValueMessageNullable := "map[int32]*MyWilson{"
for _, k := range keysForCastMapValueMessageNullable {
mapStringForCastMapValueMessageNullable += fmt.Sprintf("%#v: %#v,", k, this.CastMapValueMessageNullable[k])
}
mapStringForCastMapValueMessageNullable += "}"
if this.CastMapValueMessageNullable != nil {
s = append(s, "CastMapValueMessageNullable: "+mapStringForCastMapValueMessageNullable+",\n")
}
if this.XXX_unrecognized != nil {
s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n")
}
s = append(s, "}")
return strings.Join(s, "")
}
func (this *Wilson) GoString() string {
if this == nil {
return "nil"
}
s := make([]string, 0, 5)
s = append(s, "&castvalue.Wilson{")
if this.Int64 != nil {
s = append(s, "Int64: "+valueToGoStringCastvalue(this.Int64, "int64")+",\n")
}
if this.XXX_unrecognized != nil {
s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n")
}
s = append(s, "}")
return strings.Join(s, "")
}
func valueToGoStringCastvalue(v interface{}, typ string) string {
rv := reflect.ValueOf(v)
if rv.IsNil() {
return "nil"
}
pv := reflect.Indirect(rv).Interface()
return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv)
}
func extensionToGoStringCastvalue(m github_com_gogo_protobuf_proto.Message) string {
e := github_com_gogo_protobuf_proto.GetUnsafeExtensionsMap(m)
if e == nil {
return "nil"
}
s := "proto.NewUnsafeXXX_InternalExtensions(map[int32]proto.Extension{"
keys := make([]int, 0, len(e))
for k := range e {
keys = append(keys, int(k))
}
sort.Ints(keys)
ss := []string{}
for _, k := range keys {
ss = append(ss, strconv.Itoa(k)+": "+e[int32(k)].GoString())
}
s += strings.Join(ss, ",") + "})"
return s
}
func NewPopulatedCastaway(r randyCastvalue, easy bool) *Castaway {
this := &Castaway{}
if r.Intn(10) != 0 {
v1 := r.Intn(10)
this.CastMapValueMessage = make(map[int32]MyWilson)
for i := 0; i < v1; i++ {
this.CastMapValueMessage[int32(r.Int31())] = (MyWilson)(*NewPopulatedWilson(r, easy))
}
}
if r.Intn(10) != 0 {
v2 := r.Intn(10)
this.CastMapValueMessageNullable = make(map[int32]*MyWilson)
for i := 0; i < v2; i++ {
this.CastMapValueMessageNullable[int32(r.Int31())] = (*MyWilson)(NewPopulatedWilson(r, easy))
}
}
if !easy && r.Intn(10) != 0 {
this.XXX_unrecognized = randUnrecognizedCastvalue(r, 3)
}
return this
}
func NewPopulatedWilson(r randyCastvalue, easy bool) *Wilson {
this := &Wilson{}
if r.Intn(10) != 0 {
v3 := int64(r.Int63())
if r.Intn(2) == 0 {
v3 *= -1
}
this.Int64 = &v3
}
if !easy && r.Intn(10) != 0 {
this.XXX_unrecognized = randUnrecognizedCastvalue(r, 2)
}
return this
}
type randyCastvalue interface {
Float32() float32
Float64() float64
Int63() int64
Int31() int32
Uint32() uint32
Intn(n int) int
}
func randUTF8RuneCastvalue(r randyCastvalue) rune {
ru := r.Intn(62)
if ru < 10 {
return rune(ru + 48)
} else if ru < 36 {
return rune(ru + 55)
}
return rune(ru + 61)
}
func randStringCastvalue(r randyCastvalue) string {
v4 := r.Intn(100)
tmps := make([]rune, v4)
for i := 0; i < v4; i++ {
tmps[i] = randUTF8RuneCastvalue(r)
}
return string(tmps)
}
func randUnrecognizedCastvalue(r randyCastvalue, maxFieldNumber int) (data []byte) {
l := r.Intn(5)
for i := 0; i < l; i++ {
wire := r.Intn(4)
if wire == 3 {
wire = 5
}
fieldNumber := maxFieldNumber + r.Intn(100)
data = randFieldCastvalue(data, r, fieldNumber, wire)
}
return data
}
func randFieldCastvalue(data []byte, r randyCastvalue, fieldNumber int, wire int) []byte {
key := uint32(fieldNumber)<<3 | uint32(wire)
switch wire {
case 0:
data = encodeVarintPopulateCastvalue(data, uint64(key))
v5 := r.Int63()
if r.Intn(2) == 0 {
v5 *= -1
}
data = encodeVarintPopulateCastvalue(data, uint64(v5))
case 1:
data = encodeVarintPopulateCastvalue(data, uint64(key))
data = append(data, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
case 2:
data = encodeVarintPopulateCastvalue(data, uint64(key))
ll := r.Intn(100)
data = encodeVarintPopulateCastvalue(data, uint64(ll))
for j := 0; j < ll; j++ {
data = append(data, byte(r.Intn(256)))
}
default:
data = encodeVarintPopulateCastvalue(data, uint64(key))
data = append(data, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
}
return data
}
func encodeVarintPopulateCastvalue(data []byte, v uint64) []byte {
for v >= 1<<7 {
data = append(data, uint8(uint64(v)&0x7f|0x80))
v >>= 7
}
data = append(data, uint8(v))
return data
}
func (m *Castaway) Size() (n int) {
var l int
_ = l
if len(m.CastMapValueMessage) > 0 {
for k, v := range m.CastMapValueMessage {
_ = k
_ = v
l = ((*Wilson)(&v)).Size()
mapEntrySize := 1 + sovCastvalue(uint64(k)) + 1 + l + sovCastvalue(uint64(l))
n += mapEntrySize + 1 + sovCastvalue(uint64(mapEntrySize))
}
}
if len(m.CastMapValueMessageNullable) > 0 {
for k, v := range m.CastMapValueMessageNullable {
_ = k
_ = v
l = 0
if v != nil {
l = ((*Wilson)(v)).Size()
l += 1 + sovCastvalue(uint64(l))
}
mapEntrySize := 1 + sovCastvalue(uint64(k)) + l
n += mapEntrySize + 1 + sovCastvalue(uint64(mapEntrySize))
}
}
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n
}
func (m *Wilson) Size() (n int) {
var l int
_ = l
if m.Int64 != nil {
n += 1 + sovCastvalue(uint64(*m.Int64))
}
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n
}
func sovCastvalue(x uint64) (n int) {
for {
n++
x >>= 7
if x == 0 {
break
}
}
return n
}
func sozCastvalue(x uint64) (n int) {
return sovCastvalue(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (this *Castaway) String() string {
if this == nil {
return "nil"
}
keysForCastMapValueMessage := make([]int32, 0, len(this.CastMapValueMessage))
for k := range this.CastMapValueMessage {
keysForCastMapValueMessage = append(keysForCastMapValueMessage, k)
}
github_com_gogo_protobuf_sortkeys.Int32s(keysForCastMapValueMessage)
mapStringForCastMapValueMessage := "map[int32]MyWilson{"
for _, k := range keysForCastMapValueMessage {
mapStringForCastMapValueMessage += fmt.Sprintf("%v: %v,", k, this.CastMapValueMessage[k])
}
mapStringForCastMapValueMessage += "}"
keysForCastMapValueMessageNullable := make([]int32, 0, len(this.CastMapValueMessageNullable))
for k := range this.CastMapValueMessageNullable {
keysForCastMapValueMessageNullable = append(keysForCastMapValueMessageNullable, k)
}
github_com_gogo_protobuf_sortkeys.Int32s(keysForCastMapValueMessageNullable)
mapStringForCastMapValueMessageNullable := "map[int32]*MyWilson{"
for _, k := range keysForCastMapValueMessageNullable {
mapStringForCastMapValueMessageNullable += fmt.Sprintf("%v: %v,", k, this.CastMapValueMessageNullable[k])
}
mapStringForCastMapValueMessageNullable += "}"
s := strings.Join([]string{`&Castaway{`,
`CastMapValueMessage:` + mapStringForCastMapValueMessage + `,`,
`CastMapValueMessageNullable:` + mapStringForCastMapValueMessageNullable + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`,
}, "")
return s
}
func (this *Wilson) String() string {
if this == nil {
return "nil"
}
s := strings.Join([]string{`&Wilson{`,
`Int64:` + valueToStringCastvalue(this.Int64) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`,
}, "")
return s
}
func valueToStringCastvalue(v interface{}) string {
rv := reflect.ValueOf(v)
if rv.IsNil() {
return "nil"
}
pv := reflect.Indirect(rv).Interface()
return fmt.Sprintf("*%v", pv)
}
func init() { proto.RegisterFile("castvalue.proto", fileDescriptorCastvalue) }
var fileDescriptorCastvalue = []byte{
// 348 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xe2, 0x4f, 0x4e, 0x2c, 0x2e,
0x29, 0x4b, 0xcc, 0x29, 0x4d, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x84, 0x0b, 0x48,
0xe9, 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0xa7, 0xe7, 0xa7, 0xe7,
0xeb, 0x83, 0x55, 0x24, 0x95, 0xa6, 0x81, 0x79, 0x60, 0x0e, 0x98, 0x05, 0xd1, 0xa9, 0x74, 0x90,
0x99, 0x8b, 0xc3, 0x39, 0xb1, 0xb8, 0x24, 0xb1, 0x3c, 0xb1, 0x52, 0xa8, 0x80, 0x4b, 0x18, 0xc4,
0xf6, 0x4d, 0x2c, 0x08, 0x03, 0x99, 0xe5, 0x9b, 0x5a, 0x5c, 0x9c, 0x98, 0x9e, 0x2a, 0xc1, 0xa8,
0xc0, 0xac, 0xc1, 0x6d, 0xa4, 0xa3, 0x87, 0xb0, 0x15, 0xa6, 0x43, 0x0f, 0x8b, 0x72, 0xd7, 0xbc,
0x92, 0xa2, 0x4a, 0x27, 0x81, 0x13, 0xf7, 0xe4, 0x19, 0xba, 0xee, 0xcb, 0x73, 0xf8, 0x56, 0x86,
0x67, 0xe6, 0x14, 0xe7, 0xe7, 0x05, 0x09, 0x27, 0x63, 0xaa, 0x15, 0x6a, 0x61, 0xe4, 0x92, 0xc6,
0x62, 0x86, 0x5f, 0x69, 0x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0x00, 0x00, 0xff, 0xff, 0xad, 0x1f, 0x01, 0x78, 0x7d, 0x02, 0x00, 0x00,
}

View file

@ -0,0 +1,66 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2015, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package castvalue;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.goproto_enum_prefix_all) = false;
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
option (gogoproto.stringer_all) = true;
option (gogoproto.gostring_all) = true;
option (gogoproto.face_all) = true;
option (gogoproto.description_all) = true;
option (gogoproto.testgen_all) = true;
option (gogoproto.populate_all) = true;
option (gogoproto.benchgen_all) = true;
option (gogoproto.unmarshaler_all) = false;
option (gogoproto.marshaler_all) = false;
option (gogoproto.sizer_all) = true;
option (gogoproto.goproto_enum_stringer_all) = false;
option (gogoproto.enum_stringer_all) = true;
option (gogoproto.unsafe_marshaler_all) = false;
option (gogoproto.unsafe_unmarshaler_all) = false;
message Castaway {
map<int32,Wilson> CastMapValueMessage = 1 [(gogoproto.castvalue) = "MyWilson", (gogoproto.nullable) = false];
map<int32,Wilson> CastMapValueMessageNullable = 2 [(gogoproto.castvalue) = "MyWilson"];
}
message Wilson {
optional int64 Int64 = 1;
}

View file

@ -0,0 +1,457 @@
// Code generated by protoc-gen-gogo.
// source: castvalue.proto
// DO NOT EDIT!
/*
Package castvalue is a generated protocol buffer package.
It is generated from these files:
castvalue.proto
It has these top-level messages:
Castaway
Wilson
*/
package castvalue
import testing "testing"
import math_rand "math/rand"
import time "time"
import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
import github_com_gogo_protobuf_jsonpb "github.com/gogo/protobuf/jsonpb"
import fmt "fmt"
import go_parser "go/parser"
import proto "github.com/gogo/protobuf/proto"
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 TestCastawayProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func BenchmarkCastawayProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedCastaway(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 BenchmarkCastawayProtoUnmarshal(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(NewPopulatedCastaway(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Castaway{}
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 TestWilsonProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func BenchmarkWilsonProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedWilson(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 BenchmarkWilsonProtoUnmarshal(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(NewPopulatedWilson(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Wilson{}
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 TestCastawayJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
err = github_com_gogo_protobuf_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 TestWilsonJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
err = github_com_gogo_protobuf_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 TestCastawayProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestCastawayProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestCastvalueDescription(t *testing.T) {
CastvalueDescription()
}
func TestCastawayVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Castaway{}
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 TestWilsonVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Wilson{}
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 TestCastawayFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestWilsonFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestCastawayGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(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 TestWilsonGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(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 TestCastawaySize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkCastawaySize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedCastaway(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestWilsonSize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkWilsonSize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedWilson(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestCastawayStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
func TestWilsonStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
//These tests are generated by github.com/gogo/protobuf/plugin/testgen

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,66 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2015, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package castvalue;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.goproto_enum_prefix_all) = false;
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
option (gogoproto.stringer_all) = true;
option (gogoproto.gostring_all) = true;
option (gogoproto.face_all) = true;
option (gogoproto.description_all) = true;
option (gogoproto.testgen_all) = true;
option (gogoproto.populate_all) = true;
option (gogoproto.benchgen_all) = true;
option (gogoproto.unmarshaler_all) = true;
option (gogoproto.marshaler_all) = true;
option (gogoproto.sizer_all) = true;
option (gogoproto.goproto_enum_stringer_all) = false;
option (gogoproto.enum_stringer_all) = true;
option (gogoproto.unsafe_marshaler_all) = false;
option (gogoproto.unsafe_unmarshaler_all) = false;
message Castaway {
map<int32,Wilson> CastMapValueMessage = 1 [(gogoproto.castvalue) = "MyWilson", (gogoproto.nullable) = false];
map<int32,Wilson> CastMapValueMessageNullable = 2 [(gogoproto.castvalue) = "MyWilson"];
}
message Wilson {
optional int64 Int64 = 1;
}

View file

@ -0,0 +1,513 @@
// Code generated by protoc-gen-gogo.
// source: combos/both/castvalue.proto
// DO NOT EDIT!
/*
Package castvalue is a generated protocol buffer package.
It is generated from these files:
combos/both/castvalue.proto
It has these top-level messages:
Castaway
Wilson
*/
package castvalue
import testing "testing"
import math_rand "math/rand"
import time "time"
import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
import github_com_gogo_protobuf_jsonpb "github.com/gogo/protobuf/jsonpb"
import fmt "fmt"
import go_parser "go/parser"
import proto "github.com/gogo/protobuf/proto"
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 TestCastawayProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func TestCastawayMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(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 {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
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)
}
}
func BenchmarkCastawayProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedCastaway(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 BenchmarkCastawayProtoUnmarshal(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(NewPopulatedCastaway(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Castaway{}
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 TestWilsonProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func TestWilsonMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(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 {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
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)
}
}
func BenchmarkWilsonProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedWilson(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 BenchmarkWilsonProtoUnmarshal(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(NewPopulatedWilson(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Wilson{}
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 TestCastawayJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
err = github_com_gogo_protobuf_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 TestWilsonJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
err = github_com_gogo_protobuf_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 TestCastawayProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestCastawayProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestCastvalueDescription(t *testing.T) {
CastvalueDescription()
}
func TestCastawayVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Castaway{}
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 TestWilsonVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Wilson{}
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 TestCastawayFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestWilsonFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestCastawayGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(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 TestWilsonGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(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 TestCastawaySize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkCastawaySize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedCastaway(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestWilsonSize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkWilsonSize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedWilson(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestCastawayStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
func TestWilsonStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
//These tests are generated by github.com/gogo/protobuf/plugin/testgen

View file

@ -0,0 +1,31 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package castvalue
type MyWilson Wilson

View file

@ -0,0 +1,993 @@
// Code generated by protoc-gen-gogo.
// source: combos/marshaler/castvalue.proto
// DO NOT EDIT!
/*
Package castvalue is a generated protocol buffer package.
It is generated from these files:
combos/marshaler/castvalue.proto
It has these top-level messages:
Castaway
Wilson
*/
package castvalue
import proto "github.com/gogo/protobuf/proto"
import fmt "fmt"
import math "math"
import _ "github.com/gogo/protobuf/gogoproto"
import github_com_gogo_protobuf_protoc_gen_gogo_descriptor "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
import compress_gzip "compress/gzip"
import bytes "bytes"
import io_ioutil "io/ioutil"
import strings "strings"
import sort "sort"
import strconv "strconv"
import reflect "reflect"
import github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type Castaway struct {
CastMapValueMessage map[int32]MyWilson `protobuf:"bytes,1,rep,name=CastMapValueMessage,json=castMapValueMessage,castvalue=MyWilson,castvaluetype=castvalue.Wilson" json:"CastMapValueMessage" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
CastMapValueMessageNullable map[int32]*MyWilson `protobuf:"bytes,2,rep,name=CastMapValueMessageNullable,json=castMapValueMessageNullable,castvalue=MyWilson,castvaluetype=castvalue.Wilson" json:"CastMapValueMessageNullable,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
XXX_unrecognized []byte `json:"-"`
}
func (m *Castaway) Reset() { *m = Castaway{} }
func (*Castaway) ProtoMessage() {}
func (*Castaway) Descriptor() ([]byte, []int) { return fileDescriptorCastvalue, []int{0} }
type Wilson struct {
Int64 *int64 `protobuf:"varint,1,opt,name=Int64,json=int64" json:"Int64,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *Wilson) Reset() { *m = Wilson{} }
func (*Wilson) ProtoMessage() {}
func (*Wilson) Descriptor() ([]byte, []int) { return fileDescriptorCastvalue, []int{1} }
func init() {
proto.RegisterType((*Castaway)(nil), "castvalue.Castaway")
proto.RegisterType((*Wilson)(nil), "castvalue.Wilson")
}
func (this *Castaway) Description() (desc *github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet) {
return CastvalueDescription()
}
func (this *Wilson) Description() (desc *github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet) {
return CastvalueDescription()
}
func CastvalueDescription() (desc *github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet) {
d := &github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet{}
var gzipped = []byte{
// 3516 bytes of a gzipped FileDescriptorSet
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xcc, 0x5a, 0x5d, 0x6c, 0x1b, 0x57,
0x76, 0xd6, 0xf0, 0x47, 0x22, 0x0f, 0x29, 0x6a, 0x74, 0xa5, 0xc8, 0xb4, 0x9c, 0xd0, 0xb2, 0x92,
0xac, 0x15, 0x67, 0x57, 0xda, 0x3a, 0xb6, 0x63, 0xd3, 0xdd, 0x35, 0x28, 0x8a, 0xd6, 0xca, 0xd0,
0x5f, 0x47, 0xd2, 0xc6, 0xde, 0x3e, 0x0c, 0xae, 0x86, 0x97, 0xd4, 0xd8, 0xc3, 0x19, 0x76, 0x66,
0x68, 0x5b, 0x7e, 0x72, 0x91, 0x6d, 0x8b, 0x6d, 0xd1, 0xed, 0x2f, 0xd0, 0xdd, 0x6c, 0x76, 0xdb,
0x5d, 0xa0, 0x4d, 0x9a, 0xfe, 0x25, 0xfd, 0x43, 0xd1, 0xa7, 0x14, 0x45, 0xda, 0x3c, 0x15, 0x69,
0x9f, 0xfa, 0x50, 0xb4, 0xb1, 0x1a, 0xa0, 0x69, 0x9b, 0xb6, 0x29, 0x60, 0xa0, 0x01, 0xf2, 0x52,
0xdc, 0xbf, 0xe1, 0xf0, 0x47, 0x1e, 0x2a, 0x45, 0x9a, 0x7d, 0x12, 0xef, 0xb9, 0xe7, 0xfb, 0xe6,
0xdc, 0x73, 0xcf, 0x3d, 0xe7, 0xcc, 0x1d, 0xc1, 0x5f, 0xfe, 0x08, 0xcc, 0xd4, 0x1d, 0xa7, 0x6e,
0x91, 0x85, 0xa6, 0xeb, 0xf8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x83,
0x82, 0xf2, 0xf6, 0x41, 0x41, 0x79, 0xe7, 0xa0, 0x30, 0xf4, 0xee, 0x41, 0x41, 0x79, 0xff, 0xa0,
0x30, 0xf4, 0xe1, 0x41, 0x41, 0xf9, 0xe8, 0xa0, 0x30, 0x74, 0xff, 0x9f, 0x0b, 0x43, 0xff, 0x1b,
0x00, 0x00, 0xff, 0xff, 0xda, 0x83, 0xc0, 0xc0, 0xfb, 0x2c, 0x00, 0x00,
}
r := bytes.NewReader(gzipped)
gzipr, err := compress_gzip.NewReader(r)
if err != nil {
panic(err)
}
ungzipped, err := io_ioutil.ReadAll(gzipr)
if err != nil {
panic(err)
}
if err := github_com_gogo_protobuf_proto.Unmarshal(ungzipped, d); err != nil {
panic(err)
}
return d
}
func (this *Castaway) VerboseEqual(that interface{}) error {
if that == nil {
if this == nil {
return nil
}
return fmt.Errorf("that == nil && this != nil")
}
that1, ok := that.(*Castaway)
if !ok {
that2, ok := that.(Castaway)
if ok {
that1 = &that2
} else {
return fmt.Errorf("that is not of type *Castaway")
}
}
if that1 == nil {
if this == nil {
return nil
}
return fmt.Errorf("that is type *Castaway but is nil && this != nil")
} else if this == nil {
return fmt.Errorf("that is type *Castaway but is not nil && this == nil")
}
if len(this.CastMapValueMessage) != len(that1.CastMapValueMessage) {
return fmt.Errorf("CastMapValueMessage this(%v) Not Equal that(%v)", len(this.CastMapValueMessage), len(that1.CastMapValueMessage))
}
for i := range this.CastMapValueMessage {
a := (Wilson)(this.CastMapValueMessage[i])
b := (Wilson)(that1.CastMapValueMessage[i])
if !(&a).Equal(&b) {
return fmt.Errorf("CastMapValueMessage this[%v](%v) Not Equal that[%v](%v)", i, this.CastMapValueMessage[i], i, that1.CastMapValueMessage[i])
}
}
if len(this.CastMapValueMessageNullable) != len(that1.CastMapValueMessageNullable) {
return fmt.Errorf("CastMapValueMessageNullable this(%v) Not Equal that(%v)", len(this.CastMapValueMessageNullable), len(that1.CastMapValueMessageNullable))
}
for i := range this.CastMapValueMessageNullable {
a := (*Wilson)(this.CastMapValueMessageNullable[i])
b := (*Wilson)(that1.CastMapValueMessageNullable[i])
if !a.Equal(b) {
return fmt.Errorf("CastMapValueMessageNullable this[%v](%v) Not Equal that[%v](%v)", i, this.CastMapValueMessageNullable[i], i, that1.CastMapValueMessageNullable[i])
}
}
if !bytes.Equal(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
}
func (this *Castaway) Equal(that interface{}) bool {
if that == nil {
if this == nil {
return true
}
return false
}
that1, ok := that.(*Castaway)
if !ok {
that2, ok := that.(Castaway)
if ok {
that1 = &that2
} else {
return false
}
}
if that1 == nil {
if this == nil {
return true
}
return false
} else if this == nil {
return false
}
if len(this.CastMapValueMessage) != len(that1.CastMapValueMessage) {
return false
}
for i := range this.CastMapValueMessage {
a := (Wilson)(this.CastMapValueMessage[i])
b := (Wilson)(that1.CastMapValueMessage[i])
if !(&a).Equal(&b) {
return false
}
}
if len(this.CastMapValueMessageNullable) != len(that1.CastMapValueMessageNullable) {
return false
}
for i := range this.CastMapValueMessageNullable {
a := (*Wilson)(this.CastMapValueMessageNullable[i])
b := (*Wilson)(that1.CastMapValueMessageNullable[i])
if !a.Equal(b) {
return false
}
}
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
return false
}
return true
}
func (this *Wilson) VerboseEqual(that interface{}) error {
if that == nil {
if this == nil {
return nil
}
return fmt.Errorf("that == nil && this != nil")
}
that1, ok := that.(*Wilson)
if !ok {
that2, ok := that.(Wilson)
if ok {
that1 = &that2
} else {
return fmt.Errorf("that is not of type *Wilson")
}
}
if that1 == nil {
if this == nil {
return nil
}
return fmt.Errorf("that is type *Wilson but is nil && this != nil")
} else if this == nil {
return fmt.Errorf("that is type *Wilson but is not nil && this == nil")
}
if this.Int64 != nil && that1.Int64 != nil {
if *this.Int64 != *that1.Int64 {
return fmt.Errorf("Int64 this(%v) Not Equal that(%v)", *this.Int64, *that1.Int64)
}
} else if this.Int64 != nil {
return fmt.Errorf("this.Int64 == nil && that.Int64 != nil")
} else if that1.Int64 != nil {
return fmt.Errorf("Int64 this(%v) Not Equal that(%v)", this.Int64, that1.Int64)
}
if !bytes.Equal(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
}
func (this *Wilson) Equal(that interface{}) bool {
if that == nil {
if this == nil {
return true
}
return false
}
that1, ok := that.(*Wilson)
if !ok {
that2, ok := that.(Wilson)
if ok {
that1 = &that2
} else {
return false
}
}
if that1 == nil {
if this == nil {
return true
}
return false
} else if this == nil {
return false
}
if this.Int64 != nil && that1.Int64 != nil {
if *this.Int64 != *that1.Int64 {
return false
}
} else if this.Int64 != nil {
return false
} else if that1.Int64 != nil {
return false
}
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
return false
}
return true
}
type CastawayFace interface {
Proto() github_com_gogo_protobuf_proto.Message
GetCastMapValueMessage() map[int32]MyWilson
GetCastMapValueMessageNullable() map[int32]*MyWilson
}
func (this *Castaway) Proto() github_com_gogo_protobuf_proto.Message {
return this
}
func (this *Castaway) TestProto() github_com_gogo_protobuf_proto.Message {
return NewCastawayFromFace(this)
}
func (this *Castaway) GetCastMapValueMessage() map[int32]MyWilson {
return this.CastMapValueMessage
}
func (this *Castaway) GetCastMapValueMessageNullable() map[int32]*MyWilson {
return this.CastMapValueMessageNullable
}
func NewCastawayFromFace(that CastawayFace) *Castaway {
this := &Castaway{}
this.CastMapValueMessage = that.GetCastMapValueMessage()
this.CastMapValueMessageNullable = that.GetCastMapValueMessageNullable()
return this
}
type WilsonFace interface {
Proto() github_com_gogo_protobuf_proto.Message
GetInt64() *int64
}
func (this *Wilson) Proto() github_com_gogo_protobuf_proto.Message {
return this
}
func (this *Wilson) TestProto() github_com_gogo_protobuf_proto.Message {
return NewWilsonFromFace(this)
}
func (this *Wilson) GetInt64() *int64 {
return this.Int64
}
func NewWilsonFromFace(that WilsonFace) *Wilson {
this := &Wilson{}
this.Int64 = that.GetInt64()
return this
}
func (this *Castaway) GoString() string {
if this == nil {
return "nil"
}
s := make([]string, 0, 6)
s = append(s, "&castvalue.Castaway{")
keysForCastMapValueMessage := make([]int32, 0, len(this.CastMapValueMessage))
for k := range this.CastMapValueMessage {
keysForCastMapValueMessage = append(keysForCastMapValueMessage, k)
}
github_com_gogo_protobuf_sortkeys.Int32s(keysForCastMapValueMessage)
mapStringForCastMapValueMessage := "map[int32]MyWilson{"
for _, k := range keysForCastMapValueMessage {
mapStringForCastMapValueMessage += fmt.Sprintf("%#v: %#v,", k, this.CastMapValueMessage[k])
}
mapStringForCastMapValueMessage += "}"
if this.CastMapValueMessage != nil {
s = append(s, "CastMapValueMessage: "+mapStringForCastMapValueMessage+",\n")
}
keysForCastMapValueMessageNullable := make([]int32, 0, len(this.CastMapValueMessageNullable))
for k := range this.CastMapValueMessageNullable {
keysForCastMapValueMessageNullable = append(keysForCastMapValueMessageNullable, k)
}
github_com_gogo_protobuf_sortkeys.Int32s(keysForCastMapValueMessageNullable)
mapStringForCastMapValueMessageNullable := "map[int32]*MyWilson{"
for _, k := range keysForCastMapValueMessageNullable {
mapStringForCastMapValueMessageNullable += fmt.Sprintf("%#v: %#v,", k, this.CastMapValueMessageNullable[k])
}
mapStringForCastMapValueMessageNullable += "}"
if this.CastMapValueMessageNullable != nil {
s = append(s, "CastMapValueMessageNullable: "+mapStringForCastMapValueMessageNullable+",\n")
}
if this.XXX_unrecognized != nil {
s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n")
}
s = append(s, "}")
return strings.Join(s, "")
}
func (this *Wilson) GoString() string {
if this == nil {
return "nil"
}
s := make([]string, 0, 5)
s = append(s, "&castvalue.Wilson{")
if this.Int64 != nil {
s = append(s, "Int64: "+valueToGoStringCastvalue(this.Int64, "int64")+",\n")
}
if this.XXX_unrecognized != nil {
s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n")
}
s = append(s, "}")
return strings.Join(s, "")
}
func valueToGoStringCastvalue(v interface{}, typ string) string {
rv := reflect.ValueOf(v)
if rv.IsNil() {
return "nil"
}
pv := reflect.Indirect(rv).Interface()
return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv)
}
func extensionToGoStringCastvalue(m github_com_gogo_protobuf_proto.Message) string {
e := github_com_gogo_protobuf_proto.GetUnsafeExtensionsMap(m)
if e == nil {
return "nil"
}
s := "proto.NewUnsafeXXX_InternalExtensions(map[int32]proto.Extension{"
keys := make([]int, 0, len(e))
for k := range e {
keys = append(keys, int(k))
}
sort.Ints(keys)
ss := []string{}
for _, k := range keys {
ss = append(ss, strconv.Itoa(k)+": "+e[int32(k)].GoString())
}
s += strings.Join(ss, ",") + "})"
return s
}
func (m *Castaway) Marshal() (data []byte, err error) {
size := m.Size()
data = make([]byte, size)
n, err := m.MarshalTo(data)
if err != nil {
return nil, err
}
return data[:n], nil
}
func (m *Castaway) MarshalTo(data []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if len(m.CastMapValueMessage) > 0 {
for k := range m.CastMapValueMessage {
data[i] = 0xa
i++
v := m.CastMapValueMessage[k]
msgSize := 0
if ((*Wilson)(&v)) != nil {
msgSize = ((*Wilson)(&v)).Size()
msgSize += 1 + sovCastvalue(uint64(msgSize))
}
mapSize := 1 + sovCastvalue(uint64(k)) + msgSize
i = encodeVarintCastvalue(data, i, uint64(mapSize))
data[i] = 0x8
i++
i = encodeVarintCastvalue(data, i, uint64(k))
data[i] = 0x12
i++
i = encodeVarintCastvalue(data, i, uint64(((*Wilson)(&v)).Size()))
n1, err := ((*Wilson)(&v)).MarshalTo(data[i:])
if err != nil {
return 0, err
}
i += n1
}
}
if len(m.CastMapValueMessageNullable) > 0 {
for k := range m.CastMapValueMessageNullable {
data[i] = 0x12
i++
v := m.CastMapValueMessageNullable[k]
msgSize := 0
if ((*Wilson)(v)) != nil {
msgSize = ((*Wilson)(v)).Size()
msgSize += 1 + sovCastvalue(uint64(msgSize))
}
mapSize := 1 + sovCastvalue(uint64(k)) + msgSize
i = encodeVarintCastvalue(data, i, uint64(mapSize))
data[i] = 0x8
i++
i = encodeVarintCastvalue(data, i, uint64(k))
if ((*Wilson)(v)) != nil {
data[i] = 0x12
i++
i = encodeVarintCastvalue(data, i, uint64(((*Wilson)(v)).Size()))
n2, err := ((*Wilson)(v)).MarshalTo(data[i:])
if err != nil {
return 0, err
}
i += n2
}
}
}
if m.XXX_unrecognized != nil {
i += copy(data[i:], m.XXX_unrecognized)
}
return i, nil
}
func (m *Wilson) Marshal() (data []byte, err error) {
size := m.Size()
data = make([]byte, size)
n, err := m.MarshalTo(data)
if err != nil {
return nil, err
}
return data[:n], nil
}
func (m *Wilson) MarshalTo(data []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Int64 != nil {
data[i] = 0x8
i++
i = encodeVarintCastvalue(data, i, uint64(*m.Int64))
}
if m.XXX_unrecognized != nil {
i += copy(data[i:], m.XXX_unrecognized)
}
return i, nil
}
func encodeFixed64Castvalue(data []byte, offset int, v uint64) int {
data[offset] = uint8(v)
data[offset+1] = uint8(v >> 8)
data[offset+2] = uint8(v >> 16)
data[offset+3] = uint8(v >> 24)
data[offset+4] = uint8(v >> 32)
data[offset+5] = uint8(v >> 40)
data[offset+6] = uint8(v >> 48)
data[offset+7] = uint8(v >> 56)
return offset + 8
}
func encodeFixed32Castvalue(data []byte, offset int, v uint32) int {
data[offset] = uint8(v)
data[offset+1] = uint8(v >> 8)
data[offset+2] = uint8(v >> 16)
data[offset+3] = uint8(v >> 24)
return offset + 4
}
func encodeVarintCastvalue(data []byte, offset int, v uint64) int {
for v >= 1<<7 {
data[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
data[offset] = uint8(v)
return offset + 1
}
func NewPopulatedCastaway(r randyCastvalue, easy bool) *Castaway {
this := &Castaway{}
if r.Intn(10) != 0 {
v1 := r.Intn(10)
this.CastMapValueMessage = make(map[int32]MyWilson)
for i := 0; i < v1; i++ {
this.CastMapValueMessage[int32(r.Int31())] = (MyWilson)(*NewPopulatedWilson(r, easy))
}
}
if r.Intn(10) != 0 {
v2 := r.Intn(10)
this.CastMapValueMessageNullable = make(map[int32]*MyWilson)
for i := 0; i < v2; i++ {
this.CastMapValueMessageNullable[int32(r.Int31())] = (*MyWilson)(NewPopulatedWilson(r, easy))
}
}
if !easy && r.Intn(10) != 0 {
this.XXX_unrecognized = randUnrecognizedCastvalue(r, 3)
}
return this
}
func NewPopulatedWilson(r randyCastvalue, easy bool) *Wilson {
this := &Wilson{}
if r.Intn(10) != 0 {
v3 := int64(r.Int63())
if r.Intn(2) == 0 {
v3 *= -1
}
this.Int64 = &v3
}
if !easy && r.Intn(10) != 0 {
this.XXX_unrecognized = randUnrecognizedCastvalue(r, 2)
}
return this
}
type randyCastvalue interface {
Float32() float32
Float64() float64
Int63() int64
Int31() int32
Uint32() uint32
Intn(n int) int
}
func randUTF8RuneCastvalue(r randyCastvalue) rune {
ru := r.Intn(62)
if ru < 10 {
return rune(ru + 48)
} else if ru < 36 {
return rune(ru + 55)
}
return rune(ru + 61)
}
func randStringCastvalue(r randyCastvalue) string {
v4 := r.Intn(100)
tmps := make([]rune, v4)
for i := 0; i < v4; i++ {
tmps[i] = randUTF8RuneCastvalue(r)
}
return string(tmps)
}
func randUnrecognizedCastvalue(r randyCastvalue, maxFieldNumber int) (data []byte) {
l := r.Intn(5)
for i := 0; i < l; i++ {
wire := r.Intn(4)
if wire == 3 {
wire = 5
}
fieldNumber := maxFieldNumber + r.Intn(100)
data = randFieldCastvalue(data, r, fieldNumber, wire)
}
return data
}
func randFieldCastvalue(data []byte, r randyCastvalue, fieldNumber int, wire int) []byte {
key := uint32(fieldNumber)<<3 | uint32(wire)
switch wire {
case 0:
data = encodeVarintPopulateCastvalue(data, uint64(key))
v5 := r.Int63()
if r.Intn(2) == 0 {
v5 *= -1
}
data = encodeVarintPopulateCastvalue(data, uint64(v5))
case 1:
data = encodeVarintPopulateCastvalue(data, uint64(key))
data = append(data, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
case 2:
data = encodeVarintPopulateCastvalue(data, uint64(key))
ll := r.Intn(100)
data = encodeVarintPopulateCastvalue(data, uint64(ll))
for j := 0; j < ll; j++ {
data = append(data, byte(r.Intn(256)))
}
default:
data = encodeVarintPopulateCastvalue(data, uint64(key))
data = append(data, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
}
return data
}
func encodeVarintPopulateCastvalue(data []byte, v uint64) []byte {
for v >= 1<<7 {
data = append(data, uint8(uint64(v)&0x7f|0x80))
v >>= 7
}
data = append(data, uint8(v))
return data
}
func (m *Castaway) Size() (n int) {
var l int
_ = l
if len(m.CastMapValueMessage) > 0 {
for k, v := range m.CastMapValueMessage {
_ = k
_ = v
l = ((*Wilson)(&v)).Size()
mapEntrySize := 1 + sovCastvalue(uint64(k)) + 1 + l + sovCastvalue(uint64(l))
n += mapEntrySize + 1 + sovCastvalue(uint64(mapEntrySize))
}
}
if len(m.CastMapValueMessageNullable) > 0 {
for k, v := range m.CastMapValueMessageNullable {
_ = k
_ = v
l = 0
if v != nil {
l = ((*Wilson)(v)).Size()
l += 1 + sovCastvalue(uint64(l))
}
mapEntrySize := 1 + sovCastvalue(uint64(k)) + l
n += mapEntrySize + 1 + sovCastvalue(uint64(mapEntrySize))
}
}
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n
}
func (m *Wilson) Size() (n int) {
var l int
_ = l
if m.Int64 != nil {
n += 1 + sovCastvalue(uint64(*m.Int64))
}
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n
}
func sovCastvalue(x uint64) (n int) {
for {
n++
x >>= 7
if x == 0 {
break
}
}
return n
}
func sozCastvalue(x uint64) (n int) {
return sovCastvalue(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (this *Castaway) String() string {
if this == nil {
return "nil"
}
keysForCastMapValueMessage := make([]int32, 0, len(this.CastMapValueMessage))
for k := range this.CastMapValueMessage {
keysForCastMapValueMessage = append(keysForCastMapValueMessage, k)
}
github_com_gogo_protobuf_sortkeys.Int32s(keysForCastMapValueMessage)
mapStringForCastMapValueMessage := "map[int32]MyWilson{"
for _, k := range keysForCastMapValueMessage {
mapStringForCastMapValueMessage += fmt.Sprintf("%v: %v,", k, this.CastMapValueMessage[k])
}
mapStringForCastMapValueMessage += "}"
keysForCastMapValueMessageNullable := make([]int32, 0, len(this.CastMapValueMessageNullable))
for k := range this.CastMapValueMessageNullable {
keysForCastMapValueMessageNullable = append(keysForCastMapValueMessageNullable, k)
}
github_com_gogo_protobuf_sortkeys.Int32s(keysForCastMapValueMessageNullable)
mapStringForCastMapValueMessageNullable := "map[int32]*MyWilson{"
for _, k := range keysForCastMapValueMessageNullable {
mapStringForCastMapValueMessageNullable += fmt.Sprintf("%v: %v,", k, this.CastMapValueMessageNullable[k])
}
mapStringForCastMapValueMessageNullable += "}"
s := strings.Join([]string{`&Castaway{`,
`CastMapValueMessage:` + mapStringForCastMapValueMessage + `,`,
`CastMapValueMessageNullable:` + mapStringForCastMapValueMessageNullable + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`,
}, "")
return s
}
func (this *Wilson) String() string {
if this == nil {
return "nil"
}
s := strings.Join([]string{`&Wilson{`,
`Int64:` + valueToStringCastvalue(this.Int64) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`,
}, "")
return s
}
func valueToStringCastvalue(v interface{}) string {
rv := reflect.ValueOf(v)
if rv.IsNil() {
return "nil"
}
pv := reflect.Indirect(rv).Interface()
return fmt.Sprintf("*%v", pv)
}
func init() { proto.RegisterFile("combos/marshaler/castvalue.proto", fileDescriptorCastvalue) }
var fileDescriptorCastvalue = []byte{
// 365 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xa4, 0x8f, 0xbd, 0x4f, 0xea, 0x50,
0x18, 0xc6, 0xcf, 0x4b, 0xd3, 0x1b, 0xee, 0xe1, 0x0e, 0xdc, 0x72, 0x87, 0x06, 0x92, 0x97, 0x86,
0xe5, 0x32, 0xdc, 0xdb, 0x26, 0x84, 0x18, 0xe3, 0x88, 0x71, 0x30, 0x11, 0x07, 0x06, 0x8d, 0xe3,
0x69, 0x53, 0x0b, 0xb1, 0x70, 0x48, 0x3f, 0x34, 0xdd, 0x18, 0x9c, 0xfc, 0x4b, 0x1c, 0x1d, 0x1d,
0x75, 0x63, 0x64, 0x74, 0x52, 0x7a, 0x5c, 0x18, 0x19, 0x19, 0x4d, 0x5b, 0xf1, 0x23, 0x42, 0x34,
0x71, 0x7b, 0xdf, 0xf7, 0x3c, 0xcf, 0xf3, 0x7b, 0x0e, 0xd5, 0x2c, 0xde, 0x37, 0xb9, 0x6f, 0xf4,
0x99, 0xe7, 0x77, 0x99, 0x6b, 0x7b, 0x86, 0xc5, 0xfc, 0xe0, 0x94, 0xb9, 0xa1, 0xad, 0x0f, 0x3d,
0x1e, 0x70, 0xe5, 0xe7, 0xcb, 0xa1, 0xfc, 0xdf, 0xe9, 0x05, 0xdd, 0xd0, 0xd4, 0x2d, 0xde, 0x37,
0x1c, 0xee, 0x70, 0x23, 0x55, 0x98, 0xe1, 0x71, 0xba, 0xa5, 0x4b, 0x3a, 0x65, 0xce, 0xda, 0xad,
0x44, 0xf3, 0xdb, 0xcc, 0x0f, 0xd8, 0x19, 0x8b, 0x94, 0x21, 0x2d, 0x25, 0x73, 0x9b, 0x0d, 0x0f,
0x92, 0xac, 0xb6, 0xed, 0xfb, 0xcc, 0xb1, 0x55,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7,
0x00, 0x00, 0x00, 0xff, 0xff, 0x15, 0xb6, 0x94, 0x56, 0x8e, 0x02, 0x00, 0x00,
}

View file

@ -0,0 +1,66 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2015, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package castvalue;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.goproto_enum_prefix_all) = false;
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
option (gogoproto.stringer_all) = true;
option (gogoproto.gostring_all) = true;
option (gogoproto.face_all) = true;
option (gogoproto.description_all) = true;
option (gogoproto.testgen_all) = true;
option (gogoproto.populate_all) = true;
option (gogoproto.benchgen_all) = true;
option (gogoproto.unmarshaler_all) = false;
option (gogoproto.marshaler_all) = true;
option (gogoproto.sizer_all) = true;
option (gogoproto.goproto_enum_stringer_all) = false;
option (gogoproto.enum_stringer_all) = true;
option (gogoproto.unsafe_marshaler_all) = false;
option (gogoproto.unsafe_unmarshaler_all) = false;
message Castaway {
map<int32,Wilson> CastMapValueMessage = 1 [(gogoproto.castvalue) = "MyWilson", (gogoproto.nullable) = false];
map<int32,Wilson> CastMapValueMessageNullable = 2 [(gogoproto.castvalue) = "MyWilson"];
}
message Wilson {
optional int64 Int64 = 1;
}

View file

@ -0,0 +1,513 @@
// Code generated by protoc-gen-gogo.
// source: combos/marshaler/castvalue.proto
// DO NOT EDIT!
/*
Package castvalue is a generated protocol buffer package.
It is generated from these files:
combos/marshaler/castvalue.proto
It has these top-level messages:
Castaway
Wilson
*/
package castvalue
import testing "testing"
import math_rand "math/rand"
import time "time"
import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
import github_com_gogo_protobuf_jsonpb "github.com/gogo/protobuf/jsonpb"
import fmt "fmt"
import go_parser "go/parser"
import proto "github.com/gogo/protobuf/proto"
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 TestCastawayProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func TestCastawayMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(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 {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
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)
}
}
func BenchmarkCastawayProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedCastaway(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 BenchmarkCastawayProtoUnmarshal(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(NewPopulatedCastaway(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Castaway{}
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 TestWilsonProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func TestWilsonMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(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 {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
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)
}
}
func BenchmarkWilsonProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedWilson(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 BenchmarkWilsonProtoUnmarshal(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(NewPopulatedWilson(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Wilson{}
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 TestCastawayJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
err = github_com_gogo_protobuf_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 TestWilsonJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
err = github_com_gogo_protobuf_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 TestCastawayProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestCastawayProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestCastvalueDescription(t *testing.T) {
CastvalueDescription()
}
func TestCastawayVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Castaway{}
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 TestWilsonVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Wilson{}
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 TestCastawayFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestWilsonFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestCastawayGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(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 TestWilsonGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(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 TestCastawaySize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkCastawaySize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedCastaway(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestWilsonSize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkWilsonSize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedWilson(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestCastawayStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
func TestWilsonStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
//These tests are generated by github.com/gogo/protobuf/plugin/testgen

View file

@ -0,0 +1,31 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package castvalue
type MyWilson Wilson

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,66 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2015, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package castvalue;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.goproto_enum_prefix_all) = false;
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
option (gogoproto.stringer_all) = true;
option (gogoproto.gostring_all) = true;
option (gogoproto.face_all) = true;
option (gogoproto.description_all) = true;
option (gogoproto.testgen_all) = true;
option (gogoproto.populate_all) = true;
option (gogoproto.benchgen_all) = true;
option (gogoproto.unmarshaler_all) = true;
option (gogoproto.marshaler_all) = false;
option (gogoproto.sizer_all) = true;
option (gogoproto.goproto_enum_stringer_all) = false;
option (gogoproto.enum_stringer_all) = true;
option (gogoproto.unsafe_marshaler_all) = false;
option (gogoproto.unsafe_unmarshaler_all) = false;
message Castaway {
map<int32,Wilson> CastMapValueMessage = 1 [(gogoproto.castvalue) = "MyWilson", (gogoproto.nullable) = false];
map<int32,Wilson> CastMapValueMessageNullable = 2 [(gogoproto.castvalue) = "MyWilson"];
}
message Wilson {
optional int64 Int64 = 1;
}

View file

@ -0,0 +1,457 @@
// Code generated by protoc-gen-gogo.
// source: combos/unmarshaler/castvalue.proto
// DO NOT EDIT!
/*
Package castvalue is a generated protocol buffer package.
It is generated from these files:
combos/unmarshaler/castvalue.proto
It has these top-level messages:
Castaway
Wilson
*/
package castvalue
import testing "testing"
import math_rand "math/rand"
import time "time"
import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
import github_com_gogo_protobuf_jsonpb "github.com/gogo/protobuf/jsonpb"
import fmt "fmt"
import go_parser "go/parser"
import proto "github.com/gogo/protobuf/proto"
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 TestCastawayProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func BenchmarkCastawayProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedCastaway(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 BenchmarkCastawayProtoUnmarshal(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(NewPopulatedCastaway(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Castaway{}
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 TestWilsonProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func BenchmarkWilsonProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedWilson(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 BenchmarkWilsonProtoUnmarshal(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(NewPopulatedWilson(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Wilson{}
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 TestCastawayJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
err = github_com_gogo_protobuf_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 TestWilsonJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
err = github_com_gogo_protobuf_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 TestCastawayProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestCastawayProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestCastvalueDescription(t *testing.T) {
CastvalueDescription()
}
func TestCastawayVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Castaway{}
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 TestWilsonVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Wilson{}
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 TestCastawayFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestWilsonFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestCastawayGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(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 TestWilsonGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(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 TestCastawaySize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkCastawaySize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedCastaway(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestWilsonSize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkWilsonSize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedWilson(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestCastawayStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
func TestWilsonStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
//These tests are generated by github.com/gogo/protobuf/plugin/testgen

View file

@ -0,0 +1,31 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package castvalue
type MyWilson Wilson

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,66 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2015, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package castvalue;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.goproto_enum_prefix_all) = false;
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
option (gogoproto.stringer_all) = true;
option (gogoproto.gostring_all) = true;
option (gogoproto.face_all) = true;
option (gogoproto.description_all) = true;
option (gogoproto.testgen_all) = true;
option (gogoproto.populate_all) = true;
option (gogoproto.benchgen_all) = true;
option (gogoproto.unmarshaler_all) = false;
option (gogoproto.marshaler_all) = false;
option (gogoproto.sizer_all) = true;
option (gogoproto.goproto_enum_stringer_all) = false;
option (gogoproto.enum_stringer_all) = true;
option (gogoproto.unsafe_marshaler_all) = true;
option (gogoproto.unsafe_unmarshaler_all) = true;
message Castaway {
map<int32,Wilson> CastMapValueMessage = 1 [(gogoproto.castvalue) = "MyWilson", (gogoproto.nullable) = false];
map<int32,Wilson> CastMapValueMessageNullable = 2 [(gogoproto.castvalue) = "MyWilson"];
}
message Wilson {
optional int64 Int64 = 1;
}

View file

@ -0,0 +1,513 @@
// Code generated by protoc-gen-gogo.
// source: combos/unsafeboth/castvalue.proto
// DO NOT EDIT!
/*
Package castvalue is a generated protocol buffer package.
It is generated from these files:
combos/unsafeboth/castvalue.proto
It has these top-level messages:
Castaway
Wilson
*/
package castvalue
import testing "testing"
import math_rand "math/rand"
import time "time"
import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
import github_com_gogo_protobuf_jsonpb "github.com/gogo/protobuf/jsonpb"
import fmt "fmt"
import go_parser "go/parser"
import proto "github.com/gogo/protobuf/proto"
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 TestCastawayProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func TestCastawayMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(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 {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
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)
}
}
func BenchmarkCastawayProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedCastaway(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 BenchmarkCastawayProtoUnmarshal(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(NewPopulatedCastaway(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Castaway{}
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 TestWilsonProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func TestWilsonMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(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 {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
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)
}
}
func BenchmarkWilsonProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedWilson(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 BenchmarkWilsonProtoUnmarshal(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(NewPopulatedWilson(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Wilson{}
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 TestCastawayJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
err = github_com_gogo_protobuf_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 TestWilsonJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
err = github_com_gogo_protobuf_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 TestCastawayProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestCastawayProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestCastvalueDescription(t *testing.T) {
CastvalueDescription()
}
func TestCastawayVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Castaway{}
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 TestWilsonVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Wilson{}
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 TestCastawayFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestWilsonFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestCastawayGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(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 TestWilsonGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(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 TestCastawaySize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkCastawaySize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedCastaway(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestWilsonSize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkWilsonSize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedWilson(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestCastawayStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
func TestWilsonStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
//These tests are generated by github.com/gogo/protobuf/plugin/testgen

View file

@ -0,0 +1,31 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package castvalue
type MyWilson Wilson

View file

@ -0,0 +1,994 @@
// Code generated by protoc-gen-gogo.
// source: combos/unsafemarshaler/castvalue.proto
// DO NOT EDIT!
/*
Package castvalue is a generated protocol buffer package.
It is generated from these files:
combos/unsafemarshaler/castvalue.proto
It has these top-level messages:
Castaway
Wilson
*/
package castvalue
import proto "github.com/gogo/protobuf/proto"
import fmt "fmt"
import math "math"
import _ "github.com/gogo/protobuf/gogoproto"
import github_com_gogo_protobuf_protoc_gen_gogo_descriptor "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
import compress_gzip "compress/gzip"
import bytes "bytes"
import io_ioutil "io/ioutil"
import strings "strings"
import sort "sort"
import strconv "strconv"
import reflect "reflect"
import github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type Castaway struct {
CastMapValueMessage map[int32]MyWilson `protobuf:"bytes,1,rep,name=CastMapValueMessage,json=castMapValueMessage,castvalue=MyWilson,castvaluetype=castvalue.Wilson" json:"CastMapValueMessage" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
CastMapValueMessageNullable map[int32]*MyWilson `protobuf:"bytes,2,rep,name=CastMapValueMessageNullable,json=castMapValueMessageNullable,castvalue=MyWilson,castvaluetype=castvalue.Wilson" json:"CastMapValueMessageNullable,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
XXX_unrecognized []byte `json:"-"`
}
func (m *Castaway) Reset() { *m = Castaway{} }
func (*Castaway) ProtoMessage() {}
func (*Castaway) Descriptor() ([]byte, []int) { return fileDescriptorCastvalue, []int{0} }
type Wilson struct {
Int64 *int64 `protobuf:"varint,1,opt,name=Int64,json=int64" json:"Int64,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *Wilson) Reset() { *m = Wilson{} }
func (*Wilson) ProtoMessage() {}
func (*Wilson) Descriptor() ([]byte, []int) { return fileDescriptorCastvalue, []int{1} }
func init() {
proto.RegisterType((*Castaway)(nil), "castvalue.Castaway")
proto.RegisterType((*Wilson)(nil), "castvalue.Wilson")
}
func (this *Castaway) Description() (desc *github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet) {
return CastvalueDescription()
}
func (this *Wilson) Description() (desc *github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet) {
return CastvalueDescription()
}
func CastvalueDescription() (desc *github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet) {
d := &github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet{}
var gzipped = []byte{
// 3518 bytes of a gzipped FileDescriptorSet
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xcc, 0x5a, 0x5d, 0x6c, 0x1b, 0x57,
0x76, 0xd6, 0xf0, 0x47, 0x22, 0x0f, 0x29, 0x6a, 0x74, 0xa5, 0xc8, 0xb4, 0x9c, 0xd0, 0xb2, 0xf2,
0x63, 0xc5, 0xd9, 0x95, 0xb6, 0x8e, 0xed, 0xd8, 0x74, 0x77, 0x0d, 0x8a, 0xa2, 0xb5, 0x32, 0xf4,
0xd7, 0x91, 0xb4, 0xb1, 0xb7, 0x0f, 0x83, 0xab, 0xe1, 0x25, 0x35, 0xf6, 0x70, 0x86, 0x9d, 0x19,
0xda, 0x96, 0x9f, 0x5c, 0x64, 0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0x55, 0x94, 0xb9, 0xcc, 0xd9, 0xf1, 0x90, 0x75, 0xe2, 0x61,
0x7c, 0xbe, 0x18, 0xbb, 0xa8, 0x4c, 0x63, 0x98, 0x89, 0xb2, 0xf4, 0xff, 0xf8, 0x88, 0xd9, 0x02,
0x0c, 0x73, 0x21, 0x9a, 0x84, 0xe4, 0x8a, 0xed, 0x5f, 0x38, 0xc7, 0xa8, 0xe2, 0x5a, 0xd2, 0xa4,
0x83, 0xc5, 0xd5, 0xb7, 0x1f, 0x14, 0x86, 0xde, 0x79, 0x50, 0x18, 0xfa, 0xfb, 0x07, 0x85, 0xa1,
0x77, 0x1f, 0x14, 0x94, 0xf7, 0x1f, 0x14, 0x94, 0x0f, 0x1f, 0x14, 0x94, 0x8f, 0x1e, 0x14, 0x94,
0xfb, 0x07, 0x05, 0xe5, 0x07, 0x07, 0x05, 0xe5, 0xf5, 0x83, 0x82, 0xf2, 0x67, 0x07, 0x05, 0xe5,
0xcd, 0x83, 0x82, 0xf2, 0xf6, 0x41, 0x61, 0xe8, 0x9d, 0x83, 0xc2, 0xd0, 0xbb, 0x07, 0x05, 0xe5,
0xfd, 0x83, 0xc2, 0xd0, 0x87, 0x07, 0x05, 0xe5, 0xa3, 0x83, 0x82, 0x72, 0xff, 0x9f, 0x0b, 0x43,
0xff, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x76, 0x38, 0x95, 0x63, 0x01, 0x2d, 0x00, 0x00,
}
r := bytes.NewReader(gzipped)
gzipr, err := compress_gzip.NewReader(r)
if err != nil {
panic(err)
}
ungzipped, err := io_ioutil.ReadAll(gzipr)
if err != nil {
panic(err)
}
if err := github_com_gogo_protobuf_proto.Unmarshal(ungzipped, d); err != nil {
panic(err)
}
return d
}
func (this *Castaway) VerboseEqual(that interface{}) error {
if that == nil {
if this == nil {
return nil
}
return fmt.Errorf("that == nil && this != nil")
}
that1, ok := that.(*Castaway)
if !ok {
that2, ok := that.(Castaway)
if ok {
that1 = &that2
} else {
return fmt.Errorf("that is not of type *Castaway")
}
}
if that1 == nil {
if this == nil {
return nil
}
return fmt.Errorf("that is type *Castaway but is nil && this != nil")
} else if this == nil {
return fmt.Errorf("that is type *Castaway but is not nil && this == nil")
}
if len(this.CastMapValueMessage) != len(that1.CastMapValueMessage) {
return fmt.Errorf("CastMapValueMessage this(%v) Not Equal that(%v)", len(this.CastMapValueMessage), len(that1.CastMapValueMessage))
}
for i := range this.CastMapValueMessage {
a := (Wilson)(this.CastMapValueMessage[i])
b := (Wilson)(that1.CastMapValueMessage[i])
if !(&a).Equal(&b) {
return fmt.Errorf("CastMapValueMessage this[%v](%v) Not Equal that[%v](%v)", i, this.CastMapValueMessage[i], i, that1.CastMapValueMessage[i])
}
}
if len(this.CastMapValueMessageNullable) != len(that1.CastMapValueMessageNullable) {
return fmt.Errorf("CastMapValueMessageNullable this(%v) Not Equal that(%v)", len(this.CastMapValueMessageNullable), len(that1.CastMapValueMessageNullable))
}
for i := range this.CastMapValueMessageNullable {
a := (*Wilson)(this.CastMapValueMessageNullable[i])
b := (*Wilson)(that1.CastMapValueMessageNullable[i])
if !a.Equal(b) {
return fmt.Errorf("CastMapValueMessageNullable this[%v](%v) Not Equal that[%v](%v)", i, this.CastMapValueMessageNullable[i], i, that1.CastMapValueMessageNullable[i])
}
}
if !bytes.Equal(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
}
func (this *Castaway) Equal(that interface{}) bool {
if that == nil {
if this == nil {
return true
}
return false
}
that1, ok := that.(*Castaway)
if !ok {
that2, ok := that.(Castaway)
if ok {
that1 = &that2
} else {
return false
}
}
if that1 == nil {
if this == nil {
return true
}
return false
} else if this == nil {
return false
}
if len(this.CastMapValueMessage) != len(that1.CastMapValueMessage) {
return false
}
for i := range this.CastMapValueMessage {
a := (Wilson)(this.CastMapValueMessage[i])
b := (Wilson)(that1.CastMapValueMessage[i])
if !(&a).Equal(&b) {
return false
}
}
if len(this.CastMapValueMessageNullable) != len(that1.CastMapValueMessageNullable) {
return false
}
for i := range this.CastMapValueMessageNullable {
a := (*Wilson)(this.CastMapValueMessageNullable[i])
b := (*Wilson)(that1.CastMapValueMessageNullable[i])
if !a.Equal(b) {
return false
}
}
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
return false
}
return true
}
func (this *Wilson) VerboseEqual(that interface{}) error {
if that == nil {
if this == nil {
return nil
}
return fmt.Errorf("that == nil && this != nil")
}
that1, ok := that.(*Wilson)
if !ok {
that2, ok := that.(Wilson)
if ok {
that1 = &that2
} else {
return fmt.Errorf("that is not of type *Wilson")
}
}
if that1 == nil {
if this == nil {
return nil
}
return fmt.Errorf("that is type *Wilson but is nil && this != nil")
} else if this == nil {
return fmt.Errorf("that is type *Wilson but is not nil && this == nil")
}
if this.Int64 != nil && that1.Int64 != nil {
if *this.Int64 != *that1.Int64 {
return fmt.Errorf("Int64 this(%v) Not Equal that(%v)", *this.Int64, *that1.Int64)
}
} else if this.Int64 != nil {
return fmt.Errorf("this.Int64 == nil && that.Int64 != nil")
} else if that1.Int64 != nil {
return fmt.Errorf("Int64 this(%v) Not Equal that(%v)", this.Int64, that1.Int64)
}
if !bytes.Equal(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
}
func (this *Wilson) Equal(that interface{}) bool {
if that == nil {
if this == nil {
return true
}
return false
}
that1, ok := that.(*Wilson)
if !ok {
that2, ok := that.(Wilson)
if ok {
that1 = &that2
} else {
return false
}
}
if that1 == nil {
if this == nil {
return true
}
return false
} else if this == nil {
return false
}
if this.Int64 != nil && that1.Int64 != nil {
if *this.Int64 != *that1.Int64 {
return false
}
} else if this.Int64 != nil {
return false
} else if that1.Int64 != nil {
return false
}
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
return false
}
return true
}
type CastawayFace interface {
Proto() github_com_gogo_protobuf_proto.Message
GetCastMapValueMessage() map[int32]MyWilson
GetCastMapValueMessageNullable() map[int32]*MyWilson
}
func (this *Castaway) Proto() github_com_gogo_protobuf_proto.Message {
return this
}
func (this *Castaway) TestProto() github_com_gogo_protobuf_proto.Message {
return NewCastawayFromFace(this)
}
func (this *Castaway) GetCastMapValueMessage() map[int32]MyWilson {
return this.CastMapValueMessage
}
func (this *Castaway) GetCastMapValueMessageNullable() map[int32]*MyWilson {
return this.CastMapValueMessageNullable
}
func NewCastawayFromFace(that CastawayFace) *Castaway {
this := &Castaway{}
this.CastMapValueMessage = that.GetCastMapValueMessage()
this.CastMapValueMessageNullable = that.GetCastMapValueMessageNullable()
return this
}
type WilsonFace interface {
Proto() github_com_gogo_protobuf_proto.Message
GetInt64() *int64
}
func (this *Wilson) Proto() github_com_gogo_protobuf_proto.Message {
return this
}
func (this *Wilson) TestProto() github_com_gogo_protobuf_proto.Message {
return NewWilsonFromFace(this)
}
func (this *Wilson) GetInt64() *int64 {
return this.Int64
}
func NewWilsonFromFace(that WilsonFace) *Wilson {
this := &Wilson{}
this.Int64 = that.GetInt64()
return this
}
func (this *Castaway) GoString() string {
if this == nil {
return "nil"
}
s := make([]string, 0, 6)
s = append(s, "&castvalue.Castaway{")
keysForCastMapValueMessage := make([]int32, 0, len(this.CastMapValueMessage))
for k := range this.CastMapValueMessage {
keysForCastMapValueMessage = append(keysForCastMapValueMessage, k)
}
github_com_gogo_protobuf_sortkeys.Int32s(keysForCastMapValueMessage)
mapStringForCastMapValueMessage := "map[int32]MyWilson{"
for _, k := range keysForCastMapValueMessage {
mapStringForCastMapValueMessage += fmt.Sprintf("%#v: %#v,", k, this.CastMapValueMessage[k])
}
mapStringForCastMapValueMessage += "}"
if this.CastMapValueMessage != nil {
s = append(s, "CastMapValueMessage: "+mapStringForCastMapValueMessage+",\n")
}
keysForCastMapValueMessageNullable := make([]int32, 0, len(this.CastMapValueMessageNullable))
for k := range this.CastMapValueMessageNullable {
keysForCastMapValueMessageNullable = append(keysForCastMapValueMessageNullable, k)
}
github_com_gogo_protobuf_sortkeys.Int32s(keysForCastMapValueMessageNullable)
mapStringForCastMapValueMessageNullable := "map[int32]*MyWilson{"
for _, k := range keysForCastMapValueMessageNullable {
mapStringForCastMapValueMessageNullable += fmt.Sprintf("%#v: %#v,", k, this.CastMapValueMessageNullable[k])
}
mapStringForCastMapValueMessageNullable += "}"
if this.CastMapValueMessageNullable != nil {
s = append(s, "CastMapValueMessageNullable: "+mapStringForCastMapValueMessageNullable+",\n")
}
if this.XXX_unrecognized != nil {
s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n")
}
s = append(s, "}")
return strings.Join(s, "")
}
func (this *Wilson) GoString() string {
if this == nil {
return "nil"
}
s := make([]string, 0, 5)
s = append(s, "&castvalue.Wilson{")
if this.Int64 != nil {
s = append(s, "Int64: "+valueToGoStringCastvalue(this.Int64, "int64")+",\n")
}
if this.XXX_unrecognized != nil {
s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n")
}
s = append(s, "}")
return strings.Join(s, "")
}
func valueToGoStringCastvalue(v interface{}, typ string) string {
rv := reflect.ValueOf(v)
if rv.IsNil() {
return "nil"
}
pv := reflect.Indirect(rv).Interface()
return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv)
}
func extensionToGoStringCastvalue(m github_com_gogo_protobuf_proto.Message) string {
e := github_com_gogo_protobuf_proto.GetUnsafeExtensionsMap(m)
if e == nil {
return "nil"
}
s := "proto.NewUnsafeXXX_InternalExtensions(map[int32]proto.Extension{"
keys := make([]int, 0, len(e))
for k := range e {
keys = append(keys, int(k))
}
sort.Ints(keys)
ss := []string{}
for _, k := range keys {
ss = append(ss, strconv.Itoa(k)+": "+e[int32(k)].GoString())
}
s += strings.Join(ss, ",") + "})"
return s
}
func NewPopulatedCastaway(r randyCastvalue, easy bool) *Castaway {
this := &Castaway{}
if r.Intn(10) != 0 {
v1 := r.Intn(10)
this.CastMapValueMessage = make(map[int32]MyWilson)
for i := 0; i < v1; i++ {
this.CastMapValueMessage[int32(r.Int31())] = (MyWilson)(*NewPopulatedWilson(r, easy))
}
}
if r.Intn(10) != 0 {
v2 := r.Intn(10)
this.CastMapValueMessageNullable = make(map[int32]*MyWilson)
for i := 0; i < v2; i++ {
this.CastMapValueMessageNullable[int32(r.Int31())] = (*MyWilson)(NewPopulatedWilson(r, easy))
}
}
if !easy && r.Intn(10) != 0 {
this.XXX_unrecognized = randUnrecognizedCastvalue(r, 3)
}
return this
}
func NewPopulatedWilson(r randyCastvalue, easy bool) *Wilson {
this := &Wilson{}
if r.Intn(10) != 0 {
v3 := int64(r.Int63())
if r.Intn(2) == 0 {
v3 *= -1
}
this.Int64 = &v3
}
if !easy && r.Intn(10) != 0 {
this.XXX_unrecognized = randUnrecognizedCastvalue(r, 2)
}
return this
}
type randyCastvalue interface {
Float32() float32
Float64() float64
Int63() int64
Int31() int32
Uint32() uint32
Intn(n int) int
}
func randUTF8RuneCastvalue(r randyCastvalue) rune {
ru := r.Intn(62)
if ru < 10 {
return rune(ru + 48)
} else if ru < 36 {
return rune(ru + 55)
}
return rune(ru + 61)
}
func randStringCastvalue(r randyCastvalue) string {
v4 := r.Intn(100)
tmps := make([]rune, v4)
for i := 0; i < v4; i++ {
tmps[i] = randUTF8RuneCastvalue(r)
}
return string(tmps)
}
func randUnrecognizedCastvalue(r randyCastvalue, maxFieldNumber int) (data []byte) {
l := r.Intn(5)
for i := 0; i < l; i++ {
wire := r.Intn(4)
if wire == 3 {
wire = 5
}
fieldNumber := maxFieldNumber + r.Intn(100)
data = randFieldCastvalue(data, r, fieldNumber, wire)
}
return data
}
func randFieldCastvalue(data []byte, r randyCastvalue, fieldNumber int, wire int) []byte {
key := uint32(fieldNumber)<<3 | uint32(wire)
switch wire {
case 0:
data = encodeVarintPopulateCastvalue(data, uint64(key))
v5 := r.Int63()
if r.Intn(2) == 0 {
v5 *= -1
}
data = encodeVarintPopulateCastvalue(data, uint64(v5))
case 1:
data = encodeVarintPopulateCastvalue(data, uint64(key))
data = append(data, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
case 2:
data = encodeVarintPopulateCastvalue(data, uint64(key))
ll := r.Intn(100)
data = encodeVarintPopulateCastvalue(data, uint64(ll))
for j := 0; j < ll; j++ {
data = append(data, byte(r.Intn(256)))
}
default:
data = encodeVarintPopulateCastvalue(data, uint64(key))
data = append(data, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
}
return data
}
func encodeVarintPopulateCastvalue(data []byte, v uint64) []byte {
for v >= 1<<7 {
data = append(data, uint8(uint64(v)&0x7f|0x80))
v >>= 7
}
data = append(data, uint8(v))
return data
}
func (m *Castaway) Size() (n int) {
var l int
_ = l
if len(m.CastMapValueMessage) > 0 {
for k, v := range m.CastMapValueMessage {
_ = k
_ = v
l = ((*Wilson)(&v)).Size()
mapEntrySize := 1 + sovCastvalue(uint64(k)) + 1 + l + sovCastvalue(uint64(l))
n += mapEntrySize + 1 + sovCastvalue(uint64(mapEntrySize))
}
}
if len(m.CastMapValueMessageNullable) > 0 {
for k, v := range m.CastMapValueMessageNullable {
_ = k
_ = v
l = 0
if v != nil {
l = ((*Wilson)(v)).Size()
l += 1 + sovCastvalue(uint64(l))
}
mapEntrySize := 1 + sovCastvalue(uint64(k)) + l
n += mapEntrySize + 1 + sovCastvalue(uint64(mapEntrySize))
}
}
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n
}
func (m *Wilson) Size() (n int) {
var l int
_ = l
if m.Int64 != nil {
n += 1 + sovCastvalue(uint64(*m.Int64))
}
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
return n
}
func sovCastvalue(x uint64) (n int) {
for {
n++
x >>= 7
if x == 0 {
break
}
}
return n
}
func sozCastvalue(x uint64) (n int) {
return sovCastvalue(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (this *Castaway) String() string {
if this == nil {
return "nil"
}
keysForCastMapValueMessage := make([]int32, 0, len(this.CastMapValueMessage))
for k := range this.CastMapValueMessage {
keysForCastMapValueMessage = append(keysForCastMapValueMessage, k)
}
github_com_gogo_protobuf_sortkeys.Int32s(keysForCastMapValueMessage)
mapStringForCastMapValueMessage := "map[int32]MyWilson{"
for _, k := range keysForCastMapValueMessage {
mapStringForCastMapValueMessage += fmt.Sprintf("%v: %v,", k, this.CastMapValueMessage[k])
}
mapStringForCastMapValueMessage += "}"
keysForCastMapValueMessageNullable := make([]int32, 0, len(this.CastMapValueMessageNullable))
for k := range this.CastMapValueMessageNullable {
keysForCastMapValueMessageNullable = append(keysForCastMapValueMessageNullable, k)
}
github_com_gogo_protobuf_sortkeys.Int32s(keysForCastMapValueMessageNullable)
mapStringForCastMapValueMessageNullable := "map[int32]*MyWilson{"
for _, k := range keysForCastMapValueMessageNullable {
mapStringForCastMapValueMessageNullable += fmt.Sprintf("%v: %v,", k, this.CastMapValueMessageNullable[k])
}
mapStringForCastMapValueMessageNullable += "}"
s := strings.Join([]string{`&Castaway{`,
`CastMapValueMessage:` + mapStringForCastMapValueMessage + `,`,
`CastMapValueMessageNullable:` + mapStringForCastMapValueMessageNullable + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`,
}, "")
return s
}
func (this *Wilson) String() string {
if this == nil {
return "nil"
}
s := strings.Join([]string{`&Wilson{`,
`Int64:` + valueToStringCastvalue(this.Int64) + `,`,
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
`}`,
}, "")
return s
}
func valueToStringCastvalue(v interface{}) string {
rv := reflect.ValueOf(v)
if rv.IsNil() {
return "nil"
}
pv := reflect.Indirect(rv).Interface()
return fmt.Sprintf("*%v", pv)
}
func (m *Castaway) Marshal() (data []byte, err error) {
size := m.Size()
data = make([]byte, size)
n, err := m.MarshalTo(data)
if err != nil {
return nil, err
}
return data[:n], nil
}
func (m *Castaway) MarshalTo(data []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if len(m.CastMapValueMessage) > 0 {
for k := range m.CastMapValueMessage {
data[i] = 0xa
i++
v := m.CastMapValueMessage[k]
msgSize := 0
if ((*Wilson)(&v)) != nil {
msgSize = ((*Wilson)(&v)).Size()
msgSize += 1 + sovCastvalue(uint64(msgSize))
}
mapSize := 1 + sovCastvalue(uint64(k)) + msgSize
i = encodeVarintCastvalue(data, i, uint64(mapSize))
data[i] = 0x8
i++
i = encodeVarintCastvalue(data, i, uint64(k))
data[i] = 0x12
i++
i = encodeVarintCastvalue(data, i, uint64(((*Wilson)(&v)).Size()))
n1, err := ((*Wilson)(&v)).MarshalTo(data[i:])
if err != nil {
return 0, err
}
i += n1
}
}
if len(m.CastMapValueMessageNullable) > 0 {
for k := range m.CastMapValueMessageNullable {
data[i] = 0x12
i++
v := m.CastMapValueMessageNullable[k]
msgSize := 0
if ((*Wilson)(v)) != nil {
msgSize = ((*Wilson)(v)).Size()
msgSize += 1 + sovCastvalue(uint64(msgSize))
}
mapSize := 1 + sovCastvalue(uint64(k)) + msgSize
i = encodeVarintCastvalue(data, i, uint64(mapSize))
data[i] = 0x8
i++
i = encodeVarintCastvalue(data, i, uint64(k))
if ((*Wilson)(v)) != nil {
data[i] = 0x12
i++
i = encodeVarintCastvalue(data, i, uint64(((*Wilson)(v)).Size()))
n2, err := ((*Wilson)(v)).MarshalTo(data[i:])
if err != nil {
return 0, err
}
i += n2
}
}
}
if m.XXX_unrecognized != nil {
i += copy(data[i:], m.XXX_unrecognized)
}
return i, nil
}
func (m *Wilson) Marshal() (data []byte, err error) {
size := m.Size()
data = make([]byte, size)
n, err := m.MarshalTo(data)
if err != nil {
return nil, err
}
return data[:n], nil
}
func (m *Wilson) MarshalTo(data []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Int64 != nil {
data[i] = 0x8
i++
i = encodeVarintCastvalue(data, i, uint64(*m.Int64))
}
if m.XXX_unrecognized != nil {
i += copy(data[i:], m.XXX_unrecognized)
}
return i, nil
}
func encodeFixed64Castvalue(data []byte, offset int, v uint64) int {
data[offset] = uint8(v)
data[offset+1] = uint8(v >> 8)
data[offset+2] = uint8(v >> 16)
data[offset+3] = uint8(v >> 24)
data[offset+4] = uint8(v >> 32)
data[offset+5] = uint8(v >> 40)
data[offset+6] = uint8(v >> 48)
data[offset+7] = uint8(v >> 56)
return offset + 8
}
func encodeFixed32Castvalue(data []byte, offset int, v uint32) int {
data[offset] = uint8(v)
data[offset+1] = uint8(v >> 8)
data[offset+2] = uint8(v >> 16)
data[offset+3] = uint8(v >> 24)
return offset + 4
}
func encodeVarintCastvalue(data []byte, offset int, v uint64) int {
for v >= 1<<7 {
data[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
data[offset] = uint8(v)
return offset + 1
}
func init() { proto.RegisterFile("combos/unsafemarshaler/castvalue.proto", fileDescriptorCastvalue) }
var fileDescriptorCastvalue = []byte{
// 371 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x52, 0x4b, 0xce, 0xcf, 0x4d,
0xca, 0x2f, 0xd6, 0x2f, 0xcd, 0x2b, 0x4e, 0x4c, 0x4b, 0xcd, 0x4d, 0x2c, 0x2a, 0xce, 0x48, 0xcc,
0x49, 0x2d, 0xd2, 0x4f, 0x4e, 0x2c, 0x2e, 0x29, 0x4b, 0xcc, 0x29, 0x4d, 0xd5, 0x2b, 0x28, 0xca,
0x2f, 0xc9, 0x17, 0xe2, 0x84, 0x0b, 0x48, 0xe9, 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25,
0xe7, 0xe7, 0xea, 0xa7, 0xe7, 0xa7, 0xe7, 0xeb, 0x83, 0x55, 0x24, 0x95,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bc, 0x12, 0x33, 0x13, 0xb0, 0x51, 0xcc, 0x41, 0xac,
0x99, 0x20, 0x8e, 0x93, 0xcf, 0x89, 0x87, 0x72, 0x0c, 0x17, 0x1e, 0xca, 0x31, 0xdc, 0x78, 0x28,
0xc7, 0xf0, 0xe0, 0xa1, 0x1c, 0xe3, 0x8b, 0x87, 0x72, 0x8c, 0x1f, 0x1e, 0xca, 0x31, 0xfe, 0x78,
0x28, 0xc7, 0xd8, 0xf0, 0x48, 0x8e, 0x71, 0xc5, 0x23, 0x39, 0xc6, 0x0d, 0x8f, 0xe4, 0x18, 0x77,
0x3c, 0x92, 0x63, 0x3c, 0xf0, 0x48, 0x8e, 0xf1, 0xc4, 0x23, 0x39, 0x86, 0x0b, 0x8f, 0xe4, 0x18,
0x1e, 0x3c, 0x92, 0x63, 0x7c, 0xf1, 0x48, 0x8e, 0xe1, 0xc3, 0x23, 0x39, 0xc6, 0x1f, 0x8f, 0xe4,
0x18, 0x1b, 0x1e, 0xcb, 0x31, 0x00, 0x02, 0x00, 0x00, 0xff, 0xff, 0x29, 0x83, 0xc1, 0xb7, 0x94,
0x02, 0x00, 0x00,
}

View file

@ -0,0 +1,66 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2015, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package castvalue;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.goproto_enum_prefix_all) = false;
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
option (gogoproto.stringer_all) = true;
option (gogoproto.gostring_all) = true;
option (gogoproto.face_all) = true;
option (gogoproto.description_all) = true;
option (gogoproto.testgen_all) = true;
option (gogoproto.populate_all) = true;
option (gogoproto.benchgen_all) = true;
option (gogoproto.unmarshaler_all) = false;
option (gogoproto.marshaler_all) = false;
option (gogoproto.sizer_all) = true;
option (gogoproto.goproto_enum_stringer_all) = false;
option (gogoproto.enum_stringer_all) = true;
option (gogoproto.unsafe_marshaler_all) = true;
option (gogoproto.unsafe_unmarshaler_all) = false;
message Castaway {
map<int32,Wilson> CastMapValueMessage = 1 [(gogoproto.castvalue) = "MyWilson", (gogoproto.nullable) = false];
map<int32,Wilson> CastMapValueMessageNullable = 2 [(gogoproto.castvalue) = "MyWilson"];
}
message Wilson {
optional int64 Int64 = 1;
}

View file

@ -0,0 +1,513 @@
// Code generated by protoc-gen-gogo.
// source: combos/unsafemarshaler/castvalue.proto
// DO NOT EDIT!
/*
Package castvalue is a generated protocol buffer package.
It is generated from these files:
combos/unsafemarshaler/castvalue.proto
It has these top-level messages:
Castaway
Wilson
*/
package castvalue
import testing "testing"
import math_rand "math/rand"
import time "time"
import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
import github_com_gogo_protobuf_jsonpb "github.com/gogo/protobuf/jsonpb"
import fmt "fmt"
import go_parser "go/parser"
import proto "github.com/gogo/protobuf/proto"
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 TestCastawayProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func TestCastawayMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(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 {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
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)
}
}
func BenchmarkCastawayProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedCastaway(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 BenchmarkCastawayProtoUnmarshal(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(NewPopulatedCastaway(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Castaway{}
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 TestWilsonProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func TestWilsonMarshalTo(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(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 {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
if err := github_com_gogo_protobuf_proto.Unmarshal(data, msg); err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
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)
}
}
func BenchmarkWilsonProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedWilson(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 BenchmarkWilsonProtoUnmarshal(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(NewPopulatedWilson(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Wilson{}
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 TestCastawayJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
err = github_com_gogo_protobuf_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 TestWilsonJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
err = github_com_gogo_protobuf_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 TestCastawayProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestCastawayProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestCastvalueDescription(t *testing.T) {
CastvalueDescription()
}
func TestCastawayVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Castaway{}
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 TestWilsonVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Wilson{}
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 TestCastawayFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestWilsonFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestCastawayGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(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 TestWilsonGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(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 TestCastawaySize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkCastawaySize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedCastaway(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestWilsonSize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkWilsonSize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedWilson(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestCastawayStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
func TestWilsonStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
//These tests are generated by github.com/gogo/protobuf/plugin/testgen

View file

@ -0,0 +1,31 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package castvalue
type MyWilson Wilson

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,66 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2015, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package castvalue;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.goproto_enum_prefix_all) = false;
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
option (gogoproto.stringer_all) = true;
option (gogoproto.gostring_all) = true;
option (gogoproto.face_all) = true;
option (gogoproto.description_all) = true;
option (gogoproto.testgen_all) = true;
option (gogoproto.populate_all) = true;
option (gogoproto.benchgen_all) = true;
option (gogoproto.unmarshaler_all) = false;
option (gogoproto.marshaler_all) = false;
option (gogoproto.sizer_all) = true;
option (gogoproto.goproto_enum_stringer_all) = false;
option (gogoproto.enum_stringer_all) = true;
option (gogoproto.unsafe_marshaler_all) = false;
option (gogoproto.unsafe_unmarshaler_all) = true;
message Castaway {
map<int32,Wilson> CastMapValueMessage = 1 [(gogoproto.castvalue) = "MyWilson", (gogoproto.nullable) = false];
map<int32,Wilson> CastMapValueMessageNullable = 2 [(gogoproto.castvalue) = "MyWilson"];
}
message Wilson {
optional int64 Int64 = 1;
}

View file

@ -0,0 +1,457 @@
// Code generated by protoc-gen-gogo.
// source: combos/unsafeunmarshaler/castvalue.proto
// DO NOT EDIT!
/*
Package castvalue is a generated protocol buffer package.
It is generated from these files:
combos/unsafeunmarshaler/castvalue.proto
It has these top-level messages:
Castaway
Wilson
*/
package castvalue
import testing "testing"
import math_rand "math/rand"
import time "time"
import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto"
import github_com_gogo_protobuf_jsonpb "github.com/gogo/protobuf/jsonpb"
import fmt "fmt"
import go_parser "go/parser"
import proto "github.com/gogo/protobuf/proto"
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 TestCastawayProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func BenchmarkCastawayProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedCastaway(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 BenchmarkCastawayProtoUnmarshal(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(NewPopulatedCastaway(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Castaway{}
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 TestWilsonProto(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
if err := github_com_gogo_protobuf_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
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
}
}
func BenchmarkWilsonProtoMarshal(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 10000)
for i := 0; i < 10000; i++ {
pops[i] = NewPopulatedWilson(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 BenchmarkWilsonProtoUnmarshal(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(NewPopulatedWilson(popr, false))
if err != nil {
panic(err)
}
datas[i] = data
}
msg := &Wilson{}
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 TestCastawayJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Castaway{}
err = github_com_gogo_protobuf_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 TestWilsonJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Wilson{}
err = github_com_gogo_protobuf_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 TestCastawayProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestCastawayProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Castaway{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.MarshalTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestWilsonProtoCompactText(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
data := github_com_gogo_protobuf_proto.CompactTextString(p)
msg := &Wilson{}
if err := github_com_gogo_protobuf_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 TestCastvalueDescription(t *testing.T) {
CastvalueDescription()
}
func TestCastawayVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Castaway{}
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 TestWilsonVerboseEqual(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
data, err := github_com_gogo_protobuf_proto.Marshal(p)
if err != nil {
panic(err)
}
msg := &Wilson{}
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 TestCastawayFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestWilsonFace(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, true)
msg := p.TestProto()
if !p.Equal(msg) {
t.Fatalf("%#v !Face Equal %#v", msg, p)
}
}
func TestCastawayGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(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 TestWilsonGoString(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(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 TestCastawaySize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedCastaway(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkCastawaySize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Castaway, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedCastaway(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestWilsonSize(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedWilson(popr, true)
size2 := github_com_gogo_protobuf_proto.Size(p)
data, err := github_com_gogo_protobuf_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 := github_com_gogo_protobuf_proto.Size(p)
if size3 != size {
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
}
}
func BenchmarkWilsonSize(b *testing.B) {
popr := math_rand.New(math_rand.NewSource(616))
total := 0
pops := make([]*Wilson, 1000)
for i := 0; i < 1000; i++ {
pops[i] = NewPopulatedWilson(popr, false)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
total += pops[i%1000].Size()
}
b.SetBytes(int64(total / b.N))
}
func TestCastawayStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedCastaway(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
func TestWilsonStringer(t *testing.T) {
popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano()))
p := NewPopulatedWilson(popr, false)
s1 := p.String()
s2 := fmt.Sprintf("%v", p)
if s1 != s2 {
t.Fatalf("String want %v got %v", s1, s2)
}
}
//These tests are generated by github.com/gogo/protobuf/plugin/testgen

View file

@ -0,0 +1,31 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package castvalue
type MyWilson Wilson

View file

@ -0,0 +1,31 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package castvalue
type MyWilson Wilson

View file

@ -0,0 +1,252 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package test
import (
"fmt"
"math"
"math/rand"
"testing"
"time"
"github.com/gogo/protobuf/proto"
)
//http://code.google.com/p/goprotobuf/issues/detail?id=39
func TestBugUint32VarintSize(t *testing.T) {
temp := uint32(math.MaxUint32)
n := &NinOptNative{}
n.Field5 = &temp
data, err := proto.Marshal(n)
if err != nil {
panic(err)
}
if len(data) != 6 {
t.Fatalf("data should be length 6, but its %#v", data)
}
}
func TestBugZeroLengthSliceSize(t *testing.T) {
n := &NinRepPackedNative{
Field8: []int64{},
}
size := n.Size()
data, err := proto.Marshal(n)
if err != nil {
panic(err)
}
if len(data) != size {
t.Fatalf("expected %v, but got %v", len(data), size)
}
}
//http://code.google.com/p/goprotobuf/issues/detail?id=40
func TestBugPackedProtoSize(t *testing.T) {
n := &NinRepPackedNative{
Field4: []int64{172960727389894724, 2360337516664475010, 860833876131988189, 9068073014890763245, 7794843386260381831, 4023536436053141786, 8992311247496919020, 4330096163611305776, 4490411416244976467, 7873947349172707443, 2754969595834279669, 1360667855926938684, 4771480785172657389, 4875578924966668055, 8070579869808877481, 9128179594766551001, 4630419407064527516, 863844540220372892, 8208727650143073487, 7086117356301045838, 7779695211931506151, 5493835345187563535, 9119767633370806007, 9054342025895349248, 1887303228838508438, 7624573031734528281, 1874668389749611225, 3517684643468970593, 6677697606628877758, 7293473953189936168, 444475066704085538, 8594971141363049302, 1146643249094989673, 733393306232853371, 7721178528893916886, 7784452000911004429, 6436373110242711440, 6897422461738321237, 8772249155667732778, 6211871464311393541, 3061903718310406883, 7845488913176136641, 8342255034663902574, 3443058984649725748, 8410801047334832902, 7496541071517841153, 4305416923521577765, 7814967600020476457, 8671843803465481186, 3490266370361096855, 1447425664719091336, 653218597262334239, 8306243902880091940, 7851896059762409081, 5936760560798954978, 5755724498441478025, 7022701569985035966, 3707709584811468220, 529069456924666920, 7986469043681522462, 3092513330689518836, 5103541550470476202, 3577384161242626406, 3733428084624703294, 8388690542440473117, 3262468785346149388, 8788358556558007570, 5476276940198542020, 7277903243119461239, 5065861426928605020, 7533460976202697734, 1749213838654236956, 557497603941617931, 5496307611456481108, 6444547750062831720, 6992758776744205596, 7356719693428537399, 2896328872476734507, 381447079530132038, 598300737753233118, 3687980626612697715, 7240924191084283349, 8172414415307971170, 4847024388701257185, 2081764168600256551, 3394217778539123488, 6244660626429310923, 8301712215675381614, 5360615125359461174, 8410140945829785773, 3152963269026381373, 6197275282781459633, 4419829061407546410, 6262035523070047537, 2837207483933463885, 2158105736666826128, 8150764172235490711},
Field7: []int32{249451845, 1409974015, 393609128, 435232428, 1817529040, 91769006, 861170933, 1556185603, 1568580279, 1236375273, 512276621, 693633711, 967580535, 1950715977, 853431462, 1362390253, 159591204, 111900629, 322985263, 279671129, 1592548430, 465651370, 733849989, 1172059400, 1574824441, 263541092, 1271612397, 1520584358, 467078791, 117698716, 1098255064, 2054264846, 1766452305, 1267576395, 1557505617, 1187833560, 956187431, 1970977586, 1160235159, 1610259028, 489585797, 459139078, 566263183, 954319278, 1545018565, 1753946743, 948214318, 422878159, 883926576, 1424009347, 824732372, 1290433180, 80297942, 417294230, 1402647904, 2078392782, 220505045, 787368129, 463781454, 293083578, 808156928, 293976361},
Field9: []uint32{0xaa4976e8, 0x3da8cc4c, 0x8c470d83, 0x344d964e, 0x5b90925, 0xa4c4d34e, 0x666eff19, 0xc238e552, 0x9be53bb6, 0x56364245, 0x33ee079d, 0x96bf0ede, 0x7941b74f, 0xdb07cb47, 0x6d76d827, 0x9b211d5d, 0x2798adb6, 0xe48b0c3b, 0x87061b21, 0x48f4e4d2, 0x3e5d5c12, 0x5ee91288, 0x336d4f35, 0xe1d44941, 0xc065548d, 0x2953d73f, 0x873af451, 0xfc769db, 0x9f1bf8da, 0x9baafdfc, 0xf1d3d770, 0x5bb5d2b4, 0xc2c67c48, 0x6845c4c1, 0xa48f32b0, 0xbb04bb70, 0xa5b1ca36, 0x8d98356a, 0x2171f654, 0x5ae279b0, 0x6c4a3d6b, 0x4fff5468, 0xcf9bf851, 0x68513614, 0xdbecd9b0, 0x9553ed3c, 0xa494a736, 0x42205438, 0xbf8e5caa, 0xd3283c6, 0x76d20788, 0x9179826f, 0x96b24f85, 0xbc2eacf4, 0xe4afae0b, 0x4bca85cb, 0x35e63b5b, 0xd7ccee0c, 0x2b506bb9, 0xe78e9f44, 0x9ad232f1, 0x99a37335, 0xa5d6ffc8},
Field11: []uint64{0x53c01ebc, 0x4fb85ba6, 0x8805eea1, 0xb20ec896, 0x93b63410, 0xec7c9492, 0x50765a28, 0x19592106, 0x2ecc59b3, 0x39cd474f, 0xe4c9e47, 0x444f48c5, 0xe7731d32, 0xf3f43975, 0x603caedd, 0xbb05a1af, 0xa808e34e, 0x88580b07, 0x4c96bbd1, 0x730b4ab9, 0xed126e2b, 0x6db48205, 0x154ba1b9, 0xc26bfb6a, 0x389aa052, 0x869d966c, 0x7c86b366, 0xcc8edbcd, 0xfa8d6dad, 0xcf5857d9, 0x2d9cda0f, 0x1218a0b8, 0x41bf997, 0xf0ca65ac, 0xa610d4b9, 0x8d362e28, 0xb7212d87, 0x8e0fe109, 0xbee041d9, 0x759be2f6, 0x35fef4f3, 0xaeacdb71, 0x10888852, 0xf4e28117, 0xe2a14812, 0x73b748dc, 0xd1c3c6b2, 0xfef41bf0, 0xc9b43b62, 0x810e4faa, 0xcaa41c06, 0x1893fe0d, 0xedc7c850, 0xd12b9eaa, 0x467ee1a9, 0xbe84756b, 0xda7b1680, 0xdc069ffe, 0xf1e7e9f9, 0xb3d95370, 0xa92b77df, 0x5693ac41, 0xd04b7287, 0x27aebf15, 0x837b316e, 0x4dbe2263, 0xbab70c67, 0x547dab21, 0x3c346c1f, 0xb8ef0e4e, 0xfe2d03ce, 0xe1d75955, 0xfec1306, 0xba35c23e, 0xb784ed04, 0x2a4e33aa, 0x7e19d09a, 0x3827c1fe, 0xf3a51561, 0xef765e2b, 0xb044256c, 0x62b322be, 0xf34d56be, 0xeb71b369, 0xffe1294f, 0x237fe8d0, 0x77a1473b, 0x239e1196, 0xdd19bf3d, 0x82c91fe1, 0x95361c57, 0xffea3f1b, 0x1a094c84},
Field12: []int64{8308420747267165049, 3664160795077875961, 7868970059161834817, 7237335984251173739, 5254748003907196506, 3362259627111837480, 430460752854552122, 5119635556501066533, 1277716037866233522, 9185775384759813768, 833932430882717888, 7986528304451297640, 6792233378368656337, 2074207091120609721, 1788723326198279432, 7756514594746453657, 2283775964901597324, 3061497730110517191, 7733947890656120277, 626967303632386244, 7822928600388582821, 3489658753000061230, 168869995163005961, 248814782163480763, 477885608911386247, 4198422415674133867, 3379354662797976109, 9925112544736939, 1486335136459138480, 4561560414032850671, 1010864164014091267, 186722821683803084, 5106357936724819318, 1298160820191228988, 4675403242419953145, 7130634540106489752, 7101280006672440929, 7176058292431955718, 9109875054097770321, 6810974877085322872, 4736707874303993641, 8993135362721382187, 6857881554990254283, 3704748883307461680, 1099360832887634994, 5207691918707192633, 5984721695043995243},
}
size := proto.Size(n)
data, err := proto.Marshal(n)
if err != nil {
panic(err)
}
if len(data) != size {
t.Fatalf("expected %v, but got %v diff is %v", len(data), size, len(data)-size)
}
}
func testSize(m interface {
proto.Message
Size() int
}, desc string, expected int) ([]byte, error) {
data, err := proto.Marshal(m)
if err != nil {
return nil, err
}
protoSize := proto.Size(m)
mSize := m.Size()
lenData := len(data)
if protoSize != mSize || protoSize != lenData || mSize != lenData {
return nil, fmt.Errorf("%s proto.Size(m){%d} != m.Size(){%d} != len(data){%d}", desc, protoSize, mSize, lenData)
}
if got := protoSize; got != expected {
return nil, fmt.Errorf("%s proto.Size(m) got %d expected %d", desc, got, expected)
}
if got := mSize; got != expected {
return nil, fmt.Errorf("%s m.Size() got %d expected %d", desc, got, expected)
}
if got := lenData; got != expected {
return nil, fmt.Errorf("%s len(data) got %d expected %d", desc, got, expected)
}
return data, nil
}
func TestInt32Int64Compatibility(t *testing.T) {
//test nullable int32 and int64
data1, err := testSize(&NinOptNative{
Field3: proto.Int32(-1),
}, "nullable", 11)
if err != nil {
t.Error(err)
}
//change marshaled data1 to unmarshal into 4th field which is an int64
data1[0] = uint8(uint32(4 /*fieldNumber*/)<<3 | uint32(0 /*wireType*/))
u1 := &NinOptNative{}
if err = proto.Unmarshal(data1, u1); err != nil {
t.Error(err)
}
if !u1.Equal(&NinOptNative{
Field4: proto.Int64(-1),
}) {
t.Error("nullable unmarshaled int32 is not the same int64")
}
//test non-nullable int32 and int64
data2, err := testSize(&NidOptNative{
Field3: -1,
}, "non nullable", 67)
if err != nil {
t.Error(err)
}
//change marshaled data2 to unmarshal into 4th field which is an int64
field3 := uint8(uint32(3 /*fieldNumber*/)<<3 | uint32(0 /*wireType*/))
field4 := uint8(uint32(4 /*fieldNumber*/)<<3 | uint32(0 /*wireType*/))
for i, c := range data2 {
if c == field4 {
data2[i] = field3
} else if c == field3 {
data2[i] = field4
}
}
u2 := &NidOptNative{}
if err = proto.Unmarshal(data2, u2); err != nil {
t.Error(err)
}
if !u2.Equal(&NidOptNative{
Field4: -1,
}) {
t.Error("non nullable unmarshaled int32 is not the same int64")
}
//test packed repeated int32 and int64
m4 := &NinRepPackedNative{
Field3: []int32{-1},
}
data4, err := testSize(m4, "packed", 12)
if err != nil {
t.Error(err)
}
u4 := &NinRepPackedNative{}
if err := proto.Unmarshal(data4, u4); err != nil {
t.Error(err)
}
if err := u4.VerboseEqual(m4); err != nil {
t.Fatalf("%#v", u4)
}
//test repeated int32 and int64
if _, err := testSize(&NinRepNative{
Field3: []int32{-1},
}, "repeated", 11); err != nil {
t.Error(err)
}
t.Logf("tested all")
}
func TestRepeatedExtensionsMsgsIssue161(t *testing.T) {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
rep := 10
nins := make([]*NinOptNative, rep)
for i := range nins {
nins[i] = NewPopulatedNinOptNative(r, true)
}
input := &MyExtendable{}
if err := proto.SetExtension(input, E_FieldE, nins); err != nil {
t.Fatal(err)
}
data, err := proto.Marshal(input)
if err != nil {
t.Fatal(err)
}
output := &MyExtendable{}
if err := proto.Unmarshal(data, output); err != nil {
t.Fatal(err)
}
if !input.Equal(output) {
t.Fatal("expected equal")
}
data2, err2 := proto.Marshal(output)
if err2 != nil {
t.Fatal(err2)
}
if len(data) != len(data2) {
t.Fatal("expected equal length buffers")
}
}
func TestRepeatedExtensionsFieldsIssue161(t *testing.T) {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
rep := 10
ints := make([]int64, rep)
for i := range ints {
ints[i] = r.Int63()
}
input := &MyExtendable{}
if err := proto.SetExtension(input, E_FieldD, ints); err != nil {
t.Fatal(err)
}
data, err := proto.Marshal(input)
if err != nil {
t.Fatal(err)
}
output := &MyExtendable{}
if err := proto.Unmarshal(data, output); err != nil {
t.Fatal(err)
}
if !input.Equal(output) {
t.Fatal("expected equal")
}
data2, err2 := proto.Marshal(output)
if err2 != nil {
t.Fatal(err2)
}
if len(data) != len(data2) {
t.Fatal("expected equal length buffers")
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,626 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package test;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.goproto_enum_prefix_all) = false;
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
option (gogoproto.stringer_all) = true;
option (gogoproto.gostring_all) = true;
option (gogoproto.face_all) = true;
option (gogoproto.description_all) = true;
option (gogoproto.testgen_all) = true;
option (gogoproto.populate_all) = true;
option (gogoproto.benchgen_all) = true;
option (gogoproto.unmarshaler_all) = true;
option (gogoproto.marshaler_all) = true;
option (gogoproto.sizer_all) = true;
option (gogoproto.protosizer_all) = false;
option (gogoproto.goproto_enum_stringer_all) = false;
option (gogoproto.enum_stringer_all) = true;
option (gogoproto.unsafe_marshaler_all) = false;
option (gogoproto.unsafe_unmarshaler_all) = false;
option (gogoproto.compare_all) = true;
message NidOptNative {
optional double Field1 = 1 [(gogoproto.nullable) = false];
optional float Field2 = 2 [(gogoproto.nullable) = false];
optional int32 Field3 = 3 [(gogoproto.nullable) = false];
optional int64 Field4 = 4 [(gogoproto.nullable) = false];
optional uint32 Field5 = 5 [(gogoproto.nullable) = false];
optional uint64 Field6 = 6 [(gogoproto.nullable) = false];
optional sint32 Field7 = 7 [(gogoproto.nullable) = false];
optional sint64 Field8 = 8 [(gogoproto.nullable) = false];
optional fixed32 Field9 = 9 [(gogoproto.nullable) = false];
optional sfixed32 Field10 = 10 [(gogoproto.nullable) = false];
optional fixed64 Field11 = 11 [(gogoproto.nullable) = false];
optional sfixed64 Field12 = 12 [(gogoproto.nullable) = false];
optional bool Field13 = 13 [(gogoproto.nullable) = false];
optional string Field14 = 14 [(gogoproto.nullable) = false];
optional bytes Field15 = 15 [(gogoproto.nullable) = false];
}
message NinOptNative {
optional double Field1 = 1;
optional float Field2 = 2;
optional int32 Field3 = 3;
optional int64 Field4 = 4;
optional uint32 Field5 = 5;
optional uint64 Field6 = 6;
optional sint32 Field7 = 7;
optional sint64 Field8 = 8;
optional fixed32 Field9 = 9;
optional sfixed32 Field10 = 10;
optional fixed64 Field11 = 11;
optional sfixed64 Field12 = 12;
optional bool Field13 = 13;
optional string Field14 = 14;
optional bytes Field15 = 15;
}
message NidRepNative {
repeated double Field1 = 1 [(gogoproto.nullable) = false];
repeated float Field2 = 2 [(gogoproto.nullable) = false];
repeated int32 Field3 = 3 [(gogoproto.nullable) = false];
repeated int64 Field4 = 4 [(gogoproto.nullable) = false];
repeated uint32 Field5 = 5 [(gogoproto.nullable) = false];
repeated uint64 Field6 = 6 [(gogoproto.nullable) = false];
repeated sint32 Field7 = 7 [(gogoproto.nullable) = false];
repeated sint64 Field8 = 8 [(gogoproto.nullable) = false];
repeated fixed32 Field9 = 9 [(gogoproto.nullable) = false];
repeated sfixed32 Field10 = 10 [(gogoproto.nullable) = false];
repeated fixed64 Field11 = 11 [(gogoproto.nullable) = false];
repeated sfixed64 Field12 = 12 [(gogoproto.nullable) = false];
repeated bool Field13 = 13 [(gogoproto.nullable) = false];
repeated string Field14 = 14 [(gogoproto.nullable) = false];
repeated bytes Field15 = 15 [(gogoproto.nullable) = false];
}
message NinRepNative {
repeated double Field1 = 1;
repeated float Field2 = 2;
repeated int32 Field3 = 3;
repeated int64 Field4 = 4;
repeated uint32 Field5 = 5;
repeated uint64 Field6 = 6;
repeated sint32 Field7 = 7;
repeated sint64 Field8 = 8;
repeated fixed32 Field9 = 9;
repeated sfixed32 Field10 = 10;
repeated fixed64 Field11 = 11;
repeated sfixed64 Field12 = 12;
repeated bool Field13 = 13;
repeated string Field14 = 14;
repeated bytes Field15 = 15;
}
message NidRepPackedNative {
repeated double Field1 = 1 [(gogoproto.nullable) = false, packed = true];
repeated float Field2 = 2 [(gogoproto.nullable) = false, packed = true];
repeated int32 Field3 = 3 [(gogoproto.nullable) = false, packed = true];
repeated int64 Field4 = 4 [(gogoproto.nullable) = false, packed = true];
repeated uint32 Field5 = 5 [(gogoproto.nullable) = false, packed = true];
repeated uint64 Field6 = 6 [(gogoproto.nullable) = false, packed = true];
repeated sint32 Field7 = 7 [(gogoproto.nullable) = false, packed = true];
repeated sint64 Field8 = 8 [(gogoproto.nullable) = false, packed = true];
repeated fixed32 Field9 = 9 [(gogoproto.nullable) = false, packed = true];
repeated sfixed32 Field10 = 10 [(gogoproto.nullable) = false, packed = true];
repeated fixed64 Field11 = 11 [(gogoproto.nullable) = false, packed = true];
repeated sfixed64 Field12 = 12 [(gogoproto.nullable) = false, packed = true];
repeated bool Field13 = 13 [(gogoproto.nullable) = false, packed = true];
}
message NinRepPackedNative {
repeated double Field1 = 1 [packed = true];
repeated float Field2 = 2 [packed = true];
repeated int32 Field3 = 3 [packed = true];
repeated int64 Field4 = 4 [packed = true];
repeated uint32 Field5 = 5 [packed = true];
repeated uint64 Field6 = 6 [packed = true];
repeated sint32 Field7 = 7 [packed = true];
repeated sint64 Field8 = 8 [packed = true];
repeated fixed32 Field9 = 9 [packed = true];
repeated sfixed32 Field10 = 10 [packed = true];
repeated fixed64 Field11 = 11 [packed = true];
repeated sfixed64 Field12 = 12 [packed = true];
repeated bool Field13 = 13 [packed = true];
}
message NidOptStruct {
optional double Field1 = 1 [(gogoproto.nullable) = false];
optional float Field2 = 2 [(gogoproto.nullable) = false];
optional NidOptNative Field3 = 3 [(gogoproto.nullable) = false];
optional NinOptNative Field4 = 4 [(gogoproto.nullable) = false];
optional uint64 Field6 = 6 [(gogoproto.nullable) = false];
optional sint32 Field7 = 7 [(gogoproto.nullable) = false];
optional NidOptNative Field8 = 8 [(gogoproto.nullable) = false];
optional bool Field13 = 13 [(gogoproto.nullable) = false];
optional string Field14 = 14 [(gogoproto.nullable) = false];
optional bytes Field15 = 15 [(gogoproto.nullable) = false];
}
message NinOptStruct {
optional double Field1 = 1;
optional float Field2 = 2;
optional NidOptNative Field3 = 3;
optional NinOptNative Field4 = 4;
optional uint64 Field6 = 6;
optional sint32 Field7 = 7;
optional NidOptNative Field8 = 8;
optional bool Field13 = 13;
optional string Field14 = 14;
optional bytes Field15 = 15;
}
message NidRepStruct {
repeated double Field1 = 1 [(gogoproto.nullable) = false];
repeated float Field2 = 2 [(gogoproto.nullable) = false];
repeated NidOptNative Field3 = 3 [(gogoproto.nullable) = false];
repeated NinOptNative Field4 = 4 [(gogoproto.nullable) = false];
repeated uint64 Field6 = 6 [(gogoproto.nullable) = false];
repeated sint32 Field7 = 7 [(gogoproto.nullable) = false];
repeated NidOptNative Field8 = 8 [(gogoproto.nullable) = false];
repeated bool Field13 = 13 [(gogoproto.nullable) = false];
repeated string Field14 = 14 [(gogoproto.nullable) = false];
repeated bytes Field15 = 15 [(gogoproto.nullable) = false];
}
message NinRepStruct {
repeated double Field1 = 1;
repeated float Field2 = 2;
repeated NidOptNative Field3 = 3;
repeated NinOptNative Field4 = 4;
repeated uint64 Field6 = 6;
repeated sint32 Field7 = 7;
repeated NidOptNative Field8 = 8;
repeated bool Field13 = 13;
repeated string Field14 = 14;
repeated bytes Field15 = 15;
}
message NidEmbeddedStruct {
optional NidOptNative Field1 = 1 [(gogoproto.embed) = true];
optional NidOptNative Field200 = 200 [(gogoproto.nullable) = false];
optional bool Field210 = 210 [(gogoproto.nullable) = false];
}
message NinEmbeddedStruct {
optional NidOptNative Field1 = 1 [(gogoproto.embed) = true];
optional NidOptNative Field200 = 200;
optional bool Field210 = 210;
}
message NidNestedStruct {
optional NidOptStruct Field1 = 1 [(gogoproto.nullable) = false];
repeated NidRepStruct Field2 = 2 [(gogoproto.nullable) = false];
}
message NinNestedStruct {
optional NinOptStruct Field1 = 1;
repeated NinRepStruct Field2 = 2;
}
message NidOptCustom {
optional bytes Id = 1 [(gogoproto.customtype) = "Uuid", (gogoproto.nullable) = false];
optional bytes Value = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128", (gogoproto.nullable) = false];
}
message CustomDash {
optional bytes Value = 1 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom-dash-type.Bytes"];
}
message NinOptCustom {
optional bytes Id = 1 [(gogoproto.customtype) = "Uuid"];
optional bytes Value = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"];
}
message NidRepCustom {
repeated bytes Id = 1 [(gogoproto.customtype) = "Uuid", (gogoproto.nullable) = false];
repeated bytes Value = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128", (gogoproto.nullable) = false];
}
message NinRepCustom {
repeated bytes Id = 1 [(gogoproto.customtype) = "Uuid"];
repeated bytes Value = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"];
}
message NinOptNativeUnion {
option (gogoproto.onlyone) = true;
optional double Field1 = 1;
optional float Field2 = 2;
optional int32 Field3 = 3;
optional int64 Field4 = 4;
optional uint32 Field5 = 5;
optional uint64 Field6 = 6;
optional bool Field13 = 13;
optional string Field14 = 14;
optional bytes Field15 = 15;
}
message NinOptStructUnion {
option (gogoproto.onlyone) = true;
optional double Field1 = 1;
optional float Field2 = 2;
optional NidOptNative Field3 = 3;
optional NinOptNative Field4 = 4;
optional uint64 Field6 = 6;
optional sint32 Field7 = 7;
optional bool Field13 = 13;
optional string Field14 = 14;
optional bytes Field15 = 15;
}
message NinEmbeddedStructUnion {
option (gogoproto.onlyone) = true;
optional NidOptNative Field1 = 1 [(gogoproto.embed) = true];
optional NinOptNative Field200 = 200;
optional bool Field210 = 210;
}
message NinNestedStructUnion {
option (gogoproto.onlyone) = true;
optional NinOptNativeUnion Field1 = 1;
optional NinOptStructUnion Field2 = 2;
optional NinEmbeddedStructUnion Field3 = 3;
}
message Tree {
option (gogoproto.onlyone) = true;
optional OrBranch Or = 1;
optional AndBranch And = 2;
optional Leaf Leaf = 3;
}
message OrBranch {
optional Tree Left = 1 [(gogoproto.nullable) = false];
optional Tree Right = 2 [(gogoproto.nullable) = false];
}
message AndBranch {
optional Tree Left = 1 [(gogoproto.nullable) = false];
optional Tree Right = 2 [(gogoproto.nullable) = false];
}
message Leaf {
optional int64 Value = 1 [(gogoproto.nullable) = false];
optional string StrValue = 2 [(gogoproto.nullable) = false];
}
message DeepTree {
option (gogoproto.onlyone) = true;
optional ADeepBranch Down = 1;
optional AndDeepBranch And = 2;
optional DeepLeaf Leaf = 3;
}
message ADeepBranch {
optional DeepTree Down = 2 [(gogoproto.nullable) = false];
}
message AndDeepBranch {
optional DeepTree Left = 1 [(gogoproto.nullable) = false];
optional DeepTree Right = 2 [(gogoproto.nullable) = false];
}
message DeepLeaf {
optional Tree Tree = 1 [(gogoproto.nullable) = false];
}
message Nil {
}
enum TheTestEnum {
A = 0;
B = 1;
C = 2;
}
enum AnotherTestEnum {
option (gogoproto.goproto_enum_prefix) = false;
D = 10;
E = 11;
}
// YetAnotherTestEnum is used to test cross-package import of custom name
// fields and default resolution.
enum YetAnotherTestEnum {
option (gogoproto.goproto_enum_prefix) = false;
AA = 0;
BB = 1 [(gogoproto.enumvalue_customname) = "BetterYetBB"];
}
// YetAnotherTestEnum is used to test cross-package import of custom name
// fields and default resolution.
enum YetYetAnotherTestEnum {
option (gogoproto.goproto_enum_prefix) = true;
CC = 0;
DD = 1 [(gogoproto.enumvalue_customname) = "BetterYetDD"];
}
message NidOptEnum {
optional TheTestEnum Field1 = 1 [(gogoproto.nullable) = false];
}
message NinOptEnum {
optional TheTestEnum Field1 = 1;
optional YetAnotherTestEnum Field2 = 2;
optional YetYetAnotherTestEnum Field3 = 3;
}
message NidRepEnum {
repeated TheTestEnum Field1 = 1 [(gogoproto.nullable) = false];
repeated YetAnotherTestEnum Field2 = 2 [(gogoproto.nullable) = false];
repeated YetYetAnotherTestEnum Field3 = 3 [(gogoproto.nullable) = false];
}
message NinRepEnum {
repeated TheTestEnum Field1 = 1;
repeated YetAnotherTestEnum Field2 = 2;
repeated YetYetAnotherTestEnum Field3 = 3;
}
message NinOptEnumDefault {
option (gogoproto.goproto_getters) = true;
option (gogoproto.face) = false;
optional TheTestEnum Field1 = 1 [default=C];
optional YetAnotherTestEnum Field2 = 2 [default=BB];
optional YetYetAnotherTestEnum Field3 = 3 [default=CC];
}
message AnotherNinOptEnum {
optional AnotherTestEnum Field1 = 1;
optional YetAnotherTestEnum Field2 = 2;
optional YetYetAnotherTestEnum Field3 = 3;
}
message AnotherNinOptEnumDefault {
option (gogoproto.goproto_getters) = true;
option (gogoproto.face) = false;
optional AnotherTestEnum Field1 = 1 [default=E];
optional YetAnotherTestEnum Field2 = 2 [default=BB];
optional YetYetAnotherTestEnum Field3 = 3 [default=CC];
}
message Timer {
optional sfixed64 Time1 = 1 [(gogoproto.nullable) = false];
optional sfixed64 Time2 = 2 [(gogoproto.nullable) = false];
optional bytes Data = 3 [(gogoproto.nullable) = false];
}
message MyExtendable {
option (gogoproto.face) = false;
optional int64 Field1 = 1;
extensions 100 to 199;
}
extend MyExtendable {
optional double FieldA = 100;
optional NinOptNative FieldB = 101;
optional NinEmbeddedStruct FieldC = 102;
repeated int64 FieldD = 104;
repeated NinOptNative FieldE = 105;
}
message OtherExtenable {
option (gogoproto.face) = false;
optional int64 Field2 = 2;
extensions 14 to 16;
optional int64 Field13 = 13;
extensions 10 to 12;
optional MyExtendable M = 1;
}
message NestedDefinition {
optional int64 Field1 = 1;
message NestedMessage {
optional fixed64 NestedField1 = 1;
optional NestedNestedMsg NNM = 2;
message NestedNestedMsg {
optional string NestedNestedField1 = 10;
}
}
enum NestedEnum {
TYPE_NESTED = 1;
}
optional NestedEnum EnumField = 2;
optional NestedMessage.NestedNestedMsg NNM = 3;
optional NestedMessage NM = 4;
}
message NestedScope {
optional NestedDefinition.NestedMessage.NestedNestedMsg A = 1;
optional NestedDefinition.NestedEnum B = 2;
optional NestedDefinition.NestedMessage C = 3;
}
message NinOptNativeDefault {
option (gogoproto.goproto_getters) = true;
option (gogoproto.face) = false;
optional double Field1 = 1 [default = 1234.1234];
optional float Field2 = 2 [default = 1234.1234];
optional int32 Field3 = 3 [default = 1234];
optional int64 Field4 = 4 [default = 1234];
optional uint32 Field5 = 5 [default = 1234];
optional uint64 Field6 = 6 [default = 1234];
optional sint32 Field7 = 7 [default = 1234];
optional sint64 Field8 = 8 [default = 1234];
optional fixed32 Field9 = 9 [default = 1234];
optional sfixed32 Field10 = 10 [default = 1234];
optional fixed64 Field11 = 11 [default = 1234];
optional sfixed64 Field12 = 12 [default = 1234];
optional bool Field13 = 13 [default = true];
optional string Field14 = 14 [default = "1234"];
optional bytes Field15 = 15;
}
message CustomContainer {
optional NidOptCustom CustomStruct = 1 [(gogoproto.nullable) = false];
}
message CustomNameNidOptNative {
optional double Field1 = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldA"];
optional float Field2 = 2 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldB"];
optional int32 Field3 = 3 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldC"];
optional int64 Field4 = 4 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldD"];
optional uint32 Field5 = 5 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldE"];
optional uint64 Field6 = 6 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldF"];
optional sint32 Field7 = 7 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldG"];
optional sint64 Field8 = 8 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldH"];
optional fixed32 Field9 = 9 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldI"];
optional sfixed32 Field10 = 10 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldJ"];
optional fixed64 Field11 = 11 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldK"];
optional sfixed64 Field12 = 12 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldL"];
optional bool Field13 = 13 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldM"];
optional string Field14 = 14 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldN"];
optional bytes Field15 = 15 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldO"];
}
message CustomNameNinOptNative {
optional double Field1 = 1 [(gogoproto.customname) = "FieldA"];
optional float Field2 = 2 [(gogoproto.customname) = "FieldB"];
optional int32 Field3 = 3 [(gogoproto.customname) = "FieldC"];
optional int64 Field4 = 4 [(gogoproto.customname) = "FieldD"];
optional uint32 Field5 = 5 [(gogoproto.customname) = "FieldE"];
optional uint64 Field6 = 6 [(gogoproto.customname) = "FieldF"];
optional sint32 Field7 = 7 [(gogoproto.customname) = "FieldG"];
optional sint64 Field8 = 8 [(gogoproto.customname) = "FieldH"];
optional fixed32 Field9 = 9 [(gogoproto.customname) = "FieldI"];
optional sfixed32 Field10 = 10 [(gogoproto.customname) = "FieldJ"];
optional fixed64 Field11 = 11 [(gogoproto.customname) = "FieldK"];
optional sfixed64 Field12 = 12 [(gogoproto.customname) = "FielL"];
optional bool Field13 = 13 [(gogoproto.customname) = "FieldM"];
optional string Field14 = 14 [(gogoproto.customname) = "FieldN"];
optional bytes Field15 = 15 [(gogoproto.customname) = "FieldO"];
}
message CustomNameNinRepNative {
repeated double Field1 = 1 [(gogoproto.customname) = "FieldA"];
repeated float Field2 = 2 [(gogoproto.customname) = "FieldB"];
repeated int32 Field3 = 3 [(gogoproto.customname) = "FieldC"];
repeated int64 Field4 = 4 [(gogoproto.customname) = "FieldD"];
repeated uint32 Field5 = 5 [(gogoproto.customname) = "FieldE"];
repeated uint64 Field6 = 6 [(gogoproto.customname) = "FieldF"];
repeated sint32 Field7 = 7 [(gogoproto.customname) = "FieldG"];
repeated sint64 Field8 = 8 [(gogoproto.customname) = "FieldH"];
repeated fixed32 Field9 = 9 [(gogoproto.customname) = "FieldI"];
repeated sfixed32 Field10 = 10 [(gogoproto.customname) = "FieldJ"];
repeated fixed64 Field11 = 11 [(gogoproto.customname) = "FieldK"];
repeated sfixed64 Field12 = 12 [(gogoproto.customname) = "FieldL"];
repeated bool Field13 = 13 [(gogoproto.customname) = "FieldM"];
repeated string Field14 = 14 [(gogoproto.customname) = "FieldN"];
repeated bytes Field15 = 15 [(gogoproto.customname) = "FieldO"];
}
message CustomNameNinStruct {
optional double Field1 = 1 [(gogoproto.customname) = "FieldA"];
optional float Field2 = 2 [(gogoproto.customname) = "FieldB"];
optional NidOptNative Field3 = 3 [(gogoproto.customname) = "FieldC"];
repeated NinOptNative Field4 = 4 [(gogoproto.customname) = "FieldD"];
optional uint64 Field6 = 6 [(gogoproto.customname) = "FieldE"];
optional sint32 Field7 = 7 [(gogoproto.customname) = "FieldF"];
optional NidOptNative Field8 = 8 [(gogoproto.customname) = "FieldG"];
optional bool Field13 = 13 [(gogoproto.customname) = "FieldH"];
optional string Field14 = 14 [(gogoproto.customname) = "FieldI"];
optional bytes Field15 = 15 [(gogoproto.customname) = "FieldJ"];
}
message CustomNameCustomType {
optional bytes Id = 1 [(gogoproto.customname) = "FieldA", (gogoproto.customtype) = "Uuid"];
optional bytes Value = 2 [(gogoproto.customname) = "FieldB", (gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"];
repeated bytes Ids = 3 [(gogoproto.customname) = "FieldC", (gogoproto.customtype) = "Uuid"];
repeated bytes Values = 4 [(gogoproto.customname) = "FieldD", (gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"];
}
message CustomNameNinEmbeddedStructUnion {
option (gogoproto.onlyone) = true;
optional NidOptNative Field1 = 1 [(gogoproto.embed) = true];
optional NinOptNative Field200 = 200 [(gogoproto.customname) = "FieldA"];
optional bool Field210 = 210 [(gogoproto.customname) = "FieldB"];
}
message CustomNameEnum {
optional TheTestEnum Field1 = 1 [(gogoproto.customname) = "FieldA"];
repeated TheTestEnum Field2 = 2 [(gogoproto.customname) = "FieldB"];
}
message NoExtensionsMap {
option (gogoproto.face) = false;
option (gogoproto.goproto_extensions_map) = false;
optional int64 Field1 = 1;
extensions 100 to 199;
}
extend NoExtensionsMap {
optional double FieldA1 = 100;
optional NinOptNative FieldB1 = 101;
optional NinEmbeddedStruct FieldC1 = 102;
}
message Unrecognized {
option (gogoproto.goproto_unrecognized) = false;
optional string Field1 = 1;
}
message UnrecognizedWithInner {
message Inner {
option (gogoproto.goproto_unrecognized) = false;
optional uint32 Field1 = 1;
}
repeated Inner embedded = 1;
optional string Field2 = 2;
}
message UnrecognizedWithEmbed {
message Embedded {
option (gogoproto.goproto_unrecognized) = false;
optional uint32 Field1 = 1;
}
optional Embedded embedded = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false];
optional string Field2 = 2;
}
message Node {
optional string Label = 1;
repeated Node Children = 2;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,133 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package test
import (
"bytes"
"encoding/hex"
"encoding/json"
)
func PutLittleEndianUint64(b []byte, offset int, v uint64) {
b[offset] = byte(v)
b[offset+1] = byte(v >> 8)
b[offset+2] = byte(v >> 16)
b[offset+3] = byte(v >> 24)
b[offset+4] = byte(v >> 32)
b[offset+5] = byte(v >> 40)
b[offset+6] = byte(v >> 48)
b[offset+7] = byte(v >> 56)
}
type Uuid []byte
func (uuid Uuid) Marshal() ([]byte, error) {
if len(uuid) == 0 {
return nil, nil
}
return []byte(uuid), nil
}
func (uuid Uuid) MarshalTo(data []byte) (n int, err error) {
if len(uuid) == 0 {
return 0, nil
}
copy(data, uuid)
return 16, nil
}
func (uuid *Uuid) Unmarshal(data []byte) error {
if len(data) == 0 {
uuid = nil
return nil
}
id := Uuid(make([]byte, 16))
copy(id, data)
*uuid = id
return nil
}
func (uuid *Uuid) Size() int {
if uuid == nil {
return 0
}
if len(*uuid) == 0 {
return 0
}
return 16
}
func (uuid Uuid) MarshalJSON() ([]byte, error) {
s := hex.EncodeToString([]byte(uuid))
return json.Marshal(s)
}
func (uuid *Uuid) UnmarshalJSON(data []byte) error {
var s string
err := json.Unmarshal(data, &s)
if err != nil {
return err
}
d, err := hex.DecodeString(s)
if err != nil {
return err
}
*uuid = Uuid(d)
return nil
}
func (uuid Uuid) Equal(other Uuid) bool {
return bytes.Equal(uuid[0:], other[0:])
}
func (uuid Uuid) Compare(other Uuid) int {
return bytes.Compare(uuid[0:], other[0:])
}
type int63 interface {
Int63() int64
}
func NewPopulatedUuid(r int63) *Uuid {
u := RandV4(r)
return &u
}
func RandV4(r int63) Uuid {
uuid := make(Uuid, 16)
uuid.RandV4(r)
return uuid
}
func (uuid Uuid) RandV4(r int63) {
PutLittleEndianUint64(uuid, 0, uint64(r.Int63()))
PutLittleEndianUint64(uuid, 8, uint64(r.Int63()))
uuid[6] = (uuid[6] & 0xf) | 0x40
uuid[8] = (uuid[8] & 0x3f) | 0x80
}

View file

@ -0,0 +1,252 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package test
import (
"fmt"
"math"
"math/rand"
"testing"
"time"
"github.com/gogo/protobuf/proto"
)
//http://code.google.com/p/goprotobuf/issues/detail?id=39
func TestBugUint32VarintSize(t *testing.T) {
temp := uint32(math.MaxUint32)
n := &NinOptNative{}
n.Field5 = &temp
data, err := proto.Marshal(n)
if err != nil {
panic(err)
}
if len(data) != 6 {
t.Fatalf("data should be length 6, but its %#v", data)
}
}
func TestBugZeroLengthSliceSize(t *testing.T) {
n := &NinRepPackedNative{
Field8: []int64{},
}
size := n.Size()
data, err := proto.Marshal(n)
if err != nil {
panic(err)
}
if len(data) != size {
t.Fatalf("expected %v, but got %v", len(data), size)
}
}
//http://code.google.com/p/goprotobuf/issues/detail?id=40
func TestBugPackedProtoSize(t *testing.T) {
n := &NinRepPackedNative{
Field4: []int64{172960727389894724, 2360337516664475010, 860833876131988189, 9068073014890763245, 7794843386260381831, 4023536436053141786, 8992311247496919020, 4330096163611305776, 4490411416244976467, 7873947349172707443, 2754969595834279669, 1360667855926938684, 4771480785172657389, 4875578924966668055, 8070579869808877481, 9128179594766551001, 4630419407064527516, 863844540220372892, 8208727650143073487, 7086117356301045838, 7779695211931506151, 5493835345187563535, 9119767633370806007, 9054342025895349248, 1887303228838508438, 7624573031734528281, 1874668389749611225, 3517684643468970593, 6677697606628877758, 7293473953189936168, 444475066704085538, 8594971141363049302, 1146643249094989673, 733393306232853371, 7721178528893916886, 7784452000911004429, 6436373110242711440, 6897422461738321237, 8772249155667732778, 6211871464311393541, 3061903718310406883, 7845488913176136641, 8342255034663902574, 3443058984649725748, 8410801047334832902, 7496541071517841153, 4305416923521577765, 7814967600020476457, 8671843803465481186, 3490266370361096855, 1447425664719091336, 653218597262334239, 8306243902880091940, 7851896059762409081, 5936760560798954978, 5755724498441478025, 7022701569985035966, 3707709584811468220, 529069456924666920, 7986469043681522462, 3092513330689518836, 5103541550470476202, 3577384161242626406, 3733428084624703294, 8388690542440473117, 3262468785346149388, 8788358556558007570, 5476276940198542020, 7277903243119461239, 5065861426928605020, 7533460976202697734, 1749213838654236956, 557497603941617931, 5496307611456481108, 6444547750062831720, 6992758776744205596, 7356719693428537399, 2896328872476734507, 381447079530132038, 598300737753233118, 3687980626612697715, 7240924191084283349, 8172414415307971170, 4847024388701257185, 2081764168600256551, 3394217778539123488, 6244660626429310923, 8301712215675381614, 5360615125359461174, 8410140945829785773, 3152963269026381373, 6197275282781459633, 4419829061407546410, 6262035523070047537, 2837207483933463885, 2158105736666826128, 8150764172235490711},
Field7: []int32{249451845, 1409974015, 393609128, 435232428, 1817529040, 91769006, 861170933, 1556185603, 1568580279, 1236375273, 512276621, 693633711, 967580535, 1950715977, 853431462, 1362390253, 159591204, 111900629, 322985263, 279671129, 1592548430, 465651370, 733849989, 1172059400, 1574824441, 263541092, 1271612397, 1520584358, 467078791, 117698716, 1098255064, 2054264846, 1766452305, 1267576395, 1557505617, 1187833560, 956187431, 1970977586, 1160235159, 1610259028, 489585797, 459139078, 566263183, 954319278, 1545018565, 1753946743, 948214318, 422878159, 883926576, 1424009347, 824732372, 1290433180, 80297942, 417294230, 1402647904, 2078392782, 220505045, 787368129, 463781454, 293083578, 808156928, 293976361},
Field9: []uint32{0xaa4976e8, 0x3da8cc4c, 0x8c470d83, 0x344d964e, 0x5b90925, 0xa4c4d34e, 0x666eff19, 0xc238e552, 0x9be53bb6, 0x56364245, 0x33ee079d, 0x96bf0ede, 0x7941b74f, 0xdb07cb47, 0x6d76d827, 0x9b211d5d, 0x2798adb6, 0xe48b0c3b, 0x87061b21, 0x48f4e4d2, 0x3e5d5c12, 0x5ee91288, 0x336d4f35, 0xe1d44941, 0xc065548d, 0x2953d73f, 0x873af451, 0xfc769db, 0x9f1bf8da, 0x9baafdfc, 0xf1d3d770, 0x5bb5d2b4, 0xc2c67c48, 0x6845c4c1, 0xa48f32b0, 0xbb04bb70, 0xa5b1ca36, 0x8d98356a, 0x2171f654, 0x5ae279b0, 0x6c4a3d6b, 0x4fff5468, 0xcf9bf851, 0x68513614, 0xdbecd9b0, 0x9553ed3c, 0xa494a736, 0x42205438, 0xbf8e5caa, 0xd3283c6, 0x76d20788, 0x9179826f, 0x96b24f85, 0xbc2eacf4, 0xe4afae0b, 0x4bca85cb, 0x35e63b5b, 0xd7ccee0c, 0x2b506bb9, 0xe78e9f44, 0x9ad232f1, 0x99a37335, 0xa5d6ffc8},
Field11: []uint64{0x53c01ebc, 0x4fb85ba6, 0x8805eea1, 0xb20ec896, 0x93b63410, 0xec7c9492, 0x50765a28, 0x19592106, 0x2ecc59b3, 0x39cd474f, 0xe4c9e47, 0x444f48c5, 0xe7731d32, 0xf3f43975, 0x603caedd, 0xbb05a1af, 0xa808e34e, 0x88580b07, 0x4c96bbd1, 0x730b4ab9, 0xed126e2b, 0x6db48205, 0x154ba1b9, 0xc26bfb6a, 0x389aa052, 0x869d966c, 0x7c86b366, 0xcc8edbcd, 0xfa8d6dad, 0xcf5857d9, 0x2d9cda0f, 0x1218a0b8, 0x41bf997, 0xf0ca65ac, 0xa610d4b9, 0x8d362e28, 0xb7212d87, 0x8e0fe109, 0xbee041d9, 0x759be2f6, 0x35fef4f3, 0xaeacdb71, 0x10888852, 0xf4e28117, 0xe2a14812, 0x73b748dc, 0xd1c3c6b2, 0xfef41bf0, 0xc9b43b62, 0x810e4faa, 0xcaa41c06, 0x1893fe0d, 0xedc7c850, 0xd12b9eaa, 0x467ee1a9, 0xbe84756b, 0xda7b1680, 0xdc069ffe, 0xf1e7e9f9, 0xb3d95370, 0xa92b77df, 0x5693ac41, 0xd04b7287, 0x27aebf15, 0x837b316e, 0x4dbe2263, 0xbab70c67, 0x547dab21, 0x3c346c1f, 0xb8ef0e4e, 0xfe2d03ce, 0xe1d75955, 0xfec1306, 0xba35c23e, 0xb784ed04, 0x2a4e33aa, 0x7e19d09a, 0x3827c1fe, 0xf3a51561, 0xef765e2b, 0xb044256c, 0x62b322be, 0xf34d56be, 0xeb71b369, 0xffe1294f, 0x237fe8d0, 0x77a1473b, 0x239e1196, 0xdd19bf3d, 0x82c91fe1, 0x95361c57, 0xffea3f1b, 0x1a094c84},
Field12: []int64{8308420747267165049, 3664160795077875961, 7868970059161834817, 7237335984251173739, 5254748003907196506, 3362259627111837480, 430460752854552122, 5119635556501066533, 1277716037866233522, 9185775384759813768, 833932430882717888, 7986528304451297640, 6792233378368656337, 2074207091120609721, 1788723326198279432, 7756514594746453657, 2283775964901597324, 3061497730110517191, 7733947890656120277, 626967303632386244, 7822928600388582821, 3489658753000061230, 168869995163005961, 248814782163480763, 477885608911386247, 4198422415674133867, 3379354662797976109, 9925112544736939, 1486335136459138480, 4561560414032850671, 1010864164014091267, 186722821683803084, 5106357936724819318, 1298160820191228988, 4675403242419953145, 7130634540106489752, 7101280006672440929, 7176058292431955718, 9109875054097770321, 6810974877085322872, 4736707874303993641, 8993135362721382187, 6857881554990254283, 3704748883307461680, 1099360832887634994, 5207691918707192633, 5984721695043995243},
}
size := proto.Size(n)
data, err := proto.Marshal(n)
if err != nil {
panic(err)
}
if len(data) != size {
t.Fatalf("expected %v, but got %v diff is %v", len(data), size, len(data)-size)
}
}
func testSize(m interface {
proto.Message
Size() int
}, desc string, expected int) ([]byte, error) {
data, err := proto.Marshal(m)
if err != nil {
return nil, err
}
protoSize := proto.Size(m)
mSize := m.Size()
lenData := len(data)
if protoSize != mSize || protoSize != lenData || mSize != lenData {
return nil, fmt.Errorf("%s proto.Size(m){%d} != m.Size(){%d} != len(data){%d}", desc, protoSize, mSize, lenData)
}
if got := protoSize; got != expected {
return nil, fmt.Errorf("%s proto.Size(m) got %d expected %d", desc, got, expected)
}
if got := mSize; got != expected {
return nil, fmt.Errorf("%s m.Size() got %d expected %d", desc, got, expected)
}
if got := lenData; got != expected {
return nil, fmt.Errorf("%s len(data) got %d expected %d", desc, got, expected)
}
return data, nil
}
func TestInt32Int64Compatibility(t *testing.T) {
//test nullable int32 and int64
data1, err := testSize(&NinOptNative{
Field3: proto.Int32(-1),
}, "nullable", 11)
if err != nil {
t.Error(err)
}
//change marshaled data1 to unmarshal into 4th field which is an int64
data1[0] = uint8(uint32(4 /*fieldNumber*/)<<3 | uint32(0 /*wireType*/))
u1 := &NinOptNative{}
if err = proto.Unmarshal(data1, u1); err != nil {
t.Error(err)
}
if !u1.Equal(&NinOptNative{
Field4: proto.Int64(-1),
}) {
t.Error("nullable unmarshaled int32 is not the same int64")
}
//test non-nullable int32 and int64
data2, err := testSize(&NidOptNative{
Field3: -1,
}, "non nullable", 67)
if err != nil {
t.Error(err)
}
//change marshaled data2 to unmarshal into 4th field which is an int64
field3 := uint8(uint32(3 /*fieldNumber*/)<<3 | uint32(0 /*wireType*/))
field4 := uint8(uint32(4 /*fieldNumber*/)<<3 | uint32(0 /*wireType*/))
for i, c := range data2 {
if c == field4 {
data2[i] = field3
} else if c == field3 {
data2[i] = field4
}
}
u2 := &NidOptNative{}
if err = proto.Unmarshal(data2, u2); err != nil {
t.Error(err)
}
if !u2.Equal(&NidOptNative{
Field4: -1,
}) {
t.Error("non nullable unmarshaled int32 is not the same int64")
}
//test packed repeated int32 and int64
m4 := &NinRepPackedNative{
Field3: []int32{-1},
}
data4, err := testSize(m4, "packed", 12)
if err != nil {
t.Error(err)
}
u4 := &NinRepPackedNative{}
if err := proto.Unmarshal(data4, u4); err != nil {
t.Error(err)
}
if err := u4.VerboseEqual(m4); err != nil {
t.Fatalf("%#v", u4)
}
//test repeated int32 and int64
if _, err := testSize(&NinRepNative{
Field3: []int32{-1},
}, "repeated", 11); err != nil {
t.Error(err)
}
t.Logf("tested all")
}
func TestRepeatedExtensionsMsgsIssue161(t *testing.T) {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
rep := 10
nins := make([]*NinOptNative, rep)
for i := range nins {
nins[i] = NewPopulatedNinOptNative(r, true)
}
input := &MyExtendable{}
if err := proto.SetExtension(input, E_FieldE, nins); err != nil {
t.Fatal(err)
}
data, err := proto.Marshal(input)
if err != nil {
t.Fatal(err)
}
output := &MyExtendable{}
if err := proto.Unmarshal(data, output); err != nil {
t.Fatal(err)
}
if !input.Equal(output) {
t.Fatal("expected equal")
}
data2, err2 := proto.Marshal(output)
if err2 != nil {
t.Fatal(err2)
}
if len(data) != len(data2) {
t.Fatal("expected equal length buffers")
}
}
func TestRepeatedExtensionsFieldsIssue161(t *testing.T) {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
rep := 10
ints := make([]int64, rep)
for i := range ints {
ints[i] = r.Int63()
}
input := &MyExtendable{}
if err := proto.SetExtension(input, E_FieldD, ints); err != nil {
t.Fatal(err)
}
data, err := proto.Marshal(input)
if err != nil {
t.Fatal(err)
}
output := &MyExtendable{}
if err := proto.Unmarshal(data, output); err != nil {
t.Fatal(err)
}
if !input.Equal(output) {
t.Fatal("expected equal")
}
data2, err2 := proto.Marshal(output)
if err2 != nil {
t.Fatal(err2)
}
if len(data) != len(data2) {
t.Fatal("expected equal length buffers")
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,626 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package test;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.goproto_enum_prefix_all) = false;
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
option (gogoproto.stringer_all) = true;
option (gogoproto.gostring_all) = true;
option (gogoproto.face_all) = true;
option (gogoproto.description_all) = true;
option (gogoproto.testgen_all) = true;
option (gogoproto.populate_all) = true;
option (gogoproto.benchgen_all) = true;
option (gogoproto.unmarshaler_all) = false;
option (gogoproto.marshaler_all) = true;
option (gogoproto.sizer_all) = true;
option (gogoproto.protosizer_all) = false;
option (gogoproto.goproto_enum_stringer_all) = false;
option (gogoproto.enum_stringer_all) = true;
option (gogoproto.unsafe_marshaler_all) = false;
option (gogoproto.unsafe_unmarshaler_all) = false;
option (gogoproto.compare_all) = true;
message NidOptNative {
optional double Field1 = 1 [(gogoproto.nullable) = false];
optional float Field2 = 2 [(gogoproto.nullable) = false];
optional int32 Field3 = 3 [(gogoproto.nullable) = false];
optional int64 Field4 = 4 [(gogoproto.nullable) = false];
optional uint32 Field5 = 5 [(gogoproto.nullable) = false];
optional uint64 Field6 = 6 [(gogoproto.nullable) = false];
optional sint32 Field7 = 7 [(gogoproto.nullable) = false];
optional sint64 Field8 = 8 [(gogoproto.nullable) = false];
optional fixed32 Field9 = 9 [(gogoproto.nullable) = false];
optional sfixed32 Field10 = 10 [(gogoproto.nullable) = false];
optional fixed64 Field11 = 11 [(gogoproto.nullable) = false];
optional sfixed64 Field12 = 12 [(gogoproto.nullable) = false];
optional bool Field13 = 13 [(gogoproto.nullable) = false];
optional string Field14 = 14 [(gogoproto.nullable) = false];
optional bytes Field15 = 15 [(gogoproto.nullable) = false];
}
message NinOptNative {
optional double Field1 = 1;
optional float Field2 = 2;
optional int32 Field3 = 3;
optional int64 Field4 = 4;
optional uint32 Field5 = 5;
optional uint64 Field6 = 6;
optional sint32 Field7 = 7;
optional sint64 Field8 = 8;
optional fixed32 Field9 = 9;
optional sfixed32 Field10 = 10;
optional fixed64 Field11 = 11;
optional sfixed64 Field12 = 12;
optional bool Field13 = 13;
optional string Field14 = 14;
optional bytes Field15 = 15;
}
message NidRepNative {
repeated double Field1 = 1 [(gogoproto.nullable) = false];
repeated float Field2 = 2 [(gogoproto.nullable) = false];
repeated int32 Field3 = 3 [(gogoproto.nullable) = false];
repeated int64 Field4 = 4 [(gogoproto.nullable) = false];
repeated uint32 Field5 = 5 [(gogoproto.nullable) = false];
repeated uint64 Field6 = 6 [(gogoproto.nullable) = false];
repeated sint32 Field7 = 7 [(gogoproto.nullable) = false];
repeated sint64 Field8 = 8 [(gogoproto.nullable) = false];
repeated fixed32 Field9 = 9 [(gogoproto.nullable) = false];
repeated sfixed32 Field10 = 10 [(gogoproto.nullable) = false];
repeated fixed64 Field11 = 11 [(gogoproto.nullable) = false];
repeated sfixed64 Field12 = 12 [(gogoproto.nullable) = false];
repeated bool Field13 = 13 [(gogoproto.nullable) = false];
repeated string Field14 = 14 [(gogoproto.nullable) = false];
repeated bytes Field15 = 15 [(gogoproto.nullable) = false];
}
message NinRepNative {
repeated double Field1 = 1;
repeated float Field2 = 2;
repeated int32 Field3 = 3;
repeated int64 Field4 = 4;
repeated uint32 Field5 = 5;
repeated uint64 Field6 = 6;
repeated sint32 Field7 = 7;
repeated sint64 Field8 = 8;
repeated fixed32 Field9 = 9;
repeated sfixed32 Field10 = 10;
repeated fixed64 Field11 = 11;
repeated sfixed64 Field12 = 12;
repeated bool Field13 = 13;
repeated string Field14 = 14;
repeated bytes Field15 = 15;
}
message NidRepPackedNative {
repeated double Field1 = 1 [(gogoproto.nullable) = false, packed = true];
repeated float Field2 = 2 [(gogoproto.nullable) = false, packed = true];
repeated int32 Field3 = 3 [(gogoproto.nullable) = false, packed = true];
repeated int64 Field4 = 4 [(gogoproto.nullable) = false, packed = true];
repeated uint32 Field5 = 5 [(gogoproto.nullable) = false, packed = true];
repeated uint64 Field6 = 6 [(gogoproto.nullable) = false, packed = true];
repeated sint32 Field7 = 7 [(gogoproto.nullable) = false, packed = true];
repeated sint64 Field8 = 8 [(gogoproto.nullable) = false, packed = true];
repeated fixed32 Field9 = 9 [(gogoproto.nullable) = false, packed = true];
repeated sfixed32 Field10 = 10 [(gogoproto.nullable) = false, packed = true];
repeated fixed64 Field11 = 11 [(gogoproto.nullable) = false, packed = true];
repeated sfixed64 Field12 = 12 [(gogoproto.nullable) = false, packed = true];
repeated bool Field13 = 13 [(gogoproto.nullable) = false, packed = true];
}
message NinRepPackedNative {
repeated double Field1 = 1 [packed = true];
repeated float Field2 = 2 [packed = true];
repeated int32 Field3 = 3 [packed = true];
repeated int64 Field4 = 4 [packed = true];
repeated uint32 Field5 = 5 [packed = true];
repeated uint64 Field6 = 6 [packed = true];
repeated sint32 Field7 = 7 [packed = true];
repeated sint64 Field8 = 8 [packed = true];
repeated fixed32 Field9 = 9 [packed = true];
repeated sfixed32 Field10 = 10 [packed = true];
repeated fixed64 Field11 = 11 [packed = true];
repeated sfixed64 Field12 = 12 [packed = true];
repeated bool Field13 = 13 [packed = true];
}
message NidOptStruct {
optional double Field1 = 1 [(gogoproto.nullable) = false];
optional float Field2 = 2 [(gogoproto.nullable) = false];
optional NidOptNative Field3 = 3 [(gogoproto.nullable) = false];
optional NinOptNative Field4 = 4 [(gogoproto.nullable) = false];
optional uint64 Field6 = 6 [(gogoproto.nullable) = false];
optional sint32 Field7 = 7 [(gogoproto.nullable) = false];
optional NidOptNative Field8 = 8 [(gogoproto.nullable) = false];
optional bool Field13 = 13 [(gogoproto.nullable) = false];
optional string Field14 = 14 [(gogoproto.nullable) = false];
optional bytes Field15 = 15 [(gogoproto.nullable) = false];
}
message NinOptStruct {
optional double Field1 = 1;
optional float Field2 = 2;
optional NidOptNative Field3 = 3;
optional NinOptNative Field4 = 4;
optional uint64 Field6 = 6;
optional sint32 Field7 = 7;
optional NidOptNative Field8 = 8;
optional bool Field13 = 13;
optional string Field14 = 14;
optional bytes Field15 = 15;
}
message NidRepStruct {
repeated double Field1 = 1 [(gogoproto.nullable) = false];
repeated float Field2 = 2 [(gogoproto.nullable) = false];
repeated NidOptNative Field3 = 3 [(gogoproto.nullable) = false];
repeated NinOptNative Field4 = 4 [(gogoproto.nullable) = false];
repeated uint64 Field6 = 6 [(gogoproto.nullable) = false];
repeated sint32 Field7 = 7 [(gogoproto.nullable) = false];
repeated NidOptNative Field8 = 8 [(gogoproto.nullable) = false];
repeated bool Field13 = 13 [(gogoproto.nullable) = false];
repeated string Field14 = 14 [(gogoproto.nullable) = false];
repeated bytes Field15 = 15 [(gogoproto.nullable) = false];
}
message NinRepStruct {
repeated double Field1 = 1;
repeated float Field2 = 2;
repeated NidOptNative Field3 = 3;
repeated NinOptNative Field4 = 4;
repeated uint64 Field6 = 6;
repeated sint32 Field7 = 7;
repeated NidOptNative Field8 = 8;
repeated bool Field13 = 13;
repeated string Field14 = 14;
repeated bytes Field15 = 15;
}
message NidEmbeddedStruct {
optional NidOptNative Field1 = 1 [(gogoproto.embed) = true];
optional NidOptNative Field200 = 200 [(gogoproto.nullable) = false];
optional bool Field210 = 210 [(gogoproto.nullable) = false];
}
message NinEmbeddedStruct {
optional NidOptNative Field1 = 1 [(gogoproto.embed) = true];
optional NidOptNative Field200 = 200;
optional bool Field210 = 210;
}
message NidNestedStruct {
optional NidOptStruct Field1 = 1 [(gogoproto.nullable) = false];
repeated NidRepStruct Field2 = 2 [(gogoproto.nullable) = false];
}
message NinNestedStruct {
optional NinOptStruct Field1 = 1;
repeated NinRepStruct Field2 = 2;
}
message NidOptCustom {
optional bytes Id = 1 [(gogoproto.customtype) = "Uuid", (gogoproto.nullable) = false];
optional bytes Value = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128", (gogoproto.nullable) = false];
}
message CustomDash {
optional bytes Value = 1 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom-dash-type.Bytes"];
}
message NinOptCustom {
optional bytes Id = 1 [(gogoproto.customtype) = "Uuid"];
optional bytes Value = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"];
}
message NidRepCustom {
repeated bytes Id = 1 [(gogoproto.customtype) = "Uuid", (gogoproto.nullable) = false];
repeated bytes Value = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128", (gogoproto.nullable) = false];
}
message NinRepCustom {
repeated bytes Id = 1 [(gogoproto.customtype) = "Uuid"];
repeated bytes Value = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"];
}
message NinOptNativeUnion {
option (gogoproto.onlyone) = true;
optional double Field1 = 1;
optional float Field2 = 2;
optional int32 Field3 = 3;
optional int64 Field4 = 4;
optional uint32 Field5 = 5;
optional uint64 Field6 = 6;
optional bool Field13 = 13;
optional string Field14 = 14;
optional bytes Field15 = 15;
}
message NinOptStructUnion {
option (gogoproto.onlyone) = true;
optional double Field1 = 1;
optional float Field2 = 2;
optional NidOptNative Field3 = 3;
optional NinOptNative Field4 = 4;
optional uint64 Field6 = 6;
optional sint32 Field7 = 7;
optional bool Field13 = 13;
optional string Field14 = 14;
optional bytes Field15 = 15;
}
message NinEmbeddedStructUnion {
option (gogoproto.onlyone) = true;
optional NidOptNative Field1 = 1 [(gogoproto.embed) = true];
optional NinOptNative Field200 = 200;
optional bool Field210 = 210;
}
message NinNestedStructUnion {
option (gogoproto.onlyone) = true;
optional NinOptNativeUnion Field1 = 1;
optional NinOptStructUnion Field2 = 2;
optional NinEmbeddedStructUnion Field3 = 3;
}
message Tree {
option (gogoproto.onlyone) = true;
optional OrBranch Or = 1;
optional AndBranch And = 2;
optional Leaf Leaf = 3;
}
message OrBranch {
optional Tree Left = 1 [(gogoproto.nullable) = false];
optional Tree Right = 2 [(gogoproto.nullable) = false];
}
message AndBranch {
optional Tree Left = 1 [(gogoproto.nullable) = false];
optional Tree Right = 2 [(gogoproto.nullable) = false];
}
message Leaf {
optional int64 Value = 1 [(gogoproto.nullable) = false];
optional string StrValue = 2 [(gogoproto.nullable) = false];
}
message DeepTree {
option (gogoproto.onlyone) = true;
optional ADeepBranch Down = 1;
optional AndDeepBranch And = 2;
optional DeepLeaf Leaf = 3;
}
message ADeepBranch {
optional DeepTree Down = 2 [(gogoproto.nullable) = false];
}
message AndDeepBranch {
optional DeepTree Left = 1 [(gogoproto.nullable) = false];
optional DeepTree Right = 2 [(gogoproto.nullable) = false];
}
message DeepLeaf {
optional Tree Tree = 1 [(gogoproto.nullable) = false];
}
message Nil {
}
enum TheTestEnum {
A = 0;
B = 1;
C = 2;
}
enum AnotherTestEnum {
option (gogoproto.goproto_enum_prefix) = false;
D = 10;
E = 11;
}
// YetAnotherTestEnum is used to test cross-package import of custom name
// fields and default resolution.
enum YetAnotherTestEnum {
option (gogoproto.goproto_enum_prefix) = false;
AA = 0;
BB = 1 [(gogoproto.enumvalue_customname) = "BetterYetBB"];
}
// YetAnotherTestEnum is used to test cross-package import of custom name
// fields and default resolution.
enum YetYetAnotherTestEnum {
option (gogoproto.goproto_enum_prefix) = true;
CC = 0;
DD = 1 [(gogoproto.enumvalue_customname) = "BetterYetDD"];
}
message NidOptEnum {
optional TheTestEnum Field1 = 1 [(gogoproto.nullable) = false];
}
message NinOptEnum {
optional TheTestEnum Field1 = 1;
optional YetAnotherTestEnum Field2 = 2;
optional YetYetAnotherTestEnum Field3 = 3;
}
message NidRepEnum {
repeated TheTestEnum Field1 = 1 [(gogoproto.nullable) = false];
repeated YetAnotherTestEnum Field2 = 2 [(gogoproto.nullable) = false];
repeated YetYetAnotherTestEnum Field3 = 3 [(gogoproto.nullable) = false];
}
message NinRepEnum {
repeated TheTestEnum Field1 = 1;
repeated YetAnotherTestEnum Field2 = 2;
repeated YetYetAnotherTestEnum Field3 = 3;
}
message NinOptEnumDefault {
option (gogoproto.goproto_getters) = true;
option (gogoproto.face) = false;
optional TheTestEnum Field1 = 1 [default=C];
optional YetAnotherTestEnum Field2 = 2 [default=BB];
optional YetYetAnotherTestEnum Field3 = 3 [default=CC];
}
message AnotherNinOptEnum {
optional AnotherTestEnum Field1 = 1;
optional YetAnotherTestEnum Field2 = 2;
optional YetYetAnotherTestEnum Field3 = 3;
}
message AnotherNinOptEnumDefault {
option (gogoproto.goproto_getters) = true;
option (gogoproto.face) = false;
optional AnotherTestEnum Field1 = 1 [default=E];
optional YetAnotherTestEnum Field2 = 2 [default=BB];
optional YetYetAnotherTestEnum Field3 = 3 [default=CC];
}
message Timer {
optional sfixed64 Time1 = 1 [(gogoproto.nullable) = false];
optional sfixed64 Time2 = 2 [(gogoproto.nullable) = false];
optional bytes Data = 3 [(gogoproto.nullable) = false];
}
message MyExtendable {
option (gogoproto.face) = false;
optional int64 Field1 = 1;
extensions 100 to 199;
}
extend MyExtendable {
optional double FieldA = 100;
optional NinOptNative FieldB = 101;
optional NinEmbeddedStruct FieldC = 102;
repeated int64 FieldD = 104;
repeated NinOptNative FieldE = 105;
}
message OtherExtenable {
option (gogoproto.face) = false;
optional int64 Field2 = 2;
extensions 14 to 16;
optional int64 Field13 = 13;
extensions 10 to 12;
optional MyExtendable M = 1;
}
message NestedDefinition {
optional int64 Field1 = 1;
message NestedMessage {
optional fixed64 NestedField1 = 1;
optional NestedNestedMsg NNM = 2;
message NestedNestedMsg {
optional string NestedNestedField1 = 10;
}
}
enum NestedEnum {
TYPE_NESTED = 1;
}
optional NestedEnum EnumField = 2;
optional NestedMessage.NestedNestedMsg NNM = 3;
optional NestedMessage NM = 4;
}
message NestedScope {
optional NestedDefinition.NestedMessage.NestedNestedMsg A = 1;
optional NestedDefinition.NestedEnum B = 2;
optional NestedDefinition.NestedMessage C = 3;
}
message NinOptNativeDefault {
option (gogoproto.goproto_getters) = true;
option (gogoproto.face) = false;
optional double Field1 = 1 [default = 1234.1234];
optional float Field2 = 2 [default = 1234.1234];
optional int32 Field3 = 3 [default = 1234];
optional int64 Field4 = 4 [default = 1234];
optional uint32 Field5 = 5 [default = 1234];
optional uint64 Field6 = 6 [default = 1234];
optional sint32 Field7 = 7 [default = 1234];
optional sint64 Field8 = 8 [default = 1234];
optional fixed32 Field9 = 9 [default = 1234];
optional sfixed32 Field10 = 10 [default = 1234];
optional fixed64 Field11 = 11 [default = 1234];
optional sfixed64 Field12 = 12 [default = 1234];
optional bool Field13 = 13 [default = true];
optional string Field14 = 14 [default = "1234"];
optional bytes Field15 = 15;
}
message CustomContainer {
optional NidOptCustom CustomStruct = 1 [(gogoproto.nullable) = false];
}
message CustomNameNidOptNative {
optional double Field1 = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldA"];
optional float Field2 = 2 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldB"];
optional int32 Field3 = 3 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldC"];
optional int64 Field4 = 4 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldD"];
optional uint32 Field5 = 5 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldE"];
optional uint64 Field6 = 6 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldF"];
optional sint32 Field7 = 7 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldG"];
optional sint64 Field8 = 8 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldH"];
optional fixed32 Field9 = 9 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldI"];
optional sfixed32 Field10 = 10 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldJ"];
optional fixed64 Field11 = 11 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldK"];
optional sfixed64 Field12 = 12 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldL"];
optional bool Field13 = 13 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldM"];
optional string Field14 = 14 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldN"];
optional bytes Field15 = 15 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldO"];
}
message CustomNameNinOptNative {
optional double Field1 = 1 [(gogoproto.customname) = "FieldA"];
optional float Field2 = 2 [(gogoproto.customname) = "FieldB"];
optional int32 Field3 = 3 [(gogoproto.customname) = "FieldC"];
optional int64 Field4 = 4 [(gogoproto.customname) = "FieldD"];
optional uint32 Field5 = 5 [(gogoproto.customname) = "FieldE"];
optional uint64 Field6 = 6 [(gogoproto.customname) = "FieldF"];
optional sint32 Field7 = 7 [(gogoproto.customname) = "FieldG"];
optional sint64 Field8 = 8 [(gogoproto.customname) = "FieldH"];
optional fixed32 Field9 = 9 [(gogoproto.customname) = "FieldI"];
optional sfixed32 Field10 = 10 [(gogoproto.customname) = "FieldJ"];
optional fixed64 Field11 = 11 [(gogoproto.customname) = "FieldK"];
optional sfixed64 Field12 = 12 [(gogoproto.customname) = "FielL"];
optional bool Field13 = 13 [(gogoproto.customname) = "FieldM"];
optional string Field14 = 14 [(gogoproto.customname) = "FieldN"];
optional bytes Field15 = 15 [(gogoproto.customname) = "FieldO"];
}
message CustomNameNinRepNative {
repeated double Field1 = 1 [(gogoproto.customname) = "FieldA"];
repeated float Field2 = 2 [(gogoproto.customname) = "FieldB"];
repeated int32 Field3 = 3 [(gogoproto.customname) = "FieldC"];
repeated int64 Field4 = 4 [(gogoproto.customname) = "FieldD"];
repeated uint32 Field5 = 5 [(gogoproto.customname) = "FieldE"];
repeated uint64 Field6 = 6 [(gogoproto.customname) = "FieldF"];
repeated sint32 Field7 = 7 [(gogoproto.customname) = "FieldG"];
repeated sint64 Field8 = 8 [(gogoproto.customname) = "FieldH"];
repeated fixed32 Field9 = 9 [(gogoproto.customname) = "FieldI"];
repeated sfixed32 Field10 = 10 [(gogoproto.customname) = "FieldJ"];
repeated fixed64 Field11 = 11 [(gogoproto.customname) = "FieldK"];
repeated sfixed64 Field12 = 12 [(gogoproto.customname) = "FieldL"];
repeated bool Field13 = 13 [(gogoproto.customname) = "FieldM"];
repeated string Field14 = 14 [(gogoproto.customname) = "FieldN"];
repeated bytes Field15 = 15 [(gogoproto.customname) = "FieldO"];
}
message CustomNameNinStruct {
optional double Field1 = 1 [(gogoproto.customname) = "FieldA"];
optional float Field2 = 2 [(gogoproto.customname) = "FieldB"];
optional NidOptNative Field3 = 3 [(gogoproto.customname) = "FieldC"];
repeated NinOptNative Field4 = 4 [(gogoproto.customname) = "FieldD"];
optional uint64 Field6 = 6 [(gogoproto.customname) = "FieldE"];
optional sint32 Field7 = 7 [(gogoproto.customname) = "FieldF"];
optional NidOptNative Field8 = 8 [(gogoproto.customname) = "FieldG"];
optional bool Field13 = 13 [(gogoproto.customname) = "FieldH"];
optional string Field14 = 14 [(gogoproto.customname) = "FieldI"];
optional bytes Field15 = 15 [(gogoproto.customname) = "FieldJ"];
}
message CustomNameCustomType {
optional bytes Id = 1 [(gogoproto.customname) = "FieldA", (gogoproto.customtype) = "Uuid"];
optional bytes Value = 2 [(gogoproto.customname) = "FieldB", (gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"];
repeated bytes Ids = 3 [(gogoproto.customname) = "FieldC", (gogoproto.customtype) = "Uuid"];
repeated bytes Values = 4 [(gogoproto.customname) = "FieldD", (gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"];
}
message CustomNameNinEmbeddedStructUnion {
option (gogoproto.onlyone) = true;
optional NidOptNative Field1 = 1 [(gogoproto.embed) = true];
optional NinOptNative Field200 = 200 [(gogoproto.customname) = "FieldA"];
optional bool Field210 = 210 [(gogoproto.customname) = "FieldB"];
}
message CustomNameEnum {
optional TheTestEnum Field1 = 1 [(gogoproto.customname) = "FieldA"];
repeated TheTestEnum Field2 = 2 [(gogoproto.customname) = "FieldB"];
}
message NoExtensionsMap {
option (gogoproto.face) = false;
option (gogoproto.goproto_extensions_map) = false;
optional int64 Field1 = 1;
extensions 100 to 199;
}
extend NoExtensionsMap {
optional double FieldA1 = 100;
optional NinOptNative FieldB1 = 101;
optional NinEmbeddedStruct FieldC1 = 102;
}
message Unrecognized {
option (gogoproto.goproto_unrecognized) = false;
optional string Field1 = 1;
}
message UnrecognizedWithInner {
message Inner {
option (gogoproto.goproto_unrecognized) = false;
optional uint32 Field1 = 1;
}
repeated Inner embedded = 1;
optional string Field2 = 2;
}
message UnrecognizedWithEmbed {
message Embedded {
option (gogoproto.goproto_unrecognized) = false;
optional uint32 Field1 = 1;
}
optional Embedded embedded = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false];
optional string Field2 = 2;
}
message Node {
optional string Label = 1;
repeated Node Children = 2;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,133 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package test
import (
"bytes"
"encoding/hex"
"encoding/json"
)
func PutLittleEndianUint64(b []byte, offset int, v uint64) {
b[offset] = byte(v)
b[offset+1] = byte(v >> 8)
b[offset+2] = byte(v >> 16)
b[offset+3] = byte(v >> 24)
b[offset+4] = byte(v >> 32)
b[offset+5] = byte(v >> 40)
b[offset+6] = byte(v >> 48)
b[offset+7] = byte(v >> 56)
}
type Uuid []byte
func (uuid Uuid) Marshal() ([]byte, error) {
if len(uuid) == 0 {
return nil, nil
}
return []byte(uuid), nil
}
func (uuid Uuid) MarshalTo(data []byte) (n int, err error) {
if len(uuid) == 0 {
return 0, nil
}
copy(data, uuid)
return 16, nil
}
func (uuid *Uuid) Unmarshal(data []byte) error {
if len(data) == 0 {
uuid = nil
return nil
}
id := Uuid(make([]byte, 16))
copy(id, data)
*uuid = id
return nil
}
func (uuid *Uuid) Size() int {
if uuid == nil {
return 0
}
if len(*uuid) == 0 {
return 0
}
return 16
}
func (uuid Uuid) MarshalJSON() ([]byte, error) {
s := hex.EncodeToString([]byte(uuid))
return json.Marshal(s)
}
func (uuid *Uuid) UnmarshalJSON(data []byte) error {
var s string
err := json.Unmarshal(data, &s)
if err != nil {
return err
}
d, err := hex.DecodeString(s)
if err != nil {
return err
}
*uuid = Uuid(d)
return nil
}
func (uuid Uuid) Equal(other Uuid) bool {
return bytes.Equal(uuid[0:], other[0:])
}
func (uuid Uuid) Compare(other Uuid) int {
return bytes.Compare(uuid[0:], other[0:])
}
type int63 interface {
Int63() int64
}
func NewPopulatedUuid(r int63) *Uuid {
u := RandV4(r)
return &u
}
func RandV4(r int63) Uuid {
uuid := make(Uuid, 16)
uuid.RandV4(r)
return uuid
}
func (uuid Uuid) RandV4(r int63) {
PutLittleEndianUint64(uuid, 0, uint64(r.Int63()))
PutLittleEndianUint64(uuid, 8, uint64(r.Int63()))
uuid[6] = (uuid[6] & 0xf) | 0x40
uuid[8] = (uuid[8] & 0x3f) | 0x80
}

View file

@ -0,0 +1,252 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package test
import (
"fmt"
"math"
"math/rand"
"testing"
"time"
"github.com/gogo/protobuf/proto"
)
//http://code.google.com/p/goprotobuf/issues/detail?id=39
func TestBugUint32VarintSize(t *testing.T) {
temp := uint32(math.MaxUint32)
n := &NinOptNative{}
n.Field5 = &temp
data, err := proto.Marshal(n)
if err != nil {
panic(err)
}
if len(data) != 6 {
t.Fatalf("data should be length 6, but its %#v", data)
}
}
func TestBugZeroLengthSliceSize(t *testing.T) {
n := &NinRepPackedNative{
Field8: []int64{},
}
size := n.Size()
data, err := proto.Marshal(n)
if err != nil {
panic(err)
}
if len(data) != size {
t.Fatalf("expected %v, but got %v", len(data), size)
}
}
//http://code.google.com/p/goprotobuf/issues/detail?id=40
func TestBugPackedProtoSize(t *testing.T) {
n := &NinRepPackedNative{
Field4: []int64{172960727389894724, 2360337516664475010, 860833876131988189, 9068073014890763245, 7794843386260381831, 4023536436053141786, 8992311247496919020, 4330096163611305776, 4490411416244976467, 7873947349172707443, 2754969595834279669, 1360667855926938684, 4771480785172657389, 4875578924966668055, 8070579869808877481, 9128179594766551001, 4630419407064527516, 863844540220372892, 8208727650143073487, 7086117356301045838, 7779695211931506151, 5493835345187563535, 9119767633370806007, 9054342025895349248, 1887303228838508438, 7624573031734528281, 1874668389749611225, 3517684643468970593, 6677697606628877758, 7293473953189936168, 444475066704085538, 8594971141363049302, 1146643249094989673, 733393306232853371, 7721178528893916886, 7784452000911004429, 6436373110242711440, 6897422461738321237, 8772249155667732778, 6211871464311393541, 3061903718310406883, 7845488913176136641, 8342255034663902574, 3443058984649725748, 8410801047334832902, 7496541071517841153, 4305416923521577765, 7814967600020476457, 8671843803465481186, 3490266370361096855, 1447425664719091336, 653218597262334239, 8306243902880091940, 7851896059762409081, 5936760560798954978, 5755724498441478025, 7022701569985035966, 3707709584811468220, 529069456924666920, 7986469043681522462, 3092513330689518836, 5103541550470476202, 3577384161242626406, 3733428084624703294, 8388690542440473117, 3262468785346149388, 8788358556558007570, 5476276940198542020, 7277903243119461239, 5065861426928605020, 7533460976202697734, 1749213838654236956, 557497603941617931, 5496307611456481108, 6444547750062831720, 6992758776744205596, 7356719693428537399, 2896328872476734507, 381447079530132038, 598300737753233118, 3687980626612697715, 7240924191084283349, 8172414415307971170, 4847024388701257185, 2081764168600256551, 3394217778539123488, 6244660626429310923, 8301712215675381614, 5360615125359461174, 8410140945829785773, 3152963269026381373, 6197275282781459633, 4419829061407546410, 6262035523070047537, 2837207483933463885, 2158105736666826128, 8150764172235490711},
Field7: []int32{249451845, 1409974015, 393609128, 435232428, 1817529040, 91769006, 861170933, 1556185603, 1568580279, 1236375273, 512276621, 693633711, 967580535, 1950715977, 853431462, 1362390253, 159591204, 111900629, 322985263, 279671129, 1592548430, 465651370, 733849989, 1172059400, 1574824441, 263541092, 1271612397, 1520584358, 467078791, 117698716, 1098255064, 2054264846, 1766452305, 1267576395, 1557505617, 1187833560, 956187431, 1970977586, 1160235159, 1610259028, 489585797, 459139078, 566263183, 954319278, 1545018565, 1753946743, 948214318, 422878159, 883926576, 1424009347, 824732372, 1290433180, 80297942, 417294230, 1402647904, 2078392782, 220505045, 787368129, 463781454, 293083578, 808156928, 293976361},
Field9: []uint32{0xaa4976e8, 0x3da8cc4c, 0x8c470d83, 0x344d964e, 0x5b90925, 0xa4c4d34e, 0x666eff19, 0xc238e552, 0x9be53bb6, 0x56364245, 0x33ee079d, 0x96bf0ede, 0x7941b74f, 0xdb07cb47, 0x6d76d827, 0x9b211d5d, 0x2798adb6, 0xe48b0c3b, 0x87061b21, 0x48f4e4d2, 0x3e5d5c12, 0x5ee91288, 0x336d4f35, 0xe1d44941, 0xc065548d, 0x2953d73f, 0x873af451, 0xfc769db, 0x9f1bf8da, 0x9baafdfc, 0xf1d3d770, 0x5bb5d2b4, 0xc2c67c48, 0x6845c4c1, 0xa48f32b0, 0xbb04bb70, 0xa5b1ca36, 0x8d98356a, 0x2171f654, 0x5ae279b0, 0x6c4a3d6b, 0x4fff5468, 0xcf9bf851, 0x68513614, 0xdbecd9b0, 0x9553ed3c, 0xa494a736, 0x42205438, 0xbf8e5caa, 0xd3283c6, 0x76d20788, 0x9179826f, 0x96b24f85, 0xbc2eacf4, 0xe4afae0b, 0x4bca85cb, 0x35e63b5b, 0xd7ccee0c, 0x2b506bb9, 0xe78e9f44, 0x9ad232f1, 0x99a37335, 0xa5d6ffc8},
Field11: []uint64{0x53c01ebc, 0x4fb85ba6, 0x8805eea1, 0xb20ec896, 0x93b63410, 0xec7c9492, 0x50765a28, 0x19592106, 0x2ecc59b3, 0x39cd474f, 0xe4c9e47, 0x444f48c5, 0xe7731d32, 0xf3f43975, 0x603caedd, 0xbb05a1af, 0xa808e34e, 0x88580b07, 0x4c96bbd1, 0x730b4ab9, 0xed126e2b, 0x6db48205, 0x154ba1b9, 0xc26bfb6a, 0x389aa052, 0x869d966c, 0x7c86b366, 0xcc8edbcd, 0xfa8d6dad, 0xcf5857d9, 0x2d9cda0f, 0x1218a0b8, 0x41bf997, 0xf0ca65ac, 0xa610d4b9, 0x8d362e28, 0xb7212d87, 0x8e0fe109, 0xbee041d9, 0x759be2f6, 0x35fef4f3, 0xaeacdb71, 0x10888852, 0xf4e28117, 0xe2a14812, 0x73b748dc, 0xd1c3c6b2, 0xfef41bf0, 0xc9b43b62, 0x810e4faa, 0xcaa41c06, 0x1893fe0d, 0xedc7c850, 0xd12b9eaa, 0x467ee1a9, 0xbe84756b, 0xda7b1680, 0xdc069ffe, 0xf1e7e9f9, 0xb3d95370, 0xa92b77df, 0x5693ac41, 0xd04b7287, 0x27aebf15, 0x837b316e, 0x4dbe2263, 0xbab70c67, 0x547dab21, 0x3c346c1f, 0xb8ef0e4e, 0xfe2d03ce, 0xe1d75955, 0xfec1306, 0xba35c23e, 0xb784ed04, 0x2a4e33aa, 0x7e19d09a, 0x3827c1fe, 0xf3a51561, 0xef765e2b, 0xb044256c, 0x62b322be, 0xf34d56be, 0xeb71b369, 0xffe1294f, 0x237fe8d0, 0x77a1473b, 0x239e1196, 0xdd19bf3d, 0x82c91fe1, 0x95361c57, 0xffea3f1b, 0x1a094c84},
Field12: []int64{8308420747267165049, 3664160795077875961, 7868970059161834817, 7237335984251173739, 5254748003907196506, 3362259627111837480, 430460752854552122, 5119635556501066533, 1277716037866233522, 9185775384759813768, 833932430882717888, 7986528304451297640, 6792233378368656337, 2074207091120609721, 1788723326198279432, 7756514594746453657, 2283775964901597324, 3061497730110517191, 7733947890656120277, 626967303632386244, 7822928600388582821, 3489658753000061230, 168869995163005961, 248814782163480763, 477885608911386247, 4198422415674133867, 3379354662797976109, 9925112544736939, 1486335136459138480, 4561560414032850671, 1010864164014091267, 186722821683803084, 5106357936724819318, 1298160820191228988, 4675403242419953145, 7130634540106489752, 7101280006672440929, 7176058292431955718, 9109875054097770321, 6810974877085322872, 4736707874303993641, 8993135362721382187, 6857881554990254283, 3704748883307461680, 1099360832887634994, 5207691918707192633, 5984721695043995243},
}
size := proto.Size(n)
data, err := proto.Marshal(n)
if err != nil {
panic(err)
}
if len(data) != size {
t.Fatalf("expected %v, but got %v diff is %v", len(data), size, len(data)-size)
}
}
func testSize(m interface {
proto.Message
Size() int
}, desc string, expected int) ([]byte, error) {
data, err := proto.Marshal(m)
if err != nil {
return nil, err
}
protoSize := proto.Size(m)
mSize := m.Size()
lenData := len(data)
if protoSize != mSize || protoSize != lenData || mSize != lenData {
return nil, fmt.Errorf("%s proto.Size(m){%d} != m.Size(){%d} != len(data){%d}", desc, protoSize, mSize, lenData)
}
if got := protoSize; got != expected {
return nil, fmt.Errorf("%s proto.Size(m) got %d expected %d", desc, got, expected)
}
if got := mSize; got != expected {
return nil, fmt.Errorf("%s m.Size() got %d expected %d", desc, got, expected)
}
if got := lenData; got != expected {
return nil, fmt.Errorf("%s len(data) got %d expected %d", desc, got, expected)
}
return data, nil
}
func TestInt32Int64Compatibility(t *testing.T) {
//test nullable int32 and int64
data1, err := testSize(&NinOptNative{
Field3: proto.Int32(-1),
}, "nullable", 11)
if err != nil {
t.Error(err)
}
//change marshaled data1 to unmarshal into 4th field which is an int64
data1[0] = uint8(uint32(4 /*fieldNumber*/)<<3 | uint32(0 /*wireType*/))
u1 := &NinOptNative{}
if err = proto.Unmarshal(data1, u1); err != nil {
t.Error(err)
}
if !u1.Equal(&NinOptNative{
Field4: proto.Int64(-1),
}) {
t.Error("nullable unmarshaled int32 is not the same int64")
}
//test non-nullable int32 and int64
data2, err := testSize(&NidOptNative{
Field3: -1,
}, "non nullable", 67)
if err != nil {
t.Error(err)
}
//change marshaled data2 to unmarshal into 4th field which is an int64
field3 := uint8(uint32(3 /*fieldNumber*/)<<3 | uint32(0 /*wireType*/))
field4 := uint8(uint32(4 /*fieldNumber*/)<<3 | uint32(0 /*wireType*/))
for i, c := range data2 {
if c == field4 {
data2[i] = field3
} else if c == field3 {
data2[i] = field4
}
}
u2 := &NidOptNative{}
if err = proto.Unmarshal(data2, u2); err != nil {
t.Error(err)
}
if !u2.Equal(&NidOptNative{
Field4: -1,
}) {
t.Error("non nullable unmarshaled int32 is not the same int64")
}
//test packed repeated int32 and int64
m4 := &NinRepPackedNative{
Field3: []int32{-1},
}
data4, err := testSize(m4, "packed", 12)
if err != nil {
t.Error(err)
}
u4 := &NinRepPackedNative{}
if err := proto.Unmarshal(data4, u4); err != nil {
t.Error(err)
}
if err := u4.VerboseEqual(m4); err != nil {
t.Fatalf("%#v", u4)
}
//test repeated int32 and int64
if _, err := testSize(&NinRepNative{
Field3: []int32{-1},
}, "repeated", 11); err != nil {
t.Error(err)
}
t.Logf("tested all")
}
func TestRepeatedExtensionsMsgsIssue161(t *testing.T) {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
rep := 10
nins := make([]*NinOptNative, rep)
for i := range nins {
nins[i] = NewPopulatedNinOptNative(r, true)
}
input := &MyExtendable{}
if err := proto.SetExtension(input, E_FieldE, nins); err != nil {
t.Fatal(err)
}
data, err := proto.Marshal(input)
if err != nil {
t.Fatal(err)
}
output := &MyExtendable{}
if err := proto.Unmarshal(data, output); err != nil {
t.Fatal(err)
}
if !input.Equal(output) {
t.Fatal("expected equal")
}
data2, err2 := proto.Marshal(output)
if err2 != nil {
t.Fatal(err2)
}
if len(data) != len(data2) {
t.Fatal("expected equal length buffers")
}
}
func TestRepeatedExtensionsFieldsIssue161(t *testing.T) {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
rep := 10
ints := make([]int64, rep)
for i := range ints {
ints[i] = r.Int63()
}
input := &MyExtendable{}
if err := proto.SetExtension(input, E_FieldD, ints); err != nil {
t.Fatal(err)
}
data, err := proto.Marshal(input)
if err != nil {
t.Fatal(err)
}
output := &MyExtendable{}
if err := proto.Unmarshal(data, output); err != nil {
t.Fatal(err)
}
if !input.Equal(output) {
t.Fatal("expected equal")
}
data2, err2 := proto.Marshal(output)
if err2 != nil {
t.Fatal(err2)
}
if len(data) != len(data2) {
t.Fatal("expected equal length buffers")
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,626 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package test;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.goproto_enum_prefix_all) = false;
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
option (gogoproto.stringer_all) = true;
option (gogoproto.gostring_all) = true;
option (gogoproto.face_all) = true;
option (gogoproto.description_all) = true;
option (gogoproto.testgen_all) = true;
option (gogoproto.populate_all) = true;
option (gogoproto.benchgen_all) = true;
option (gogoproto.unmarshaler_all) = true;
option (gogoproto.marshaler_all) = false;
option (gogoproto.sizer_all) = true;
option (gogoproto.protosizer_all) = false;
option (gogoproto.goproto_enum_stringer_all) = false;
option (gogoproto.enum_stringer_all) = true;
option (gogoproto.unsafe_marshaler_all) = false;
option (gogoproto.unsafe_unmarshaler_all) = false;
option (gogoproto.compare_all) = true;
message NidOptNative {
optional double Field1 = 1 [(gogoproto.nullable) = false];
optional float Field2 = 2 [(gogoproto.nullable) = false];
optional int32 Field3 = 3 [(gogoproto.nullable) = false];
optional int64 Field4 = 4 [(gogoproto.nullable) = false];
optional uint32 Field5 = 5 [(gogoproto.nullable) = false];
optional uint64 Field6 = 6 [(gogoproto.nullable) = false];
optional sint32 Field7 = 7 [(gogoproto.nullable) = false];
optional sint64 Field8 = 8 [(gogoproto.nullable) = false];
optional fixed32 Field9 = 9 [(gogoproto.nullable) = false];
optional sfixed32 Field10 = 10 [(gogoproto.nullable) = false];
optional fixed64 Field11 = 11 [(gogoproto.nullable) = false];
optional sfixed64 Field12 = 12 [(gogoproto.nullable) = false];
optional bool Field13 = 13 [(gogoproto.nullable) = false];
optional string Field14 = 14 [(gogoproto.nullable) = false];
optional bytes Field15 = 15 [(gogoproto.nullable) = false];
}
message NinOptNative {
optional double Field1 = 1;
optional float Field2 = 2;
optional int32 Field3 = 3;
optional int64 Field4 = 4;
optional uint32 Field5 = 5;
optional uint64 Field6 = 6;
optional sint32 Field7 = 7;
optional sint64 Field8 = 8;
optional fixed32 Field9 = 9;
optional sfixed32 Field10 = 10;
optional fixed64 Field11 = 11;
optional sfixed64 Field12 = 12;
optional bool Field13 = 13;
optional string Field14 = 14;
optional bytes Field15 = 15;
}
message NidRepNative {
repeated double Field1 = 1 [(gogoproto.nullable) = false];
repeated float Field2 = 2 [(gogoproto.nullable) = false];
repeated int32 Field3 = 3 [(gogoproto.nullable) = false];
repeated int64 Field4 = 4 [(gogoproto.nullable) = false];
repeated uint32 Field5 = 5 [(gogoproto.nullable) = false];
repeated uint64 Field6 = 6 [(gogoproto.nullable) = false];
repeated sint32 Field7 = 7 [(gogoproto.nullable) = false];
repeated sint64 Field8 = 8 [(gogoproto.nullable) = false];
repeated fixed32 Field9 = 9 [(gogoproto.nullable) = false];
repeated sfixed32 Field10 = 10 [(gogoproto.nullable) = false];
repeated fixed64 Field11 = 11 [(gogoproto.nullable) = false];
repeated sfixed64 Field12 = 12 [(gogoproto.nullable) = false];
repeated bool Field13 = 13 [(gogoproto.nullable) = false];
repeated string Field14 = 14 [(gogoproto.nullable) = false];
repeated bytes Field15 = 15 [(gogoproto.nullable) = false];
}
message NinRepNative {
repeated double Field1 = 1;
repeated float Field2 = 2;
repeated int32 Field3 = 3;
repeated int64 Field4 = 4;
repeated uint32 Field5 = 5;
repeated uint64 Field6 = 6;
repeated sint32 Field7 = 7;
repeated sint64 Field8 = 8;
repeated fixed32 Field9 = 9;
repeated sfixed32 Field10 = 10;
repeated fixed64 Field11 = 11;
repeated sfixed64 Field12 = 12;
repeated bool Field13 = 13;
repeated string Field14 = 14;
repeated bytes Field15 = 15;
}
message NidRepPackedNative {
repeated double Field1 = 1 [(gogoproto.nullable) = false, packed = true];
repeated float Field2 = 2 [(gogoproto.nullable) = false, packed = true];
repeated int32 Field3 = 3 [(gogoproto.nullable) = false, packed = true];
repeated int64 Field4 = 4 [(gogoproto.nullable) = false, packed = true];
repeated uint32 Field5 = 5 [(gogoproto.nullable) = false, packed = true];
repeated uint64 Field6 = 6 [(gogoproto.nullable) = false, packed = true];
repeated sint32 Field7 = 7 [(gogoproto.nullable) = false, packed = true];
repeated sint64 Field8 = 8 [(gogoproto.nullable) = false, packed = true];
repeated fixed32 Field9 = 9 [(gogoproto.nullable) = false, packed = true];
repeated sfixed32 Field10 = 10 [(gogoproto.nullable) = false, packed = true];
repeated fixed64 Field11 = 11 [(gogoproto.nullable) = false, packed = true];
repeated sfixed64 Field12 = 12 [(gogoproto.nullable) = false, packed = true];
repeated bool Field13 = 13 [(gogoproto.nullable) = false, packed = true];
}
message NinRepPackedNative {
repeated double Field1 = 1 [packed = true];
repeated float Field2 = 2 [packed = true];
repeated int32 Field3 = 3 [packed = true];
repeated int64 Field4 = 4 [packed = true];
repeated uint32 Field5 = 5 [packed = true];
repeated uint64 Field6 = 6 [packed = true];
repeated sint32 Field7 = 7 [packed = true];
repeated sint64 Field8 = 8 [packed = true];
repeated fixed32 Field9 = 9 [packed = true];
repeated sfixed32 Field10 = 10 [packed = true];
repeated fixed64 Field11 = 11 [packed = true];
repeated sfixed64 Field12 = 12 [packed = true];
repeated bool Field13 = 13 [packed = true];
}
message NidOptStruct {
optional double Field1 = 1 [(gogoproto.nullable) = false];
optional float Field2 = 2 [(gogoproto.nullable) = false];
optional NidOptNative Field3 = 3 [(gogoproto.nullable) = false];
optional NinOptNative Field4 = 4 [(gogoproto.nullable) = false];
optional uint64 Field6 = 6 [(gogoproto.nullable) = false];
optional sint32 Field7 = 7 [(gogoproto.nullable) = false];
optional NidOptNative Field8 = 8 [(gogoproto.nullable) = false];
optional bool Field13 = 13 [(gogoproto.nullable) = false];
optional string Field14 = 14 [(gogoproto.nullable) = false];
optional bytes Field15 = 15 [(gogoproto.nullable) = false];
}
message NinOptStruct {
optional double Field1 = 1;
optional float Field2 = 2;
optional NidOptNative Field3 = 3;
optional NinOptNative Field4 = 4;
optional uint64 Field6 = 6;
optional sint32 Field7 = 7;
optional NidOptNative Field8 = 8;
optional bool Field13 = 13;
optional string Field14 = 14;
optional bytes Field15 = 15;
}
message NidRepStruct {
repeated double Field1 = 1 [(gogoproto.nullable) = false];
repeated float Field2 = 2 [(gogoproto.nullable) = false];
repeated NidOptNative Field3 = 3 [(gogoproto.nullable) = false];
repeated NinOptNative Field4 = 4 [(gogoproto.nullable) = false];
repeated uint64 Field6 = 6 [(gogoproto.nullable) = false];
repeated sint32 Field7 = 7 [(gogoproto.nullable) = false];
repeated NidOptNative Field8 = 8 [(gogoproto.nullable) = false];
repeated bool Field13 = 13 [(gogoproto.nullable) = false];
repeated string Field14 = 14 [(gogoproto.nullable) = false];
repeated bytes Field15 = 15 [(gogoproto.nullable) = false];
}
message NinRepStruct {
repeated double Field1 = 1;
repeated float Field2 = 2;
repeated NidOptNative Field3 = 3;
repeated NinOptNative Field4 = 4;
repeated uint64 Field6 = 6;
repeated sint32 Field7 = 7;
repeated NidOptNative Field8 = 8;
repeated bool Field13 = 13;
repeated string Field14 = 14;
repeated bytes Field15 = 15;
}
message NidEmbeddedStruct {
optional NidOptNative Field1 = 1 [(gogoproto.embed) = true];
optional NidOptNative Field200 = 200 [(gogoproto.nullable) = false];
optional bool Field210 = 210 [(gogoproto.nullable) = false];
}
message NinEmbeddedStruct {
optional NidOptNative Field1 = 1 [(gogoproto.embed) = true];
optional NidOptNative Field200 = 200;
optional bool Field210 = 210;
}
message NidNestedStruct {
optional NidOptStruct Field1 = 1 [(gogoproto.nullable) = false];
repeated NidRepStruct Field2 = 2 [(gogoproto.nullable) = false];
}
message NinNestedStruct {
optional NinOptStruct Field1 = 1;
repeated NinRepStruct Field2 = 2;
}
message NidOptCustom {
optional bytes Id = 1 [(gogoproto.customtype) = "Uuid", (gogoproto.nullable) = false];
optional bytes Value = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128", (gogoproto.nullable) = false];
}
message CustomDash {
optional bytes Value = 1 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom-dash-type.Bytes"];
}
message NinOptCustom {
optional bytes Id = 1 [(gogoproto.customtype) = "Uuid"];
optional bytes Value = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"];
}
message NidRepCustom {
repeated bytes Id = 1 [(gogoproto.customtype) = "Uuid", (gogoproto.nullable) = false];
repeated bytes Value = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128", (gogoproto.nullable) = false];
}
message NinRepCustom {
repeated bytes Id = 1 [(gogoproto.customtype) = "Uuid"];
repeated bytes Value = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"];
}
message NinOptNativeUnion {
option (gogoproto.onlyone) = true;
optional double Field1 = 1;
optional float Field2 = 2;
optional int32 Field3 = 3;
optional int64 Field4 = 4;
optional uint32 Field5 = 5;
optional uint64 Field6 = 6;
optional bool Field13 = 13;
optional string Field14 = 14;
optional bytes Field15 = 15;
}
message NinOptStructUnion {
option (gogoproto.onlyone) = true;
optional double Field1 = 1;
optional float Field2 = 2;
optional NidOptNative Field3 = 3;
optional NinOptNative Field4 = 4;
optional uint64 Field6 = 6;
optional sint32 Field7 = 7;
optional bool Field13 = 13;
optional string Field14 = 14;
optional bytes Field15 = 15;
}
message NinEmbeddedStructUnion {
option (gogoproto.onlyone) = true;
optional NidOptNative Field1 = 1 [(gogoproto.embed) = true];
optional NinOptNative Field200 = 200;
optional bool Field210 = 210;
}
message NinNestedStructUnion {
option (gogoproto.onlyone) = true;
optional NinOptNativeUnion Field1 = 1;
optional NinOptStructUnion Field2 = 2;
optional NinEmbeddedStructUnion Field3 = 3;
}
message Tree {
option (gogoproto.onlyone) = true;
optional OrBranch Or = 1;
optional AndBranch And = 2;
optional Leaf Leaf = 3;
}
message OrBranch {
optional Tree Left = 1 [(gogoproto.nullable) = false];
optional Tree Right = 2 [(gogoproto.nullable) = false];
}
message AndBranch {
optional Tree Left = 1 [(gogoproto.nullable) = false];
optional Tree Right = 2 [(gogoproto.nullable) = false];
}
message Leaf {
optional int64 Value = 1 [(gogoproto.nullable) = false];
optional string StrValue = 2 [(gogoproto.nullable) = false];
}
message DeepTree {
option (gogoproto.onlyone) = true;
optional ADeepBranch Down = 1;
optional AndDeepBranch And = 2;
optional DeepLeaf Leaf = 3;
}
message ADeepBranch {
optional DeepTree Down = 2 [(gogoproto.nullable) = false];
}
message AndDeepBranch {
optional DeepTree Left = 1 [(gogoproto.nullable) = false];
optional DeepTree Right = 2 [(gogoproto.nullable) = false];
}
message DeepLeaf {
optional Tree Tree = 1 [(gogoproto.nullable) = false];
}
message Nil {
}
enum TheTestEnum {
A = 0;
B = 1;
C = 2;
}
enum AnotherTestEnum {
option (gogoproto.goproto_enum_prefix) = false;
D = 10;
E = 11;
}
// YetAnotherTestEnum is used to test cross-package import of custom name
// fields and default resolution.
enum YetAnotherTestEnum {
option (gogoproto.goproto_enum_prefix) = false;
AA = 0;
BB = 1 [(gogoproto.enumvalue_customname) = "BetterYetBB"];
}
// YetAnotherTestEnum is used to test cross-package import of custom name
// fields and default resolution.
enum YetYetAnotherTestEnum {
option (gogoproto.goproto_enum_prefix) = true;
CC = 0;
DD = 1 [(gogoproto.enumvalue_customname) = "BetterYetDD"];
}
message NidOptEnum {
optional TheTestEnum Field1 = 1 [(gogoproto.nullable) = false];
}
message NinOptEnum {
optional TheTestEnum Field1 = 1;
optional YetAnotherTestEnum Field2 = 2;
optional YetYetAnotherTestEnum Field3 = 3;
}
message NidRepEnum {
repeated TheTestEnum Field1 = 1 [(gogoproto.nullable) = false];
repeated YetAnotherTestEnum Field2 = 2 [(gogoproto.nullable) = false];
repeated YetYetAnotherTestEnum Field3 = 3 [(gogoproto.nullable) = false];
}
message NinRepEnum {
repeated TheTestEnum Field1 = 1;
repeated YetAnotherTestEnum Field2 = 2;
repeated YetYetAnotherTestEnum Field3 = 3;
}
message NinOptEnumDefault {
option (gogoproto.goproto_getters) = true;
option (gogoproto.face) = false;
optional TheTestEnum Field1 = 1 [default=C];
optional YetAnotherTestEnum Field2 = 2 [default=BB];
optional YetYetAnotherTestEnum Field3 = 3 [default=CC];
}
message AnotherNinOptEnum {
optional AnotherTestEnum Field1 = 1;
optional YetAnotherTestEnum Field2 = 2;
optional YetYetAnotherTestEnum Field3 = 3;
}
message AnotherNinOptEnumDefault {
option (gogoproto.goproto_getters) = true;
option (gogoproto.face) = false;
optional AnotherTestEnum Field1 = 1 [default=E];
optional YetAnotherTestEnum Field2 = 2 [default=BB];
optional YetYetAnotherTestEnum Field3 = 3 [default=CC];
}
message Timer {
optional sfixed64 Time1 = 1 [(gogoproto.nullable) = false];
optional sfixed64 Time2 = 2 [(gogoproto.nullable) = false];
optional bytes Data = 3 [(gogoproto.nullable) = false];
}
message MyExtendable {
option (gogoproto.face) = false;
optional int64 Field1 = 1;
extensions 100 to 199;
}
extend MyExtendable {
optional double FieldA = 100;
optional NinOptNative FieldB = 101;
optional NinEmbeddedStruct FieldC = 102;
repeated int64 FieldD = 104;
repeated NinOptNative FieldE = 105;
}
message OtherExtenable {
option (gogoproto.face) = false;
optional int64 Field2 = 2;
extensions 14 to 16;
optional int64 Field13 = 13;
extensions 10 to 12;
optional MyExtendable M = 1;
}
message NestedDefinition {
optional int64 Field1 = 1;
message NestedMessage {
optional fixed64 NestedField1 = 1;
optional NestedNestedMsg NNM = 2;
message NestedNestedMsg {
optional string NestedNestedField1 = 10;
}
}
enum NestedEnum {
TYPE_NESTED = 1;
}
optional NestedEnum EnumField = 2;
optional NestedMessage.NestedNestedMsg NNM = 3;
optional NestedMessage NM = 4;
}
message NestedScope {
optional NestedDefinition.NestedMessage.NestedNestedMsg A = 1;
optional NestedDefinition.NestedEnum B = 2;
optional NestedDefinition.NestedMessage C = 3;
}
message NinOptNativeDefault {
option (gogoproto.goproto_getters) = true;
option (gogoproto.face) = false;
optional double Field1 = 1 [default = 1234.1234];
optional float Field2 = 2 [default = 1234.1234];
optional int32 Field3 = 3 [default = 1234];
optional int64 Field4 = 4 [default = 1234];
optional uint32 Field5 = 5 [default = 1234];
optional uint64 Field6 = 6 [default = 1234];
optional sint32 Field7 = 7 [default = 1234];
optional sint64 Field8 = 8 [default = 1234];
optional fixed32 Field9 = 9 [default = 1234];
optional sfixed32 Field10 = 10 [default = 1234];
optional fixed64 Field11 = 11 [default = 1234];
optional sfixed64 Field12 = 12 [default = 1234];
optional bool Field13 = 13 [default = true];
optional string Field14 = 14 [default = "1234"];
optional bytes Field15 = 15;
}
message CustomContainer {
optional NidOptCustom CustomStruct = 1 [(gogoproto.nullable) = false];
}
message CustomNameNidOptNative {
optional double Field1 = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldA"];
optional float Field2 = 2 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldB"];
optional int32 Field3 = 3 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldC"];
optional int64 Field4 = 4 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldD"];
optional uint32 Field5 = 5 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldE"];
optional uint64 Field6 = 6 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldF"];
optional sint32 Field7 = 7 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldG"];
optional sint64 Field8 = 8 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldH"];
optional fixed32 Field9 = 9 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldI"];
optional sfixed32 Field10 = 10 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldJ"];
optional fixed64 Field11 = 11 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldK"];
optional sfixed64 Field12 = 12 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldL"];
optional bool Field13 = 13 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldM"];
optional string Field14 = 14 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldN"];
optional bytes Field15 = 15 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldO"];
}
message CustomNameNinOptNative {
optional double Field1 = 1 [(gogoproto.customname) = "FieldA"];
optional float Field2 = 2 [(gogoproto.customname) = "FieldB"];
optional int32 Field3 = 3 [(gogoproto.customname) = "FieldC"];
optional int64 Field4 = 4 [(gogoproto.customname) = "FieldD"];
optional uint32 Field5 = 5 [(gogoproto.customname) = "FieldE"];
optional uint64 Field6 = 6 [(gogoproto.customname) = "FieldF"];
optional sint32 Field7 = 7 [(gogoproto.customname) = "FieldG"];
optional sint64 Field8 = 8 [(gogoproto.customname) = "FieldH"];
optional fixed32 Field9 = 9 [(gogoproto.customname) = "FieldI"];
optional sfixed32 Field10 = 10 [(gogoproto.customname) = "FieldJ"];
optional fixed64 Field11 = 11 [(gogoproto.customname) = "FieldK"];
optional sfixed64 Field12 = 12 [(gogoproto.customname) = "FielL"];
optional bool Field13 = 13 [(gogoproto.customname) = "FieldM"];
optional string Field14 = 14 [(gogoproto.customname) = "FieldN"];
optional bytes Field15 = 15 [(gogoproto.customname) = "FieldO"];
}
message CustomNameNinRepNative {
repeated double Field1 = 1 [(gogoproto.customname) = "FieldA"];
repeated float Field2 = 2 [(gogoproto.customname) = "FieldB"];
repeated int32 Field3 = 3 [(gogoproto.customname) = "FieldC"];
repeated int64 Field4 = 4 [(gogoproto.customname) = "FieldD"];
repeated uint32 Field5 = 5 [(gogoproto.customname) = "FieldE"];
repeated uint64 Field6 = 6 [(gogoproto.customname) = "FieldF"];
repeated sint32 Field7 = 7 [(gogoproto.customname) = "FieldG"];
repeated sint64 Field8 = 8 [(gogoproto.customname) = "FieldH"];
repeated fixed32 Field9 = 9 [(gogoproto.customname) = "FieldI"];
repeated sfixed32 Field10 = 10 [(gogoproto.customname) = "FieldJ"];
repeated fixed64 Field11 = 11 [(gogoproto.customname) = "FieldK"];
repeated sfixed64 Field12 = 12 [(gogoproto.customname) = "FieldL"];
repeated bool Field13 = 13 [(gogoproto.customname) = "FieldM"];
repeated string Field14 = 14 [(gogoproto.customname) = "FieldN"];
repeated bytes Field15 = 15 [(gogoproto.customname) = "FieldO"];
}
message CustomNameNinStruct {
optional double Field1 = 1 [(gogoproto.customname) = "FieldA"];
optional float Field2 = 2 [(gogoproto.customname) = "FieldB"];
optional NidOptNative Field3 = 3 [(gogoproto.customname) = "FieldC"];
repeated NinOptNative Field4 = 4 [(gogoproto.customname) = "FieldD"];
optional uint64 Field6 = 6 [(gogoproto.customname) = "FieldE"];
optional sint32 Field7 = 7 [(gogoproto.customname) = "FieldF"];
optional NidOptNative Field8 = 8 [(gogoproto.customname) = "FieldG"];
optional bool Field13 = 13 [(gogoproto.customname) = "FieldH"];
optional string Field14 = 14 [(gogoproto.customname) = "FieldI"];
optional bytes Field15 = 15 [(gogoproto.customname) = "FieldJ"];
}
message CustomNameCustomType {
optional bytes Id = 1 [(gogoproto.customname) = "FieldA", (gogoproto.customtype) = "Uuid"];
optional bytes Value = 2 [(gogoproto.customname) = "FieldB", (gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"];
repeated bytes Ids = 3 [(gogoproto.customname) = "FieldC", (gogoproto.customtype) = "Uuid"];
repeated bytes Values = 4 [(gogoproto.customname) = "FieldD", (gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"];
}
message CustomNameNinEmbeddedStructUnion {
option (gogoproto.onlyone) = true;
optional NidOptNative Field1 = 1 [(gogoproto.embed) = true];
optional NinOptNative Field200 = 200 [(gogoproto.customname) = "FieldA"];
optional bool Field210 = 210 [(gogoproto.customname) = "FieldB"];
}
message CustomNameEnum {
optional TheTestEnum Field1 = 1 [(gogoproto.customname) = "FieldA"];
repeated TheTestEnum Field2 = 2 [(gogoproto.customname) = "FieldB"];
}
message NoExtensionsMap {
option (gogoproto.face) = false;
option (gogoproto.goproto_extensions_map) = false;
optional int64 Field1 = 1;
extensions 100 to 199;
}
extend NoExtensionsMap {
optional double FieldA1 = 100;
optional NinOptNative FieldB1 = 101;
optional NinEmbeddedStruct FieldC1 = 102;
}
message Unrecognized {
option (gogoproto.goproto_unrecognized) = false;
optional string Field1 = 1;
}
message UnrecognizedWithInner {
message Inner {
option (gogoproto.goproto_unrecognized) = false;
optional uint32 Field1 = 1;
}
repeated Inner embedded = 1;
optional string Field2 = 2;
}
message UnrecognizedWithEmbed {
message Embedded {
option (gogoproto.goproto_unrecognized) = false;
optional uint32 Field1 = 1;
}
optional Embedded embedded = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false];
optional string Field2 = 2;
}
message Node {
optional string Label = 1;
repeated Node Children = 2;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,133 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package test
import (
"bytes"
"encoding/hex"
"encoding/json"
)
func PutLittleEndianUint64(b []byte, offset int, v uint64) {
b[offset] = byte(v)
b[offset+1] = byte(v >> 8)
b[offset+2] = byte(v >> 16)
b[offset+3] = byte(v >> 24)
b[offset+4] = byte(v >> 32)
b[offset+5] = byte(v >> 40)
b[offset+6] = byte(v >> 48)
b[offset+7] = byte(v >> 56)
}
type Uuid []byte
func (uuid Uuid) Marshal() ([]byte, error) {
if len(uuid) == 0 {
return nil, nil
}
return []byte(uuid), nil
}
func (uuid Uuid) MarshalTo(data []byte) (n int, err error) {
if len(uuid) == 0 {
return 0, nil
}
copy(data, uuid)
return 16, nil
}
func (uuid *Uuid) Unmarshal(data []byte) error {
if len(data) == 0 {
uuid = nil
return nil
}
id := Uuid(make([]byte, 16))
copy(id, data)
*uuid = id
return nil
}
func (uuid *Uuid) Size() int {
if uuid == nil {
return 0
}
if len(*uuid) == 0 {
return 0
}
return 16
}
func (uuid Uuid) MarshalJSON() ([]byte, error) {
s := hex.EncodeToString([]byte(uuid))
return json.Marshal(s)
}
func (uuid *Uuid) UnmarshalJSON(data []byte) error {
var s string
err := json.Unmarshal(data, &s)
if err != nil {
return err
}
d, err := hex.DecodeString(s)
if err != nil {
return err
}
*uuid = Uuid(d)
return nil
}
func (uuid Uuid) Equal(other Uuid) bool {
return bytes.Equal(uuid[0:], other[0:])
}
func (uuid Uuid) Compare(other Uuid) int {
return bytes.Compare(uuid[0:], other[0:])
}
type int63 interface {
Int63() int64
}
func NewPopulatedUuid(r int63) *Uuid {
u := RandV4(r)
return &u
}
func RandV4(r int63) Uuid {
uuid := make(Uuid, 16)
uuid.RandV4(r)
return uuid
}
func (uuid Uuid) RandV4(r int63) {
PutLittleEndianUint64(uuid, 0, uint64(r.Int63()))
PutLittleEndianUint64(uuid, 8, uint64(r.Int63()))
uuid[6] = (uuid[6] & 0xf) | 0x40
uuid[8] = (uuid[8] & 0x3f) | 0x80
}

View file

@ -0,0 +1,252 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package test
import (
"fmt"
"math"
"math/rand"
"testing"
"time"
"github.com/gogo/protobuf/proto"
)
//http://code.google.com/p/goprotobuf/issues/detail?id=39
func TestBugUint32VarintSize(t *testing.T) {
temp := uint32(math.MaxUint32)
n := &NinOptNative{}
n.Field5 = &temp
data, err := proto.Marshal(n)
if err != nil {
panic(err)
}
if len(data) != 6 {
t.Fatalf("data should be length 6, but its %#v", data)
}
}
func TestBugZeroLengthSliceSize(t *testing.T) {
n := &NinRepPackedNative{
Field8: []int64{},
}
size := n.Size()
data, err := proto.Marshal(n)
if err != nil {
panic(err)
}
if len(data) != size {
t.Fatalf("expected %v, but got %v", len(data), size)
}
}
//http://code.google.com/p/goprotobuf/issues/detail?id=40
func TestBugPackedProtoSize(t *testing.T) {
n := &NinRepPackedNative{
Field4: []int64{172960727389894724, 2360337516664475010, 860833876131988189, 9068073014890763245, 7794843386260381831, 4023536436053141786, 8992311247496919020, 4330096163611305776, 4490411416244976467, 7873947349172707443, 2754969595834279669, 1360667855926938684, 4771480785172657389, 4875578924966668055, 8070579869808877481, 9128179594766551001, 4630419407064527516, 863844540220372892, 8208727650143073487, 7086117356301045838, 7779695211931506151, 5493835345187563535, 9119767633370806007, 9054342025895349248, 1887303228838508438, 7624573031734528281, 1874668389749611225, 3517684643468970593, 6677697606628877758, 7293473953189936168, 444475066704085538, 8594971141363049302, 1146643249094989673, 733393306232853371, 7721178528893916886, 7784452000911004429, 6436373110242711440, 6897422461738321237, 8772249155667732778, 6211871464311393541, 3061903718310406883, 7845488913176136641, 8342255034663902574, 3443058984649725748, 8410801047334832902, 7496541071517841153, 4305416923521577765, 7814967600020476457, 8671843803465481186, 3490266370361096855, 1447425664719091336, 653218597262334239, 8306243902880091940, 7851896059762409081, 5936760560798954978, 5755724498441478025, 7022701569985035966, 3707709584811468220, 529069456924666920, 7986469043681522462, 3092513330689518836, 5103541550470476202, 3577384161242626406, 3733428084624703294, 8388690542440473117, 3262468785346149388, 8788358556558007570, 5476276940198542020, 7277903243119461239, 5065861426928605020, 7533460976202697734, 1749213838654236956, 557497603941617931, 5496307611456481108, 6444547750062831720, 6992758776744205596, 7356719693428537399, 2896328872476734507, 381447079530132038, 598300737753233118, 3687980626612697715, 7240924191084283349, 8172414415307971170, 4847024388701257185, 2081764168600256551, 3394217778539123488, 6244660626429310923, 8301712215675381614, 5360615125359461174, 8410140945829785773, 3152963269026381373, 6197275282781459633, 4419829061407546410, 6262035523070047537, 2837207483933463885, 2158105736666826128, 8150764172235490711},
Field7: []int32{249451845, 1409974015, 393609128, 435232428, 1817529040, 91769006, 861170933, 1556185603, 1568580279, 1236375273, 512276621, 693633711, 967580535, 1950715977, 853431462, 1362390253, 159591204, 111900629, 322985263, 279671129, 1592548430, 465651370, 733849989, 1172059400, 1574824441, 263541092, 1271612397, 1520584358, 467078791, 117698716, 1098255064, 2054264846, 1766452305, 1267576395, 1557505617, 1187833560, 956187431, 1970977586, 1160235159, 1610259028, 489585797, 459139078, 566263183, 954319278, 1545018565, 1753946743, 948214318, 422878159, 883926576, 1424009347, 824732372, 1290433180, 80297942, 417294230, 1402647904, 2078392782, 220505045, 787368129, 463781454, 293083578, 808156928, 293976361},
Field9: []uint32{0xaa4976e8, 0x3da8cc4c, 0x8c470d83, 0x344d964e, 0x5b90925, 0xa4c4d34e, 0x666eff19, 0xc238e552, 0x9be53bb6, 0x56364245, 0x33ee079d, 0x96bf0ede, 0x7941b74f, 0xdb07cb47, 0x6d76d827, 0x9b211d5d, 0x2798adb6, 0xe48b0c3b, 0x87061b21, 0x48f4e4d2, 0x3e5d5c12, 0x5ee91288, 0x336d4f35, 0xe1d44941, 0xc065548d, 0x2953d73f, 0x873af451, 0xfc769db, 0x9f1bf8da, 0x9baafdfc, 0xf1d3d770, 0x5bb5d2b4, 0xc2c67c48, 0x6845c4c1, 0xa48f32b0, 0xbb04bb70, 0xa5b1ca36, 0x8d98356a, 0x2171f654, 0x5ae279b0, 0x6c4a3d6b, 0x4fff5468, 0xcf9bf851, 0x68513614, 0xdbecd9b0, 0x9553ed3c, 0xa494a736, 0x42205438, 0xbf8e5caa, 0xd3283c6, 0x76d20788, 0x9179826f, 0x96b24f85, 0xbc2eacf4, 0xe4afae0b, 0x4bca85cb, 0x35e63b5b, 0xd7ccee0c, 0x2b506bb9, 0xe78e9f44, 0x9ad232f1, 0x99a37335, 0xa5d6ffc8},
Field11: []uint64{0x53c01ebc, 0x4fb85ba6, 0x8805eea1, 0xb20ec896, 0x93b63410, 0xec7c9492, 0x50765a28, 0x19592106, 0x2ecc59b3, 0x39cd474f, 0xe4c9e47, 0x444f48c5, 0xe7731d32, 0xf3f43975, 0x603caedd, 0xbb05a1af, 0xa808e34e, 0x88580b07, 0x4c96bbd1, 0x730b4ab9, 0xed126e2b, 0x6db48205, 0x154ba1b9, 0xc26bfb6a, 0x389aa052, 0x869d966c, 0x7c86b366, 0xcc8edbcd, 0xfa8d6dad, 0xcf5857d9, 0x2d9cda0f, 0x1218a0b8, 0x41bf997, 0xf0ca65ac, 0xa610d4b9, 0x8d362e28, 0xb7212d87, 0x8e0fe109, 0xbee041d9, 0x759be2f6, 0x35fef4f3, 0xaeacdb71, 0x10888852, 0xf4e28117, 0xe2a14812, 0x73b748dc, 0xd1c3c6b2, 0xfef41bf0, 0xc9b43b62, 0x810e4faa, 0xcaa41c06, 0x1893fe0d, 0xedc7c850, 0xd12b9eaa, 0x467ee1a9, 0xbe84756b, 0xda7b1680, 0xdc069ffe, 0xf1e7e9f9, 0xb3d95370, 0xa92b77df, 0x5693ac41, 0xd04b7287, 0x27aebf15, 0x837b316e, 0x4dbe2263, 0xbab70c67, 0x547dab21, 0x3c346c1f, 0xb8ef0e4e, 0xfe2d03ce, 0xe1d75955, 0xfec1306, 0xba35c23e, 0xb784ed04, 0x2a4e33aa, 0x7e19d09a, 0x3827c1fe, 0xf3a51561, 0xef765e2b, 0xb044256c, 0x62b322be, 0xf34d56be, 0xeb71b369, 0xffe1294f, 0x237fe8d0, 0x77a1473b, 0x239e1196, 0xdd19bf3d, 0x82c91fe1, 0x95361c57, 0xffea3f1b, 0x1a094c84},
Field12: []int64{8308420747267165049, 3664160795077875961, 7868970059161834817, 7237335984251173739, 5254748003907196506, 3362259627111837480, 430460752854552122, 5119635556501066533, 1277716037866233522, 9185775384759813768, 833932430882717888, 7986528304451297640, 6792233378368656337, 2074207091120609721, 1788723326198279432, 7756514594746453657, 2283775964901597324, 3061497730110517191, 7733947890656120277, 626967303632386244, 7822928600388582821, 3489658753000061230, 168869995163005961, 248814782163480763, 477885608911386247, 4198422415674133867, 3379354662797976109, 9925112544736939, 1486335136459138480, 4561560414032850671, 1010864164014091267, 186722821683803084, 5106357936724819318, 1298160820191228988, 4675403242419953145, 7130634540106489752, 7101280006672440929, 7176058292431955718, 9109875054097770321, 6810974877085322872, 4736707874303993641, 8993135362721382187, 6857881554990254283, 3704748883307461680, 1099360832887634994, 5207691918707192633, 5984721695043995243},
}
size := proto.Size(n)
data, err := proto.Marshal(n)
if err != nil {
panic(err)
}
if len(data) != size {
t.Fatalf("expected %v, but got %v diff is %v", len(data), size, len(data)-size)
}
}
func testSize(m interface {
proto.Message
Size() int
}, desc string, expected int) ([]byte, error) {
data, err := proto.Marshal(m)
if err != nil {
return nil, err
}
protoSize := proto.Size(m)
mSize := m.Size()
lenData := len(data)
if protoSize != mSize || protoSize != lenData || mSize != lenData {
return nil, fmt.Errorf("%s proto.Size(m){%d} != m.Size(){%d} != len(data){%d}", desc, protoSize, mSize, lenData)
}
if got := protoSize; got != expected {
return nil, fmt.Errorf("%s proto.Size(m) got %d expected %d", desc, got, expected)
}
if got := mSize; got != expected {
return nil, fmt.Errorf("%s m.Size() got %d expected %d", desc, got, expected)
}
if got := lenData; got != expected {
return nil, fmt.Errorf("%s len(data) got %d expected %d", desc, got, expected)
}
return data, nil
}
func TestInt32Int64Compatibility(t *testing.T) {
//test nullable int32 and int64
data1, err := testSize(&NinOptNative{
Field3: proto.Int32(-1),
}, "nullable", 11)
if err != nil {
t.Error(err)
}
//change marshaled data1 to unmarshal into 4th field which is an int64
data1[0] = uint8(uint32(4 /*fieldNumber*/)<<3 | uint32(0 /*wireType*/))
u1 := &NinOptNative{}
if err = proto.Unmarshal(data1, u1); err != nil {
t.Error(err)
}
if !u1.Equal(&NinOptNative{
Field4: proto.Int64(-1),
}) {
t.Error("nullable unmarshaled int32 is not the same int64")
}
//test non-nullable int32 and int64
data2, err := testSize(&NidOptNative{
Field3: -1,
}, "non nullable", 67)
if err != nil {
t.Error(err)
}
//change marshaled data2 to unmarshal into 4th field which is an int64
field3 := uint8(uint32(3 /*fieldNumber*/)<<3 | uint32(0 /*wireType*/))
field4 := uint8(uint32(4 /*fieldNumber*/)<<3 | uint32(0 /*wireType*/))
for i, c := range data2 {
if c == field4 {
data2[i] = field3
} else if c == field3 {
data2[i] = field4
}
}
u2 := &NidOptNative{}
if err = proto.Unmarshal(data2, u2); err != nil {
t.Error(err)
}
if !u2.Equal(&NidOptNative{
Field4: -1,
}) {
t.Error("non nullable unmarshaled int32 is not the same int64")
}
//test packed repeated int32 and int64
m4 := &NinRepPackedNative{
Field3: []int32{-1},
}
data4, err := testSize(m4, "packed", 12)
if err != nil {
t.Error(err)
}
u4 := &NinRepPackedNative{}
if err := proto.Unmarshal(data4, u4); err != nil {
t.Error(err)
}
if err := u4.VerboseEqual(m4); err != nil {
t.Fatalf("%#v", u4)
}
//test repeated int32 and int64
if _, err := testSize(&NinRepNative{
Field3: []int32{-1},
}, "repeated", 11); err != nil {
t.Error(err)
}
t.Logf("tested all")
}
func TestRepeatedExtensionsMsgsIssue161(t *testing.T) {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
rep := 10
nins := make([]*NinOptNative, rep)
for i := range nins {
nins[i] = NewPopulatedNinOptNative(r, true)
}
input := &MyExtendable{}
if err := proto.SetExtension(input, E_FieldE, nins); err != nil {
t.Fatal(err)
}
data, err := proto.Marshal(input)
if err != nil {
t.Fatal(err)
}
output := &MyExtendable{}
if err := proto.Unmarshal(data, output); err != nil {
t.Fatal(err)
}
if !input.Equal(output) {
t.Fatal("expected equal")
}
data2, err2 := proto.Marshal(output)
if err2 != nil {
t.Fatal(err2)
}
if len(data) != len(data2) {
t.Fatal("expected equal length buffers")
}
}
func TestRepeatedExtensionsFieldsIssue161(t *testing.T) {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
rep := 10
ints := make([]int64, rep)
for i := range ints {
ints[i] = r.Int63()
}
input := &MyExtendable{}
if err := proto.SetExtension(input, E_FieldD, ints); err != nil {
t.Fatal(err)
}
data, err := proto.Marshal(input)
if err != nil {
t.Fatal(err)
}
output := &MyExtendable{}
if err := proto.Unmarshal(data, output); err != nil {
t.Fatal(err)
}
if !input.Equal(output) {
t.Fatal("expected equal")
}
data2, err2 := proto.Marshal(output)
if err2 != nil {
t.Fatal(err2)
}
if len(data) != len(data2) {
t.Fatal("expected equal length buffers")
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,626 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package test;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.goproto_enum_prefix_all) = false;
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
option (gogoproto.stringer_all) = true;
option (gogoproto.gostring_all) = true;
option (gogoproto.face_all) = true;
option (gogoproto.description_all) = true;
option (gogoproto.testgen_all) = true;
option (gogoproto.populate_all) = true;
option (gogoproto.benchgen_all) = true;
option (gogoproto.unmarshaler_all) = false;
option (gogoproto.marshaler_all) = false;
option (gogoproto.sizer_all) = true;
option (gogoproto.protosizer_all) = false;
option (gogoproto.goproto_enum_stringer_all) = false;
option (gogoproto.enum_stringer_all) = true;
option (gogoproto.unsafe_marshaler_all) = true;
option (gogoproto.unsafe_unmarshaler_all) = true;
option (gogoproto.compare_all) = true;
message NidOptNative {
optional double Field1 = 1 [(gogoproto.nullable) = false];
optional float Field2 = 2 [(gogoproto.nullable) = false];
optional int32 Field3 = 3 [(gogoproto.nullable) = false];
optional int64 Field4 = 4 [(gogoproto.nullable) = false];
optional uint32 Field5 = 5 [(gogoproto.nullable) = false];
optional uint64 Field6 = 6 [(gogoproto.nullable) = false];
optional sint32 Field7 = 7 [(gogoproto.nullable) = false];
optional sint64 Field8 = 8 [(gogoproto.nullable) = false];
optional fixed32 Field9 = 9 [(gogoproto.nullable) = false];
optional sfixed32 Field10 = 10 [(gogoproto.nullable) = false];
optional fixed64 Field11 = 11 [(gogoproto.nullable) = false];
optional sfixed64 Field12 = 12 [(gogoproto.nullable) = false];
optional bool Field13 = 13 [(gogoproto.nullable) = false];
optional string Field14 = 14 [(gogoproto.nullable) = false];
optional bytes Field15 = 15 [(gogoproto.nullable) = false];
}
message NinOptNative {
optional double Field1 = 1;
optional float Field2 = 2;
optional int32 Field3 = 3;
optional int64 Field4 = 4;
optional uint32 Field5 = 5;
optional uint64 Field6 = 6;
optional sint32 Field7 = 7;
optional sint64 Field8 = 8;
optional fixed32 Field9 = 9;
optional sfixed32 Field10 = 10;
optional fixed64 Field11 = 11;
optional sfixed64 Field12 = 12;
optional bool Field13 = 13;
optional string Field14 = 14;
optional bytes Field15 = 15;
}
message NidRepNative {
repeated double Field1 = 1 [(gogoproto.nullable) = false];
repeated float Field2 = 2 [(gogoproto.nullable) = false];
repeated int32 Field3 = 3 [(gogoproto.nullable) = false];
repeated int64 Field4 = 4 [(gogoproto.nullable) = false];
repeated uint32 Field5 = 5 [(gogoproto.nullable) = false];
repeated uint64 Field6 = 6 [(gogoproto.nullable) = false];
repeated sint32 Field7 = 7 [(gogoproto.nullable) = false];
repeated sint64 Field8 = 8 [(gogoproto.nullable) = false];
repeated fixed32 Field9 = 9 [(gogoproto.nullable) = false];
repeated sfixed32 Field10 = 10 [(gogoproto.nullable) = false];
repeated fixed64 Field11 = 11 [(gogoproto.nullable) = false];
repeated sfixed64 Field12 = 12 [(gogoproto.nullable) = false];
repeated bool Field13 = 13 [(gogoproto.nullable) = false];
repeated string Field14 = 14 [(gogoproto.nullable) = false];
repeated bytes Field15 = 15 [(gogoproto.nullable) = false];
}
message NinRepNative {
repeated double Field1 = 1;
repeated float Field2 = 2;
repeated int32 Field3 = 3;
repeated int64 Field4 = 4;
repeated uint32 Field5 = 5;
repeated uint64 Field6 = 6;
repeated sint32 Field7 = 7;
repeated sint64 Field8 = 8;
repeated fixed32 Field9 = 9;
repeated sfixed32 Field10 = 10;
repeated fixed64 Field11 = 11;
repeated sfixed64 Field12 = 12;
repeated bool Field13 = 13;
repeated string Field14 = 14;
repeated bytes Field15 = 15;
}
message NidRepPackedNative {
repeated double Field1 = 1 [(gogoproto.nullable) = false, packed = true];
repeated float Field2 = 2 [(gogoproto.nullable) = false, packed = true];
repeated int32 Field3 = 3 [(gogoproto.nullable) = false, packed = true];
repeated int64 Field4 = 4 [(gogoproto.nullable) = false, packed = true];
repeated uint32 Field5 = 5 [(gogoproto.nullable) = false, packed = true];
repeated uint64 Field6 = 6 [(gogoproto.nullable) = false, packed = true];
repeated sint32 Field7 = 7 [(gogoproto.nullable) = false, packed = true];
repeated sint64 Field8 = 8 [(gogoproto.nullable) = false, packed = true];
repeated fixed32 Field9 = 9 [(gogoproto.nullable) = false, packed = true];
repeated sfixed32 Field10 = 10 [(gogoproto.nullable) = false, packed = true];
repeated fixed64 Field11 = 11 [(gogoproto.nullable) = false, packed = true];
repeated sfixed64 Field12 = 12 [(gogoproto.nullable) = false, packed = true];
repeated bool Field13 = 13 [(gogoproto.nullable) = false, packed = true];
}
message NinRepPackedNative {
repeated double Field1 = 1 [packed = true];
repeated float Field2 = 2 [packed = true];
repeated int32 Field3 = 3 [packed = true];
repeated int64 Field4 = 4 [packed = true];
repeated uint32 Field5 = 5 [packed = true];
repeated uint64 Field6 = 6 [packed = true];
repeated sint32 Field7 = 7 [packed = true];
repeated sint64 Field8 = 8 [packed = true];
repeated fixed32 Field9 = 9 [packed = true];
repeated sfixed32 Field10 = 10 [packed = true];
repeated fixed64 Field11 = 11 [packed = true];
repeated sfixed64 Field12 = 12 [packed = true];
repeated bool Field13 = 13 [packed = true];
}
message NidOptStruct {
optional double Field1 = 1 [(gogoproto.nullable) = false];
optional float Field2 = 2 [(gogoproto.nullable) = false];
optional NidOptNative Field3 = 3 [(gogoproto.nullable) = false];
optional NinOptNative Field4 = 4 [(gogoproto.nullable) = false];
optional uint64 Field6 = 6 [(gogoproto.nullable) = false];
optional sint32 Field7 = 7 [(gogoproto.nullable) = false];
optional NidOptNative Field8 = 8 [(gogoproto.nullable) = false];
optional bool Field13 = 13 [(gogoproto.nullable) = false];
optional string Field14 = 14 [(gogoproto.nullable) = false];
optional bytes Field15 = 15 [(gogoproto.nullable) = false];
}
message NinOptStruct {
optional double Field1 = 1;
optional float Field2 = 2;
optional NidOptNative Field3 = 3;
optional NinOptNative Field4 = 4;
optional uint64 Field6 = 6;
optional sint32 Field7 = 7;
optional NidOptNative Field8 = 8;
optional bool Field13 = 13;
optional string Field14 = 14;
optional bytes Field15 = 15;
}
message NidRepStruct {
repeated double Field1 = 1 [(gogoproto.nullable) = false];
repeated float Field2 = 2 [(gogoproto.nullable) = false];
repeated NidOptNative Field3 = 3 [(gogoproto.nullable) = false];
repeated NinOptNative Field4 = 4 [(gogoproto.nullable) = false];
repeated uint64 Field6 = 6 [(gogoproto.nullable) = false];
repeated sint32 Field7 = 7 [(gogoproto.nullable) = false];
repeated NidOptNative Field8 = 8 [(gogoproto.nullable) = false];
repeated bool Field13 = 13 [(gogoproto.nullable) = false];
repeated string Field14 = 14 [(gogoproto.nullable) = false];
repeated bytes Field15 = 15 [(gogoproto.nullable) = false];
}
message NinRepStruct {
repeated double Field1 = 1;
repeated float Field2 = 2;
repeated NidOptNative Field3 = 3;
repeated NinOptNative Field4 = 4;
repeated uint64 Field6 = 6;
repeated sint32 Field7 = 7;
repeated NidOptNative Field8 = 8;
repeated bool Field13 = 13;
repeated string Field14 = 14;
repeated bytes Field15 = 15;
}
message NidEmbeddedStruct {
optional NidOptNative Field1 = 1 [(gogoproto.embed) = true];
optional NidOptNative Field200 = 200 [(gogoproto.nullable) = false];
optional bool Field210 = 210 [(gogoproto.nullable) = false];
}
message NinEmbeddedStruct {
optional NidOptNative Field1 = 1 [(gogoproto.embed) = true];
optional NidOptNative Field200 = 200;
optional bool Field210 = 210;
}
message NidNestedStruct {
optional NidOptStruct Field1 = 1 [(gogoproto.nullable) = false];
repeated NidRepStruct Field2 = 2 [(gogoproto.nullable) = false];
}
message NinNestedStruct {
optional NinOptStruct Field1 = 1;
repeated NinRepStruct Field2 = 2;
}
message NidOptCustom {
optional bytes Id = 1 [(gogoproto.customtype) = "Uuid", (gogoproto.nullable) = false];
optional bytes Value = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128", (gogoproto.nullable) = false];
}
message CustomDash {
optional bytes Value = 1 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom-dash-type.Bytes"];
}
message NinOptCustom {
optional bytes Id = 1 [(gogoproto.customtype) = "Uuid"];
optional bytes Value = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"];
}
message NidRepCustom {
repeated bytes Id = 1 [(gogoproto.customtype) = "Uuid", (gogoproto.nullable) = false];
repeated bytes Value = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128", (gogoproto.nullable) = false];
}
message NinRepCustom {
repeated bytes Id = 1 [(gogoproto.customtype) = "Uuid"];
repeated bytes Value = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"];
}
message NinOptNativeUnion {
option (gogoproto.onlyone) = true;
optional double Field1 = 1;
optional float Field2 = 2;
optional int32 Field3 = 3;
optional int64 Field4 = 4;
optional uint32 Field5 = 5;
optional uint64 Field6 = 6;
optional bool Field13 = 13;
optional string Field14 = 14;
optional bytes Field15 = 15;
}
message NinOptStructUnion {
option (gogoproto.onlyone) = true;
optional double Field1 = 1;
optional float Field2 = 2;
optional NidOptNative Field3 = 3;
optional NinOptNative Field4 = 4;
optional uint64 Field6 = 6;
optional sint32 Field7 = 7;
optional bool Field13 = 13;
optional string Field14 = 14;
optional bytes Field15 = 15;
}
message NinEmbeddedStructUnion {
option (gogoproto.onlyone) = true;
optional NidOptNative Field1 = 1 [(gogoproto.embed) = true];
optional NinOptNative Field200 = 200;
optional bool Field210 = 210;
}
message NinNestedStructUnion {
option (gogoproto.onlyone) = true;
optional NinOptNativeUnion Field1 = 1;
optional NinOptStructUnion Field2 = 2;
optional NinEmbeddedStructUnion Field3 = 3;
}
message Tree {
option (gogoproto.onlyone) = true;
optional OrBranch Or = 1;
optional AndBranch And = 2;
optional Leaf Leaf = 3;
}
message OrBranch {
optional Tree Left = 1 [(gogoproto.nullable) = false];
optional Tree Right = 2 [(gogoproto.nullable) = false];
}
message AndBranch {
optional Tree Left = 1 [(gogoproto.nullable) = false];
optional Tree Right = 2 [(gogoproto.nullable) = false];
}
message Leaf {
optional int64 Value = 1 [(gogoproto.nullable) = false];
optional string StrValue = 2 [(gogoproto.nullable) = false];
}
message DeepTree {
option (gogoproto.onlyone) = true;
optional ADeepBranch Down = 1;
optional AndDeepBranch And = 2;
optional DeepLeaf Leaf = 3;
}
message ADeepBranch {
optional DeepTree Down = 2 [(gogoproto.nullable) = false];
}
message AndDeepBranch {
optional DeepTree Left = 1 [(gogoproto.nullable) = false];
optional DeepTree Right = 2 [(gogoproto.nullable) = false];
}
message DeepLeaf {
optional Tree Tree = 1 [(gogoproto.nullable) = false];
}
message Nil {
}
enum TheTestEnum {
A = 0;
B = 1;
C = 2;
}
enum AnotherTestEnum {
option (gogoproto.goproto_enum_prefix) = false;
D = 10;
E = 11;
}
// YetAnotherTestEnum is used to test cross-package import of custom name
// fields and default resolution.
enum YetAnotherTestEnum {
option (gogoproto.goproto_enum_prefix) = false;
AA = 0;
BB = 1 [(gogoproto.enumvalue_customname) = "BetterYetBB"];
}
// YetAnotherTestEnum is used to test cross-package import of custom name
// fields and default resolution.
enum YetYetAnotherTestEnum {
option (gogoproto.goproto_enum_prefix) = true;
CC = 0;
DD = 1 [(gogoproto.enumvalue_customname) = "BetterYetDD"];
}
message NidOptEnum {
optional TheTestEnum Field1 = 1 [(gogoproto.nullable) = false];
}
message NinOptEnum {
optional TheTestEnum Field1 = 1;
optional YetAnotherTestEnum Field2 = 2;
optional YetYetAnotherTestEnum Field3 = 3;
}
message NidRepEnum {
repeated TheTestEnum Field1 = 1 [(gogoproto.nullable) = false];
repeated YetAnotherTestEnum Field2 = 2 [(gogoproto.nullable) = false];
repeated YetYetAnotherTestEnum Field3 = 3 [(gogoproto.nullable) = false];
}
message NinRepEnum {
repeated TheTestEnum Field1 = 1;
repeated YetAnotherTestEnum Field2 = 2;
repeated YetYetAnotherTestEnum Field3 = 3;
}
message NinOptEnumDefault {
option (gogoproto.goproto_getters) = true;
option (gogoproto.face) = false;
optional TheTestEnum Field1 = 1 [default=C];
optional YetAnotherTestEnum Field2 = 2 [default=BB];
optional YetYetAnotherTestEnum Field3 = 3 [default=CC];
}
message AnotherNinOptEnum {
optional AnotherTestEnum Field1 = 1;
optional YetAnotherTestEnum Field2 = 2;
optional YetYetAnotherTestEnum Field3 = 3;
}
message AnotherNinOptEnumDefault {
option (gogoproto.goproto_getters) = true;
option (gogoproto.face) = false;
optional AnotherTestEnum Field1 = 1 [default=E];
optional YetAnotherTestEnum Field2 = 2 [default=BB];
optional YetYetAnotherTestEnum Field3 = 3 [default=CC];
}
message Timer {
optional sfixed64 Time1 = 1 [(gogoproto.nullable) = false];
optional sfixed64 Time2 = 2 [(gogoproto.nullable) = false];
optional bytes Data = 3 [(gogoproto.nullable) = false];
}
message MyExtendable {
option (gogoproto.face) = false;
optional int64 Field1 = 1;
extensions 100 to 199;
}
extend MyExtendable {
optional double FieldA = 100;
optional NinOptNative FieldB = 101;
optional NinEmbeddedStruct FieldC = 102;
repeated int64 FieldD = 104;
repeated NinOptNative FieldE = 105;
}
message OtherExtenable {
option (gogoproto.face) = false;
optional int64 Field2 = 2;
extensions 14 to 16;
optional int64 Field13 = 13;
extensions 10 to 12;
optional MyExtendable M = 1;
}
message NestedDefinition {
optional int64 Field1 = 1;
message NestedMessage {
optional fixed64 NestedField1 = 1;
optional NestedNestedMsg NNM = 2;
message NestedNestedMsg {
optional string NestedNestedField1 = 10;
}
}
enum NestedEnum {
TYPE_NESTED = 1;
}
optional NestedEnum EnumField = 2;
optional NestedMessage.NestedNestedMsg NNM = 3;
optional NestedMessage NM = 4;
}
message NestedScope {
optional NestedDefinition.NestedMessage.NestedNestedMsg A = 1;
optional NestedDefinition.NestedEnum B = 2;
optional NestedDefinition.NestedMessage C = 3;
}
message NinOptNativeDefault {
option (gogoproto.goproto_getters) = true;
option (gogoproto.face) = false;
optional double Field1 = 1 [default = 1234.1234];
optional float Field2 = 2 [default = 1234.1234];
optional int32 Field3 = 3 [default = 1234];
optional int64 Field4 = 4 [default = 1234];
optional uint32 Field5 = 5 [default = 1234];
optional uint64 Field6 = 6 [default = 1234];
optional sint32 Field7 = 7 [default = 1234];
optional sint64 Field8 = 8 [default = 1234];
optional fixed32 Field9 = 9 [default = 1234];
optional sfixed32 Field10 = 10 [default = 1234];
optional fixed64 Field11 = 11 [default = 1234];
optional sfixed64 Field12 = 12 [default = 1234];
optional bool Field13 = 13 [default = true];
optional string Field14 = 14 [default = "1234"];
optional bytes Field15 = 15;
}
message CustomContainer {
optional NidOptCustom CustomStruct = 1 [(gogoproto.nullable) = false];
}
message CustomNameNidOptNative {
optional double Field1 = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldA"];
optional float Field2 = 2 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldB"];
optional int32 Field3 = 3 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldC"];
optional int64 Field4 = 4 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldD"];
optional uint32 Field5 = 5 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldE"];
optional uint64 Field6 = 6 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldF"];
optional sint32 Field7 = 7 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldG"];
optional sint64 Field8 = 8 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldH"];
optional fixed32 Field9 = 9 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldI"];
optional sfixed32 Field10 = 10 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldJ"];
optional fixed64 Field11 = 11 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldK"];
optional sfixed64 Field12 = 12 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldL"];
optional bool Field13 = 13 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldM"];
optional string Field14 = 14 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldN"];
optional bytes Field15 = 15 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldO"];
}
message CustomNameNinOptNative {
optional double Field1 = 1 [(gogoproto.customname) = "FieldA"];
optional float Field2 = 2 [(gogoproto.customname) = "FieldB"];
optional int32 Field3 = 3 [(gogoproto.customname) = "FieldC"];
optional int64 Field4 = 4 [(gogoproto.customname) = "FieldD"];
optional uint32 Field5 = 5 [(gogoproto.customname) = "FieldE"];
optional uint64 Field6 = 6 [(gogoproto.customname) = "FieldF"];
optional sint32 Field7 = 7 [(gogoproto.customname) = "FieldG"];
optional sint64 Field8 = 8 [(gogoproto.customname) = "FieldH"];
optional fixed32 Field9 = 9 [(gogoproto.customname) = "FieldI"];
optional sfixed32 Field10 = 10 [(gogoproto.customname) = "FieldJ"];
optional fixed64 Field11 = 11 [(gogoproto.customname) = "FieldK"];
optional sfixed64 Field12 = 12 [(gogoproto.customname) = "FielL"];
optional bool Field13 = 13 [(gogoproto.customname) = "FieldM"];
optional string Field14 = 14 [(gogoproto.customname) = "FieldN"];
optional bytes Field15 = 15 [(gogoproto.customname) = "FieldO"];
}
message CustomNameNinRepNative {
repeated double Field1 = 1 [(gogoproto.customname) = "FieldA"];
repeated float Field2 = 2 [(gogoproto.customname) = "FieldB"];
repeated int32 Field3 = 3 [(gogoproto.customname) = "FieldC"];
repeated int64 Field4 = 4 [(gogoproto.customname) = "FieldD"];
repeated uint32 Field5 = 5 [(gogoproto.customname) = "FieldE"];
repeated uint64 Field6 = 6 [(gogoproto.customname) = "FieldF"];
repeated sint32 Field7 = 7 [(gogoproto.customname) = "FieldG"];
repeated sint64 Field8 = 8 [(gogoproto.customname) = "FieldH"];
repeated fixed32 Field9 = 9 [(gogoproto.customname) = "FieldI"];
repeated sfixed32 Field10 = 10 [(gogoproto.customname) = "FieldJ"];
repeated fixed64 Field11 = 11 [(gogoproto.customname) = "FieldK"];
repeated sfixed64 Field12 = 12 [(gogoproto.customname) = "FieldL"];
repeated bool Field13 = 13 [(gogoproto.customname) = "FieldM"];
repeated string Field14 = 14 [(gogoproto.customname) = "FieldN"];
repeated bytes Field15 = 15 [(gogoproto.customname) = "FieldO"];
}
message CustomNameNinStruct {
optional double Field1 = 1 [(gogoproto.customname) = "FieldA"];
optional float Field2 = 2 [(gogoproto.customname) = "FieldB"];
optional NidOptNative Field3 = 3 [(gogoproto.customname) = "FieldC"];
repeated NinOptNative Field4 = 4 [(gogoproto.customname) = "FieldD"];
optional uint64 Field6 = 6 [(gogoproto.customname) = "FieldE"];
optional sint32 Field7 = 7 [(gogoproto.customname) = "FieldF"];
optional NidOptNative Field8 = 8 [(gogoproto.customname) = "FieldG"];
optional bool Field13 = 13 [(gogoproto.customname) = "FieldH"];
optional string Field14 = 14 [(gogoproto.customname) = "FieldI"];
optional bytes Field15 = 15 [(gogoproto.customname) = "FieldJ"];
}
message CustomNameCustomType {
optional bytes Id = 1 [(gogoproto.customname) = "FieldA", (gogoproto.customtype) = "Uuid"];
optional bytes Value = 2 [(gogoproto.customname) = "FieldB", (gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"];
repeated bytes Ids = 3 [(gogoproto.customname) = "FieldC", (gogoproto.customtype) = "Uuid"];
repeated bytes Values = 4 [(gogoproto.customname) = "FieldD", (gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"];
}
message CustomNameNinEmbeddedStructUnion {
option (gogoproto.onlyone) = true;
optional NidOptNative Field1 = 1 [(gogoproto.embed) = true];
optional NinOptNative Field200 = 200 [(gogoproto.customname) = "FieldA"];
optional bool Field210 = 210 [(gogoproto.customname) = "FieldB"];
}
message CustomNameEnum {
optional TheTestEnum Field1 = 1 [(gogoproto.customname) = "FieldA"];
repeated TheTestEnum Field2 = 2 [(gogoproto.customname) = "FieldB"];
}
message NoExtensionsMap {
option (gogoproto.face) = false;
option (gogoproto.goproto_extensions_map) = false;
optional int64 Field1 = 1;
extensions 100 to 199;
}
extend NoExtensionsMap {
optional double FieldA1 = 100;
optional NinOptNative FieldB1 = 101;
optional NinEmbeddedStruct FieldC1 = 102;
}
message Unrecognized {
option (gogoproto.goproto_unrecognized) = false;
optional string Field1 = 1;
}
message UnrecognizedWithInner {
message Inner {
option (gogoproto.goproto_unrecognized) = false;
optional uint32 Field1 = 1;
}
repeated Inner embedded = 1;
optional string Field2 = 2;
}
message UnrecognizedWithEmbed {
message Embedded {
option (gogoproto.goproto_unrecognized) = false;
optional uint32 Field1 = 1;
}
optional Embedded embedded = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false];
optional string Field2 = 2;
}
message Node {
optional string Label = 1;
repeated Node Children = 2;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,133 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package test
import (
"bytes"
"encoding/hex"
"encoding/json"
)
func PutLittleEndianUint64(b []byte, offset int, v uint64) {
b[offset] = byte(v)
b[offset+1] = byte(v >> 8)
b[offset+2] = byte(v >> 16)
b[offset+3] = byte(v >> 24)
b[offset+4] = byte(v >> 32)
b[offset+5] = byte(v >> 40)
b[offset+6] = byte(v >> 48)
b[offset+7] = byte(v >> 56)
}
type Uuid []byte
func (uuid Uuid) Marshal() ([]byte, error) {
if len(uuid) == 0 {
return nil, nil
}
return []byte(uuid), nil
}
func (uuid Uuid) MarshalTo(data []byte) (n int, err error) {
if len(uuid) == 0 {
return 0, nil
}
copy(data, uuid)
return 16, nil
}
func (uuid *Uuid) Unmarshal(data []byte) error {
if len(data) == 0 {
uuid = nil
return nil
}
id := Uuid(make([]byte, 16))
copy(id, data)
*uuid = id
return nil
}
func (uuid *Uuid) Size() int {
if uuid == nil {
return 0
}
if len(*uuid) == 0 {
return 0
}
return 16
}
func (uuid Uuid) MarshalJSON() ([]byte, error) {
s := hex.EncodeToString([]byte(uuid))
return json.Marshal(s)
}
func (uuid *Uuid) UnmarshalJSON(data []byte) error {
var s string
err := json.Unmarshal(data, &s)
if err != nil {
return err
}
d, err := hex.DecodeString(s)
if err != nil {
return err
}
*uuid = Uuid(d)
return nil
}
func (uuid Uuid) Equal(other Uuid) bool {
return bytes.Equal(uuid[0:], other[0:])
}
func (uuid Uuid) Compare(other Uuid) int {
return bytes.Compare(uuid[0:], other[0:])
}
type int63 interface {
Int63() int64
}
func NewPopulatedUuid(r int63) *Uuid {
u := RandV4(r)
return &u
}
func RandV4(r int63) Uuid {
uuid := make(Uuid, 16)
uuid.RandV4(r)
return uuid
}
func (uuid Uuid) RandV4(r int63) {
PutLittleEndianUint64(uuid, 0, uint64(r.Int63()))
PutLittleEndianUint64(uuid, 8, uint64(r.Int63()))
uuid[6] = (uuid[6] & 0xf) | 0x40
uuid[8] = (uuid[8] & 0x3f) | 0x80
}

View file

@ -0,0 +1,252 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package test
import (
"fmt"
"math"
"math/rand"
"testing"
"time"
"github.com/gogo/protobuf/proto"
)
//http://code.google.com/p/goprotobuf/issues/detail?id=39
func TestBugUint32VarintSize(t *testing.T) {
temp := uint32(math.MaxUint32)
n := &NinOptNative{}
n.Field5 = &temp
data, err := proto.Marshal(n)
if err != nil {
panic(err)
}
if len(data) != 6 {
t.Fatalf("data should be length 6, but its %#v", data)
}
}
func TestBugZeroLengthSliceSize(t *testing.T) {
n := &NinRepPackedNative{
Field8: []int64{},
}
size := n.Size()
data, err := proto.Marshal(n)
if err != nil {
panic(err)
}
if len(data) != size {
t.Fatalf("expected %v, but got %v", len(data), size)
}
}
//http://code.google.com/p/goprotobuf/issues/detail?id=40
func TestBugPackedProtoSize(t *testing.T) {
n := &NinRepPackedNative{
Field4: []int64{172960727389894724, 2360337516664475010, 860833876131988189, 9068073014890763245, 7794843386260381831, 4023536436053141786, 8992311247496919020, 4330096163611305776, 4490411416244976467, 7873947349172707443, 2754969595834279669, 1360667855926938684, 4771480785172657389, 4875578924966668055, 8070579869808877481, 9128179594766551001, 4630419407064527516, 863844540220372892, 8208727650143073487, 7086117356301045838, 7779695211931506151, 5493835345187563535, 9119767633370806007, 9054342025895349248, 1887303228838508438, 7624573031734528281, 1874668389749611225, 3517684643468970593, 6677697606628877758, 7293473953189936168, 444475066704085538, 8594971141363049302, 1146643249094989673, 733393306232853371, 7721178528893916886, 7784452000911004429, 6436373110242711440, 6897422461738321237, 8772249155667732778, 6211871464311393541, 3061903718310406883, 7845488913176136641, 8342255034663902574, 3443058984649725748, 8410801047334832902, 7496541071517841153, 4305416923521577765, 7814967600020476457, 8671843803465481186, 3490266370361096855, 1447425664719091336, 653218597262334239, 8306243902880091940, 7851896059762409081, 5936760560798954978, 5755724498441478025, 7022701569985035966, 3707709584811468220, 529069456924666920, 7986469043681522462, 3092513330689518836, 5103541550470476202, 3577384161242626406, 3733428084624703294, 8388690542440473117, 3262468785346149388, 8788358556558007570, 5476276940198542020, 7277903243119461239, 5065861426928605020, 7533460976202697734, 1749213838654236956, 557497603941617931, 5496307611456481108, 6444547750062831720, 6992758776744205596, 7356719693428537399, 2896328872476734507, 381447079530132038, 598300737753233118, 3687980626612697715, 7240924191084283349, 8172414415307971170, 4847024388701257185, 2081764168600256551, 3394217778539123488, 6244660626429310923, 8301712215675381614, 5360615125359461174, 8410140945829785773, 3152963269026381373, 6197275282781459633, 4419829061407546410, 6262035523070047537, 2837207483933463885, 2158105736666826128, 8150764172235490711},
Field7: []int32{249451845, 1409974015, 393609128, 435232428, 1817529040, 91769006, 861170933, 1556185603, 1568580279, 1236375273, 512276621, 693633711, 967580535, 1950715977, 853431462, 1362390253, 159591204, 111900629, 322985263, 279671129, 1592548430, 465651370, 733849989, 1172059400, 1574824441, 263541092, 1271612397, 1520584358, 467078791, 117698716, 1098255064, 2054264846, 1766452305, 1267576395, 1557505617, 1187833560, 956187431, 1970977586, 1160235159, 1610259028, 489585797, 459139078, 566263183, 954319278, 1545018565, 1753946743, 948214318, 422878159, 883926576, 1424009347, 824732372, 1290433180, 80297942, 417294230, 1402647904, 2078392782, 220505045, 787368129, 463781454, 293083578, 808156928, 293976361},
Field9: []uint32{0xaa4976e8, 0x3da8cc4c, 0x8c470d83, 0x344d964e, 0x5b90925, 0xa4c4d34e, 0x666eff19, 0xc238e552, 0x9be53bb6, 0x56364245, 0x33ee079d, 0x96bf0ede, 0x7941b74f, 0xdb07cb47, 0x6d76d827, 0x9b211d5d, 0x2798adb6, 0xe48b0c3b, 0x87061b21, 0x48f4e4d2, 0x3e5d5c12, 0x5ee91288, 0x336d4f35, 0xe1d44941, 0xc065548d, 0x2953d73f, 0x873af451, 0xfc769db, 0x9f1bf8da, 0x9baafdfc, 0xf1d3d770, 0x5bb5d2b4, 0xc2c67c48, 0x6845c4c1, 0xa48f32b0, 0xbb04bb70, 0xa5b1ca36, 0x8d98356a, 0x2171f654, 0x5ae279b0, 0x6c4a3d6b, 0x4fff5468, 0xcf9bf851, 0x68513614, 0xdbecd9b0, 0x9553ed3c, 0xa494a736, 0x42205438, 0xbf8e5caa, 0xd3283c6, 0x76d20788, 0x9179826f, 0x96b24f85, 0xbc2eacf4, 0xe4afae0b, 0x4bca85cb, 0x35e63b5b, 0xd7ccee0c, 0x2b506bb9, 0xe78e9f44, 0x9ad232f1, 0x99a37335, 0xa5d6ffc8},
Field11: []uint64{0x53c01ebc, 0x4fb85ba6, 0x8805eea1, 0xb20ec896, 0x93b63410, 0xec7c9492, 0x50765a28, 0x19592106, 0x2ecc59b3, 0x39cd474f, 0xe4c9e47, 0x444f48c5, 0xe7731d32, 0xf3f43975, 0x603caedd, 0xbb05a1af, 0xa808e34e, 0x88580b07, 0x4c96bbd1, 0x730b4ab9, 0xed126e2b, 0x6db48205, 0x154ba1b9, 0xc26bfb6a, 0x389aa052, 0x869d966c, 0x7c86b366, 0xcc8edbcd, 0xfa8d6dad, 0xcf5857d9, 0x2d9cda0f, 0x1218a0b8, 0x41bf997, 0xf0ca65ac, 0xa610d4b9, 0x8d362e28, 0xb7212d87, 0x8e0fe109, 0xbee041d9, 0x759be2f6, 0x35fef4f3, 0xaeacdb71, 0x10888852, 0xf4e28117, 0xe2a14812, 0x73b748dc, 0xd1c3c6b2, 0xfef41bf0, 0xc9b43b62, 0x810e4faa, 0xcaa41c06, 0x1893fe0d, 0xedc7c850, 0xd12b9eaa, 0x467ee1a9, 0xbe84756b, 0xda7b1680, 0xdc069ffe, 0xf1e7e9f9, 0xb3d95370, 0xa92b77df, 0x5693ac41, 0xd04b7287, 0x27aebf15, 0x837b316e, 0x4dbe2263, 0xbab70c67, 0x547dab21, 0x3c346c1f, 0xb8ef0e4e, 0xfe2d03ce, 0xe1d75955, 0xfec1306, 0xba35c23e, 0xb784ed04, 0x2a4e33aa, 0x7e19d09a, 0x3827c1fe, 0xf3a51561, 0xef765e2b, 0xb044256c, 0x62b322be, 0xf34d56be, 0xeb71b369, 0xffe1294f, 0x237fe8d0, 0x77a1473b, 0x239e1196, 0xdd19bf3d, 0x82c91fe1, 0x95361c57, 0xffea3f1b, 0x1a094c84},
Field12: []int64{8308420747267165049, 3664160795077875961, 7868970059161834817, 7237335984251173739, 5254748003907196506, 3362259627111837480, 430460752854552122, 5119635556501066533, 1277716037866233522, 9185775384759813768, 833932430882717888, 7986528304451297640, 6792233378368656337, 2074207091120609721, 1788723326198279432, 7756514594746453657, 2283775964901597324, 3061497730110517191, 7733947890656120277, 626967303632386244, 7822928600388582821, 3489658753000061230, 168869995163005961, 248814782163480763, 477885608911386247, 4198422415674133867, 3379354662797976109, 9925112544736939, 1486335136459138480, 4561560414032850671, 1010864164014091267, 186722821683803084, 5106357936724819318, 1298160820191228988, 4675403242419953145, 7130634540106489752, 7101280006672440929, 7176058292431955718, 9109875054097770321, 6810974877085322872, 4736707874303993641, 8993135362721382187, 6857881554990254283, 3704748883307461680, 1099360832887634994, 5207691918707192633, 5984721695043995243},
}
size := proto.Size(n)
data, err := proto.Marshal(n)
if err != nil {
panic(err)
}
if len(data) != size {
t.Fatalf("expected %v, but got %v diff is %v", len(data), size, len(data)-size)
}
}
func testSize(m interface {
proto.Message
Size() int
}, desc string, expected int) ([]byte, error) {
data, err := proto.Marshal(m)
if err != nil {
return nil, err
}
protoSize := proto.Size(m)
mSize := m.Size()
lenData := len(data)
if protoSize != mSize || protoSize != lenData || mSize != lenData {
return nil, fmt.Errorf("%s proto.Size(m){%d} != m.Size(){%d} != len(data){%d}", desc, protoSize, mSize, lenData)
}
if got := protoSize; got != expected {
return nil, fmt.Errorf("%s proto.Size(m) got %d expected %d", desc, got, expected)
}
if got := mSize; got != expected {
return nil, fmt.Errorf("%s m.Size() got %d expected %d", desc, got, expected)
}
if got := lenData; got != expected {
return nil, fmt.Errorf("%s len(data) got %d expected %d", desc, got, expected)
}
return data, nil
}
func TestInt32Int64Compatibility(t *testing.T) {
//test nullable int32 and int64
data1, err := testSize(&NinOptNative{
Field3: proto.Int32(-1),
}, "nullable", 11)
if err != nil {
t.Error(err)
}
//change marshaled data1 to unmarshal into 4th field which is an int64
data1[0] = uint8(uint32(4 /*fieldNumber*/)<<3 | uint32(0 /*wireType*/))
u1 := &NinOptNative{}
if err = proto.Unmarshal(data1, u1); err != nil {
t.Error(err)
}
if !u1.Equal(&NinOptNative{
Field4: proto.Int64(-1),
}) {
t.Error("nullable unmarshaled int32 is not the same int64")
}
//test non-nullable int32 and int64
data2, err := testSize(&NidOptNative{
Field3: -1,
}, "non nullable", 67)
if err != nil {
t.Error(err)
}
//change marshaled data2 to unmarshal into 4th field which is an int64
field3 := uint8(uint32(3 /*fieldNumber*/)<<3 | uint32(0 /*wireType*/))
field4 := uint8(uint32(4 /*fieldNumber*/)<<3 | uint32(0 /*wireType*/))
for i, c := range data2 {
if c == field4 {
data2[i] = field3
} else if c == field3 {
data2[i] = field4
}
}
u2 := &NidOptNative{}
if err = proto.Unmarshal(data2, u2); err != nil {
t.Error(err)
}
if !u2.Equal(&NidOptNative{
Field4: -1,
}) {
t.Error("non nullable unmarshaled int32 is not the same int64")
}
//test packed repeated int32 and int64
m4 := &NinRepPackedNative{
Field3: []int32{-1},
}
data4, err := testSize(m4, "packed", 12)
if err != nil {
t.Error(err)
}
u4 := &NinRepPackedNative{}
if err := proto.Unmarshal(data4, u4); err != nil {
t.Error(err)
}
if err := u4.VerboseEqual(m4); err != nil {
t.Fatalf("%#v", u4)
}
//test repeated int32 and int64
if _, err := testSize(&NinRepNative{
Field3: []int32{-1},
}, "repeated", 11); err != nil {
t.Error(err)
}
t.Logf("tested all")
}
func TestRepeatedExtensionsMsgsIssue161(t *testing.T) {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
rep := 10
nins := make([]*NinOptNative, rep)
for i := range nins {
nins[i] = NewPopulatedNinOptNative(r, true)
}
input := &MyExtendable{}
if err := proto.SetExtension(input, E_FieldE, nins); err != nil {
t.Fatal(err)
}
data, err := proto.Marshal(input)
if err != nil {
t.Fatal(err)
}
output := &MyExtendable{}
if err := proto.Unmarshal(data, output); err != nil {
t.Fatal(err)
}
if !input.Equal(output) {
t.Fatal("expected equal")
}
data2, err2 := proto.Marshal(output)
if err2 != nil {
t.Fatal(err2)
}
if len(data) != len(data2) {
t.Fatal("expected equal length buffers")
}
}
func TestRepeatedExtensionsFieldsIssue161(t *testing.T) {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
rep := 10
ints := make([]int64, rep)
for i := range ints {
ints[i] = r.Int63()
}
input := &MyExtendable{}
if err := proto.SetExtension(input, E_FieldD, ints); err != nil {
t.Fatal(err)
}
data, err := proto.Marshal(input)
if err != nil {
t.Fatal(err)
}
output := &MyExtendable{}
if err := proto.Unmarshal(data, output); err != nil {
t.Fatal(err)
}
if !input.Equal(output) {
t.Fatal("expected equal")
}
data2, err2 := proto.Marshal(output)
if err2 != nil {
t.Fatal(err2)
}
if len(data) != len(data2) {
t.Fatal("expected equal length buffers")
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,626 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package test;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.goproto_enum_prefix_all) = false;
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
option (gogoproto.stringer_all) = true;
option (gogoproto.gostring_all) = true;
option (gogoproto.face_all) = true;
option (gogoproto.description_all) = true;
option (gogoproto.testgen_all) = true;
option (gogoproto.populate_all) = true;
option (gogoproto.benchgen_all) = true;
option (gogoproto.unmarshaler_all) = false;
option (gogoproto.marshaler_all) = false;
option (gogoproto.sizer_all) = true;
option (gogoproto.protosizer_all) = false;
option (gogoproto.goproto_enum_stringer_all) = false;
option (gogoproto.enum_stringer_all) = true;
option (gogoproto.unsafe_marshaler_all) = true;
option (gogoproto.unsafe_unmarshaler_all) = false;
option (gogoproto.compare_all) = true;
message NidOptNative {
optional double Field1 = 1 [(gogoproto.nullable) = false];
optional float Field2 = 2 [(gogoproto.nullable) = false];
optional int32 Field3 = 3 [(gogoproto.nullable) = false];
optional int64 Field4 = 4 [(gogoproto.nullable) = false];
optional uint32 Field5 = 5 [(gogoproto.nullable) = false];
optional uint64 Field6 = 6 [(gogoproto.nullable) = false];
optional sint32 Field7 = 7 [(gogoproto.nullable) = false];
optional sint64 Field8 = 8 [(gogoproto.nullable) = false];
optional fixed32 Field9 = 9 [(gogoproto.nullable) = false];
optional sfixed32 Field10 = 10 [(gogoproto.nullable) = false];
optional fixed64 Field11 = 11 [(gogoproto.nullable) = false];
optional sfixed64 Field12 = 12 [(gogoproto.nullable) = false];
optional bool Field13 = 13 [(gogoproto.nullable) = false];
optional string Field14 = 14 [(gogoproto.nullable) = false];
optional bytes Field15 = 15 [(gogoproto.nullable) = false];
}
message NinOptNative {
optional double Field1 = 1;
optional float Field2 = 2;
optional int32 Field3 = 3;
optional int64 Field4 = 4;
optional uint32 Field5 = 5;
optional uint64 Field6 = 6;
optional sint32 Field7 = 7;
optional sint64 Field8 = 8;
optional fixed32 Field9 = 9;
optional sfixed32 Field10 = 10;
optional fixed64 Field11 = 11;
optional sfixed64 Field12 = 12;
optional bool Field13 = 13;
optional string Field14 = 14;
optional bytes Field15 = 15;
}
message NidRepNative {
repeated double Field1 = 1 [(gogoproto.nullable) = false];
repeated float Field2 = 2 [(gogoproto.nullable) = false];
repeated int32 Field3 = 3 [(gogoproto.nullable) = false];
repeated int64 Field4 = 4 [(gogoproto.nullable) = false];
repeated uint32 Field5 = 5 [(gogoproto.nullable) = false];
repeated uint64 Field6 = 6 [(gogoproto.nullable) = false];
repeated sint32 Field7 = 7 [(gogoproto.nullable) = false];
repeated sint64 Field8 = 8 [(gogoproto.nullable) = false];
repeated fixed32 Field9 = 9 [(gogoproto.nullable) = false];
repeated sfixed32 Field10 = 10 [(gogoproto.nullable) = false];
repeated fixed64 Field11 = 11 [(gogoproto.nullable) = false];
repeated sfixed64 Field12 = 12 [(gogoproto.nullable) = false];
repeated bool Field13 = 13 [(gogoproto.nullable) = false];
repeated string Field14 = 14 [(gogoproto.nullable) = false];
repeated bytes Field15 = 15 [(gogoproto.nullable) = false];
}
message NinRepNative {
repeated double Field1 = 1;
repeated float Field2 = 2;
repeated int32 Field3 = 3;
repeated int64 Field4 = 4;
repeated uint32 Field5 = 5;
repeated uint64 Field6 = 6;
repeated sint32 Field7 = 7;
repeated sint64 Field8 = 8;
repeated fixed32 Field9 = 9;
repeated sfixed32 Field10 = 10;
repeated fixed64 Field11 = 11;
repeated sfixed64 Field12 = 12;
repeated bool Field13 = 13;
repeated string Field14 = 14;
repeated bytes Field15 = 15;
}
message NidRepPackedNative {
repeated double Field1 = 1 [(gogoproto.nullable) = false, packed = true];
repeated float Field2 = 2 [(gogoproto.nullable) = false, packed = true];
repeated int32 Field3 = 3 [(gogoproto.nullable) = false, packed = true];
repeated int64 Field4 = 4 [(gogoproto.nullable) = false, packed = true];
repeated uint32 Field5 = 5 [(gogoproto.nullable) = false, packed = true];
repeated uint64 Field6 = 6 [(gogoproto.nullable) = false, packed = true];
repeated sint32 Field7 = 7 [(gogoproto.nullable) = false, packed = true];
repeated sint64 Field8 = 8 [(gogoproto.nullable) = false, packed = true];
repeated fixed32 Field9 = 9 [(gogoproto.nullable) = false, packed = true];
repeated sfixed32 Field10 = 10 [(gogoproto.nullable) = false, packed = true];
repeated fixed64 Field11 = 11 [(gogoproto.nullable) = false, packed = true];
repeated sfixed64 Field12 = 12 [(gogoproto.nullable) = false, packed = true];
repeated bool Field13 = 13 [(gogoproto.nullable) = false, packed = true];
}
message NinRepPackedNative {
repeated double Field1 = 1 [packed = true];
repeated float Field2 = 2 [packed = true];
repeated int32 Field3 = 3 [packed = true];
repeated int64 Field4 = 4 [packed = true];
repeated uint32 Field5 = 5 [packed = true];
repeated uint64 Field6 = 6 [packed = true];
repeated sint32 Field7 = 7 [packed = true];
repeated sint64 Field8 = 8 [packed = true];
repeated fixed32 Field9 = 9 [packed = true];
repeated sfixed32 Field10 = 10 [packed = true];
repeated fixed64 Field11 = 11 [packed = true];
repeated sfixed64 Field12 = 12 [packed = true];
repeated bool Field13 = 13 [packed = true];
}
message NidOptStruct {
optional double Field1 = 1 [(gogoproto.nullable) = false];
optional float Field2 = 2 [(gogoproto.nullable) = false];
optional NidOptNative Field3 = 3 [(gogoproto.nullable) = false];
optional NinOptNative Field4 = 4 [(gogoproto.nullable) = false];
optional uint64 Field6 = 6 [(gogoproto.nullable) = false];
optional sint32 Field7 = 7 [(gogoproto.nullable) = false];
optional NidOptNative Field8 = 8 [(gogoproto.nullable) = false];
optional bool Field13 = 13 [(gogoproto.nullable) = false];
optional string Field14 = 14 [(gogoproto.nullable) = false];
optional bytes Field15 = 15 [(gogoproto.nullable) = false];
}
message NinOptStruct {
optional double Field1 = 1;
optional float Field2 = 2;
optional NidOptNative Field3 = 3;
optional NinOptNative Field4 = 4;
optional uint64 Field6 = 6;
optional sint32 Field7 = 7;
optional NidOptNative Field8 = 8;
optional bool Field13 = 13;
optional string Field14 = 14;
optional bytes Field15 = 15;
}
message NidRepStruct {
repeated double Field1 = 1 [(gogoproto.nullable) = false];
repeated float Field2 = 2 [(gogoproto.nullable) = false];
repeated NidOptNative Field3 = 3 [(gogoproto.nullable) = false];
repeated NinOptNative Field4 = 4 [(gogoproto.nullable) = false];
repeated uint64 Field6 = 6 [(gogoproto.nullable) = false];
repeated sint32 Field7 = 7 [(gogoproto.nullable) = false];
repeated NidOptNative Field8 = 8 [(gogoproto.nullable) = false];
repeated bool Field13 = 13 [(gogoproto.nullable) = false];
repeated string Field14 = 14 [(gogoproto.nullable) = false];
repeated bytes Field15 = 15 [(gogoproto.nullable) = false];
}
message NinRepStruct {
repeated double Field1 = 1;
repeated float Field2 = 2;
repeated NidOptNative Field3 = 3;
repeated NinOptNative Field4 = 4;
repeated uint64 Field6 = 6;
repeated sint32 Field7 = 7;
repeated NidOptNative Field8 = 8;
repeated bool Field13 = 13;
repeated string Field14 = 14;
repeated bytes Field15 = 15;
}
message NidEmbeddedStruct {
optional NidOptNative Field1 = 1 [(gogoproto.embed) = true];
optional NidOptNative Field200 = 200 [(gogoproto.nullable) = false];
optional bool Field210 = 210 [(gogoproto.nullable) = false];
}
message NinEmbeddedStruct {
optional NidOptNative Field1 = 1 [(gogoproto.embed) = true];
optional NidOptNative Field200 = 200;
optional bool Field210 = 210;
}
message NidNestedStruct {
optional NidOptStruct Field1 = 1 [(gogoproto.nullable) = false];
repeated NidRepStruct Field2 = 2 [(gogoproto.nullable) = false];
}
message NinNestedStruct {
optional NinOptStruct Field1 = 1;
repeated NinRepStruct Field2 = 2;
}
message NidOptCustom {
optional bytes Id = 1 [(gogoproto.customtype) = "Uuid", (gogoproto.nullable) = false];
optional bytes Value = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128", (gogoproto.nullable) = false];
}
message CustomDash {
optional bytes Value = 1 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom-dash-type.Bytes"];
}
message NinOptCustom {
optional bytes Id = 1 [(gogoproto.customtype) = "Uuid"];
optional bytes Value = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"];
}
message NidRepCustom {
repeated bytes Id = 1 [(gogoproto.customtype) = "Uuid", (gogoproto.nullable) = false];
repeated bytes Value = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128", (gogoproto.nullable) = false];
}
message NinRepCustom {
repeated bytes Id = 1 [(gogoproto.customtype) = "Uuid"];
repeated bytes Value = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"];
}
message NinOptNativeUnion {
option (gogoproto.onlyone) = true;
optional double Field1 = 1;
optional float Field2 = 2;
optional int32 Field3 = 3;
optional int64 Field4 = 4;
optional uint32 Field5 = 5;
optional uint64 Field6 = 6;
optional bool Field13 = 13;
optional string Field14 = 14;
optional bytes Field15 = 15;
}
message NinOptStructUnion {
option (gogoproto.onlyone) = true;
optional double Field1 = 1;
optional float Field2 = 2;
optional NidOptNative Field3 = 3;
optional NinOptNative Field4 = 4;
optional uint64 Field6 = 6;
optional sint32 Field7 = 7;
optional bool Field13 = 13;
optional string Field14 = 14;
optional bytes Field15 = 15;
}
message NinEmbeddedStructUnion {
option (gogoproto.onlyone) = true;
optional NidOptNative Field1 = 1 [(gogoproto.embed) = true];
optional NinOptNative Field200 = 200;
optional bool Field210 = 210;
}
message NinNestedStructUnion {
option (gogoproto.onlyone) = true;
optional NinOptNativeUnion Field1 = 1;
optional NinOptStructUnion Field2 = 2;
optional NinEmbeddedStructUnion Field3 = 3;
}
message Tree {
option (gogoproto.onlyone) = true;
optional OrBranch Or = 1;
optional AndBranch And = 2;
optional Leaf Leaf = 3;
}
message OrBranch {
optional Tree Left = 1 [(gogoproto.nullable) = false];
optional Tree Right = 2 [(gogoproto.nullable) = false];
}
message AndBranch {
optional Tree Left = 1 [(gogoproto.nullable) = false];
optional Tree Right = 2 [(gogoproto.nullable) = false];
}
message Leaf {
optional int64 Value = 1 [(gogoproto.nullable) = false];
optional string StrValue = 2 [(gogoproto.nullable) = false];
}
message DeepTree {
option (gogoproto.onlyone) = true;
optional ADeepBranch Down = 1;
optional AndDeepBranch And = 2;
optional DeepLeaf Leaf = 3;
}
message ADeepBranch {
optional DeepTree Down = 2 [(gogoproto.nullable) = false];
}
message AndDeepBranch {
optional DeepTree Left = 1 [(gogoproto.nullable) = false];
optional DeepTree Right = 2 [(gogoproto.nullable) = false];
}
message DeepLeaf {
optional Tree Tree = 1 [(gogoproto.nullable) = false];
}
message Nil {
}
enum TheTestEnum {
A = 0;
B = 1;
C = 2;
}
enum AnotherTestEnum {
option (gogoproto.goproto_enum_prefix) = false;
D = 10;
E = 11;
}
// YetAnotherTestEnum is used to test cross-package import of custom name
// fields and default resolution.
enum YetAnotherTestEnum {
option (gogoproto.goproto_enum_prefix) = false;
AA = 0;
BB = 1 [(gogoproto.enumvalue_customname) = "BetterYetBB"];
}
// YetAnotherTestEnum is used to test cross-package import of custom name
// fields and default resolution.
enum YetYetAnotherTestEnum {
option (gogoproto.goproto_enum_prefix) = true;
CC = 0;
DD = 1 [(gogoproto.enumvalue_customname) = "BetterYetDD"];
}
message NidOptEnum {
optional TheTestEnum Field1 = 1 [(gogoproto.nullable) = false];
}
message NinOptEnum {
optional TheTestEnum Field1 = 1;
optional YetAnotherTestEnum Field2 = 2;
optional YetYetAnotherTestEnum Field3 = 3;
}
message NidRepEnum {
repeated TheTestEnum Field1 = 1 [(gogoproto.nullable) = false];
repeated YetAnotherTestEnum Field2 = 2 [(gogoproto.nullable) = false];
repeated YetYetAnotherTestEnum Field3 = 3 [(gogoproto.nullable) = false];
}
message NinRepEnum {
repeated TheTestEnum Field1 = 1;
repeated YetAnotherTestEnum Field2 = 2;
repeated YetYetAnotherTestEnum Field3 = 3;
}
message NinOptEnumDefault {
option (gogoproto.goproto_getters) = true;
option (gogoproto.face) = false;
optional TheTestEnum Field1 = 1 [default=C];
optional YetAnotherTestEnum Field2 = 2 [default=BB];
optional YetYetAnotherTestEnum Field3 = 3 [default=CC];
}
message AnotherNinOptEnum {
optional AnotherTestEnum Field1 = 1;
optional YetAnotherTestEnum Field2 = 2;
optional YetYetAnotherTestEnum Field3 = 3;
}
message AnotherNinOptEnumDefault {
option (gogoproto.goproto_getters) = true;
option (gogoproto.face) = false;
optional AnotherTestEnum Field1 = 1 [default=E];
optional YetAnotherTestEnum Field2 = 2 [default=BB];
optional YetYetAnotherTestEnum Field3 = 3 [default=CC];
}
message Timer {
optional sfixed64 Time1 = 1 [(gogoproto.nullable) = false];
optional sfixed64 Time2 = 2 [(gogoproto.nullable) = false];
optional bytes Data = 3 [(gogoproto.nullable) = false];
}
message MyExtendable {
option (gogoproto.face) = false;
optional int64 Field1 = 1;
extensions 100 to 199;
}
extend MyExtendable {
optional double FieldA = 100;
optional NinOptNative FieldB = 101;
optional NinEmbeddedStruct FieldC = 102;
repeated int64 FieldD = 104;
repeated NinOptNative FieldE = 105;
}
message OtherExtenable {
option (gogoproto.face) = false;
optional int64 Field2 = 2;
extensions 14 to 16;
optional int64 Field13 = 13;
extensions 10 to 12;
optional MyExtendable M = 1;
}
message NestedDefinition {
optional int64 Field1 = 1;
message NestedMessage {
optional fixed64 NestedField1 = 1;
optional NestedNestedMsg NNM = 2;
message NestedNestedMsg {
optional string NestedNestedField1 = 10;
}
}
enum NestedEnum {
TYPE_NESTED = 1;
}
optional NestedEnum EnumField = 2;
optional NestedMessage.NestedNestedMsg NNM = 3;
optional NestedMessage NM = 4;
}
message NestedScope {
optional NestedDefinition.NestedMessage.NestedNestedMsg A = 1;
optional NestedDefinition.NestedEnum B = 2;
optional NestedDefinition.NestedMessage C = 3;
}
message NinOptNativeDefault {
option (gogoproto.goproto_getters) = true;
option (gogoproto.face) = false;
optional double Field1 = 1 [default = 1234.1234];
optional float Field2 = 2 [default = 1234.1234];
optional int32 Field3 = 3 [default = 1234];
optional int64 Field4 = 4 [default = 1234];
optional uint32 Field5 = 5 [default = 1234];
optional uint64 Field6 = 6 [default = 1234];
optional sint32 Field7 = 7 [default = 1234];
optional sint64 Field8 = 8 [default = 1234];
optional fixed32 Field9 = 9 [default = 1234];
optional sfixed32 Field10 = 10 [default = 1234];
optional fixed64 Field11 = 11 [default = 1234];
optional sfixed64 Field12 = 12 [default = 1234];
optional bool Field13 = 13 [default = true];
optional string Field14 = 14 [default = "1234"];
optional bytes Field15 = 15;
}
message CustomContainer {
optional NidOptCustom CustomStruct = 1 [(gogoproto.nullable) = false];
}
message CustomNameNidOptNative {
optional double Field1 = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldA"];
optional float Field2 = 2 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldB"];
optional int32 Field3 = 3 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldC"];
optional int64 Field4 = 4 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldD"];
optional uint32 Field5 = 5 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldE"];
optional uint64 Field6 = 6 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldF"];
optional sint32 Field7 = 7 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldG"];
optional sint64 Field8 = 8 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldH"];
optional fixed32 Field9 = 9 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldI"];
optional sfixed32 Field10 = 10 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldJ"];
optional fixed64 Field11 = 11 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldK"];
optional sfixed64 Field12 = 12 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldL"];
optional bool Field13 = 13 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldM"];
optional string Field14 = 14 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldN"];
optional bytes Field15 = 15 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldO"];
}
message CustomNameNinOptNative {
optional double Field1 = 1 [(gogoproto.customname) = "FieldA"];
optional float Field2 = 2 [(gogoproto.customname) = "FieldB"];
optional int32 Field3 = 3 [(gogoproto.customname) = "FieldC"];
optional int64 Field4 = 4 [(gogoproto.customname) = "FieldD"];
optional uint32 Field5 = 5 [(gogoproto.customname) = "FieldE"];
optional uint64 Field6 = 6 [(gogoproto.customname) = "FieldF"];
optional sint32 Field7 = 7 [(gogoproto.customname) = "FieldG"];
optional sint64 Field8 = 8 [(gogoproto.customname) = "FieldH"];
optional fixed32 Field9 = 9 [(gogoproto.customname) = "FieldI"];
optional sfixed32 Field10 = 10 [(gogoproto.customname) = "FieldJ"];
optional fixed64 Field11 = 11 [(gogoproto.customname) = "FieldK"];
optional sfixed64 Field12 = 12 [(gogoproto.customname) = "FielL"];
optional bool Field13 = 13 [(gogoproto.customname) = "FieldM"];
optional string Field14 = 14 [(gogoproto.customname) = "FieldN"];
optional bytes Field15 = 15 [(gogoproto.customname) = "FieldO"];
}
message CustomNameNinRepNative {
repeated double Field1 = 1 [(gogoproto.customname) = "FieldA"];
repeated float Field2 = 2 [(gogoproto.customname) = "FieldB"];
repeated int32 Field3 = 3 [(gogoproto.customname) = "FieldC"];
repeated int64 Field4 = 4 [(gogoproto.customname) = "FieldD"];
repeated uint32 Field5 = 5 [(gogoproto.customname) = "FieldE"];
repeated uint64 Field6 = 6 [(gogoproto.customname) = "FieldF"];
repeated sint32 Field7 = 7 [(gogoproto.customname) = "FieldG"];
repeated sint64 Field8 = 8 [(gogoproto.customname) = "FieldH"];
repeated fixed32 Field9 = 9 [(gogoproto.customname) = "FieldI"];
repeated sfixed32 Field10 = 10 [(gogoproto.customname) = "FieldJ"];
repeated fixed64 Field11 = 11 [(gogoproto.customname) = "FieldK"];
repeated sfixed64 Field12 = 12 [(gogoproto.customname) = "FieldL"];
repeated bool Field13 = 13 [(gogoproto.customname) = "FieldM"];
repeated string Field14 = 14 [(gogoproto.customname) = "FieldN"];
repeated bytes Field15 = 15 [(gogoproto.customname) = "FieldO"];
}
message CustomNameNinStruct {
optional double Field1 = 1 [(gogoproto.customname) = "FieldA"];
optional float Field2 = 2 [(gogoproto.customname) = "FieldB"];
optional NidOptNative Field3 = 3 [(gogoproto.customname) = "FieldC"];
repeated NinOptNative Field4 = 4 [(gogoproto.customname) = "FieldD"];
optional uint64 Field6 = 6 [(gogoproto.customname) = "FieldE"];
optional sint32 Field7 = 7 [(gogoproto.customname) = "FieldF"];
optional NidOptNative Field8 = 8 [(gogoproto.customname) = "FieldG"];
optional bool Field13 = 13 [(gogoproto.customname) = "FieldH"];
optional string Field14 = 14 [(gogoproto.customname) = "FieldI"];
optional bytes Field15 = 15 [(gogoproto.customname) = "FieldJ"];
}
message CustomNameCustomType {
optional bytes Id = 1 [(gogoproto.customname) = "FieldA", (gogoproto.customtype) = "Uuid"];
optional bytes Value = 2 [(gogoproto.customname) = "FieldB", (gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"];
repeated bytes Ids = 3 [(gogoproto.customname) = "FieldC", (gogoproto.customtype) = "Uuid"];
repeated bytes Values = 4 [(gogoproto.customname) = "FieldD", (gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"];
}
message CustomNameNinEmbeddedStructUnion {
option (gogoproto.onlyone) = true;
optional NidOptNative Field1 = 1 [(gogoproto.embed) = true];
optional NinOptNative Field200 = 200 [(gogoproto.customname) = "FieldA"];
optional bool Field210 = 210 [(gogoproto.customname) = "FieldB"];
}
message CustomNameEnum {
optional TheTestEnum Field1 = 1 [(gogoproto.customname) = "FieldA"];
repeated TheTestEnum Field2 = 2 [(gogoproto.customname) = "FieldB"];
}
message NoExtensionsMap {
option (gogoproto.face) = false;
option (gogoproto.goproto_extensions_map) = false;
optional int64 Field1 = 1;
extensions 100 to 199;
}
extend NoExtensionsMap {
optional double FieldA1 = 100;
optional NinOptNative FieldB1 = 101;
optional NinEmbeddedStruct FieldC1 = 102;
}
message Unrecognized {
option (gogoproto.goproto_unrecognized) = false;
optional string Field1 = 1;
}
message UnrecognizedWithInner {
message Inner {
option (gogoproto.goproto_unrecognized) = false;
optional uint32 Field1 = 1;
}
repeated Inner embedded = 1;
optional string Field2 = 2;
}
message UnrecognizedWithEmbed {
message Embedded {
option (gogoproto.goproto_unrecognized) = false;
optional uint32 Field1 = 1;
}
optional Embedded embedded = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false];
optional string Field2 = 2;
}
message Node {
optional string Label = 1;
repeated Node Children = 2;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,133 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package test
import (
"bytes"
"encoding/hex"
"encoding/json"
)
func PutLittleEndianUint64(b []byte, offset int, v uint64) {
b[offset] = byte(v)
b[offset+1] = byte(v >> 8)
b[offset+2] = byte(v >> 16)
b[offset+3] = byte(v >> 24)
b[offset+4] = byte(v >> 32)
b[offset+5] = byte(v >> 40)
b[offset+6] = byte(v >> 48)
b[offset+7] = byte(v >> 56)
}
type Uuid []byte
func (uuid Uuid) Marshal() ([]byte, error) {
if len(uuid) == 0 {
return nil, nil
}
return []byte(uuid), nil
}
func (uuid Uuid) MarshalTo(data []byte) (n int, err error) {
if len(uuid) == 0 {
return 0, nil
}
copy(data, uuid)
return 16, nil
}
func (uuid *Uuid) Unmarshal(data []byte) error {
if len(data) == 0 {
uuid = nil
return nil
}
id := Uuid(make([]byte, 16))
copy(id, data)
*uuid = id
return nil
}
func (uuid *Uuid) Size() int {
if uuid == nil {
return 0
}
if len(*uuid) == 0 {
return 0
}
return 16
}
func (uuid Uuid) MarshalJSON() ([]byte, error) {
s := hex.EncodeToString([]byte(uuid))
return json.Marshal(s)
}
func (uuid *Uuid) UnmarshalJSON(data []byte) error {
var s string
err := json.Unmarshal(data, &s)
if err != nil {
return err
}
d, err := hex.DecodeString(s)
if err != nil {
return err
}
*uuid = Uuid(d)
return nil
}
func (uuid Uuid) Equal(other Uuid) bool {
return bytes.Equal(uuid[0:], other[0:])
}
func (uuid Uuid) Compare(other Uuid) int {
return bytes.Compare(uuid[0:], other[0:])
}
type int63 interface {
Int63() int64
}
func NewPopulatedUuid(r int63) *Uuid {
u := RandV4(r)
return &u
}
func RandV4(r int63) Uuid {
uuid := make(Uuid, 16)
uuid.RandV4(r)
return uuid
}
func (uuid Uuid) RandV4(r int63) {
PutLittleEndianUint64(uuid, 0, uint64(r.Int63()))
PutLittleEndianUint64(uuid, 8, uint64(r.Int63()))
uuid[6] = (uuid[6] & 0xf) | 0x40
uuid[8] = (uuid[8] & 0x3f) | 0x80
}

View file

@ -0,0 +1,252 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package test
import (
"fmt"
"math"
"math/rand"
"testing"
"time"
"github.com/gogo/protobuf/proto"
)
//http://code.google.com/p/goprotobuf/issues/detail?id=39
func TestBugUint32VarintSize(t *testing.T) {
temp := uint32(math.MaxUint32)
n := &NinOptNative{}
n.Field5 = &temp
data, err := proto.Marshal(n)
if err != nil {
panic(err)
}
if len(data) != 6 {
t.Fatalf("data should be length 6, but its %#v", data)
}
}
func TestBugZeroLengthSliceSize(t *testing.T) {
n := &NinRepPackedNative{
Field8: []int64{},
}
size := n.Size()
data, err := proto.Marshal(n)
if err != nil {
panic(err)
}
if len(data) != size {
t.Fatalf("expected %v, but got %v", len(data), size)
}
}
//http://code.google.com/p/goprotobuf/issues/detail?id=40
func TestBugPackedProtoSize(t *testing.T) {
n := &NinRepPackedNative{
Field4: []int64{172960727389894724, 2360337516664475010, 860833876131988189, 9068073014890763245, 7794843386260381831, 4023536436053141786, 8992311247496919020, 4330096163611305776, 4490411416244976467, 7873947349172707443, 2754969595834279669, 1360667855926938684, 4771480785172657389, 4875578924966668055, 8070579869808877481, 9128179594766551001, 4630419407064527516, 863844540220372892, 8208727650143073487, 7086117356301045838, 7779695211931506151, 5493835345187563535, 9119767633370806007, 9054342025895349248, 1887303228838508438, 7624573031734528281, 1874668389749611225, 3517684643468970593, 6677697606628877758, 7293473953189936168, 444475066704085538, 8594971141363049302, 1146643249094989673, 733393306232853371, 7721178528893916886, 7784452000911004429, 6436373110242711440, 6897422461738321237, 8772249155667732778, 6211871464311393541, 3061903718310406883, 7845488913176136641, 8342255034663902574, 3443058984649725748, 8410801047334832902, 7496541071517841153, 4305416923521577765, 7814967600020476457, 8671843803465481186, 3490266370361096855, 1447425664719091336, 653218597262334239, 8306243902880091940, 7851896059762409081, 5936760560798954978, 5755724498441478025, 7022701569985035966, 3707709584811468220, 529069456924666920, 7986469043681522462, 3092513330689518836, 5103541550470476202, 3577384161242626406, 3733428084624703294, 8388690542440473117, 3262468785346149388, 8788358556558007570, 5476276940198542020, 7277903243119461239, 5065861426928605020, 7533460976202697734, 1749213838654236956, 557497603941617931, 5496307611456481108, 6444547750062831720, 6992758776744205596, 7356719693428537399, 2896328872476734507, 381447079530132038, 598300737753233118, 3687980626612697715, 7240924191084283349, 8172414415307971170, 4847024388701257185, 2081764168600256551, 3394217778539123488, 6244660626429310923, 8301712215675381614, 5360615125359461174, 8410140945829785773, 3152963269026381373, 6197275282781459633, 4419829061407546410, 6262035523070047537, 2837207483933463885, 2158105736666826128, 8150764172235490711},
Field7: []int32{249451845, 1409974015, 393609128, 435232428, 1817529040, 91769006, 861170933, 1556185603, 1568580279, 1236375273, 512276621, 693633711, 967580535, 1950715977, 853431462, 1362390253, 159591204, 111900629, 322985263, 279671129, 1592548430, 465651370, 733849989, 1172059400, 1574824441, 263541092, 1271612397, 1520584358, 467078791, 117698716, 1098255064, 2054264846, 1766452305, 1267576395, 1557505617, 1187833560, 956187431, 1970977586, 1160235159, 1610259028, 489585797, 459139078, 566263183, 954319278, 1545018565, 1753946743, 948214318, 422878159, 883926576, 1424009347, 824732372, 1290433180, 80297942, 417294230, 1402647904, 2078392782, 220505045, 787368129, 463781454, 293083578, 808156928, 293976361},
Field9: []uint32{0xaa4976e8, 0x3da8cc4c, 0x8c470d83, 0x344d964e, 0x5b90925, 0xa4c4d34e, 0x666eff19, 0xc238e552, 0x9be53bb6, 0x56364245, 0x33ee079d, 0x96bf0ede, 0x7941b74f, 0xdb07cb47, 0x6d76d827, 0x9b211d5d, 0x2798adb6, 0xe48b0c3b, 0x87061b21, 0x48f4e4d2, 0x3e5d5c12, 0x5ee91288, 0x336d4f35, 0xe1d44941, 0xc065548d, 0x2953d73f, 0x873af451, 0xfc769db, 0x9f1bf8da, 0x9baafdfc, 0xf1d3d770, 0x5bb5d2b4, 0xc2c67c48, 0x6845c4c1, 0xa48f32b0, 0xbb04bb70, 0xa5b1ca36, 0x8d98356a, 0x2171f654, 0x5ae279b0, 0x6c4a3d6b, 0x4fff5468, 0xcf9bf851, 0x68513614, 0xdbecd9b0, 0x9553ed3c, 0xa494a736, 0x42205438, 0xbf8e5caa, 0xd3283c6, 0x76d20788, 0x9179826f, 0x96b24f85, 0xbc2eacf4, 0xe4afae0b, 0x4bca85cb, 0x35e63b5b, 0xd7ccee0c, 0x2b506bb9, 0xe78e9f44, 0x9ad232f1, 0x99a37335, 0xa5d6ffc8},
Field11: []uint64{0x53c01ebc, 0x4fb85ba6, 0x8805eea1, 0xb20ec896, 0x93b63410, 0xec7c9492, 0x50765a28, 0x19592106, 0x2ecc59b3, 0x39cd474f, 0xe4c9e47, 0x444f48c5, 0xe7731d32, 0xf3f43975, 0x603caedd, 0xbb05a1af, 0xa808e34e, 0x88580b07, 0x4c96bbd1, 0x730b4ab9, 0xed126e2b, 0x6db48205, 0x154ba1b9, 0xc26bfb6a, 0x389aa052, 0x869d966c, 0x7c86b366, 0xcc8edbcd, 0xfa8d6dad, 0xcf5857d9, 0x2d9cda0f, 0x1218a0b8, 0x41bf997, 0xf0ca65ac, 0xa610d4b9, 0x8d362e28, 0xb7212d87, 0x8e0fe109, 0xbee041d9, 0x759be2f6, 0x35fef4f3, 0xaeacdb71, 0x10888852, 0xf4e28117, 0xe2a14812, 0x73b748dc, 0xd1c3c6b2, 0xfef41bf0, 0xc9b43b62, 0x810e4faa, 0xcaa41c06, 0x1893fe0d, 0xedc7c850, 0xd12b9eaa, 0x467ee1a9, 0xbe84756b, 0xda7b1680, 0xdc069ffe, 0xf1e7e9f9, 0xb3d95370, 0xa92b77df, 0x5693ac41, 0xd04b7287, 0x27aebf15, 0x837b316e, 0x4dbe2263, 0xbab70c67, 0x547dab21, 0x3c346c1f, 0xb8ef0e4e, 0xfe2d03ce, 0xe1d75955, 0xfec1306, 0xba35c23e, 0xb784ed04, 0x2a4e33aa, 0x7e19d09a, 0x3827c1fe, 0xf3a51561, 0xef765e2b, 0xb044256c, 0x62b322be, 0xf34d56be, 0xeb71b369, 0xffe1294f, 0x237fe8d0, 0x77a1473b, 0x239e1196, 0xdd19bf3d, 0x82c91fe1, 0x95361c57, 0xffea3f1b, 0x1a094c84},
Field12: []int64{8308420747267165049, 3664160795077875961, 7868970059161834817, 7237335984251173739, 5254748003907196506, 3362259627111837480, 430460752854552122, 5119635556501066533, 1277716037866233522, 9185775384759813768, 833932430882717888, 7986528304451297640, 6792233378368656337, 2074207091120609721, 1788723326198279432, 7756514594746453657, 2283775964901597324, 3061497730110517191, 7733947890656120277, 626967303632386244, 7822928600388582821, 3489658753000061230, 168869995163005961, 248814782163480763, 477885608911386247, 4198422415674133867, 3379354662797976109, 9925112544736939, 1486335136459138480, 4561560414032850671, 1010864164014091267, 186722821683803084, 5106357936724819318, 1298160820191228988, 4675403242419953145, 7130634540106489752, 7101280006672440929, 7176058292431955718, 9109875054097770321, 6810974877085322872, 4736707874303993641, 8993135362721382187, 6857881554990254283, 3704748883307461680, 1099360832887634994, 5207691918707192633, 5984721695043995243},
}
size := proto.Size(n)
data, err := proto.Marshal(n)
if err != nil {
panic(err)
}
if len(data) != size {
t.Fatalf("expected %v, but got %v diff is %v", len(data), size, len(data)-size)
}
}
func testSize(m interface {
proto.Message
Size() int
}, desc string, expected int) ([]byte, error) {
data, err := proto.Marshal(m)
if err != nil {
return nil, err
}
protoSize := proto.Size(m)
mSize := m.Size()
lenData := len(data)
if protoSize != mSize || protoSize != lenData || mSize != lenData {
return nil, fmt.Errorf("%s proto.Size(m){%d} != m.Size(){%d} != len(data){%d}", desc, protoSize, mSize, lenData)
}
if got := protoSize; got != expected {
return nil, fmt.Errorf("%s proto.Size(m) got %d expected %d", desc, got, expected)
}
if got := mSize; got != expected {
return nil, fmt.Errorf("%s m.Size() got %d expected %d", desc, got, expected)
}
if got := lenData; got != expected {
return nil, fmt.Errorf("%s len(data) got %d expected %d", desc, got, expected)
}
return data, nil
}
func TestInt32Int64Compatibility(t *testing.T) {
//test nullable int32 and int64
data1, err := testSize(&NinOptNative{
Field3: proto.Int32(-1),
}, "nullable", 11)
if err != nil {
t.Error(err)
}
//change marshaled data1 to unmarshal into 4th field which is an int64
data1[0] = uint8(uint32(4 /*fieldNumber*/)<<3 | uint32(0 /*wireType*/))
u1 := &NinOptNative{}
if err = proto.Unmarshal(data1, u1); err != nil {
t.Error(err)
}
if !u1.Equal(&NinOptNative{
Field4: proto.Int64(-1),
}) {
t.Error("nullable unmarshaled int32 is not the same int64")
}
//test non-nullable int32 and int64
data2, err := testSize(&NidOptNative{
Field3: -1,
}, "non nullable", 67)
if err != nil {
t.Error(err)
}
//change marshaled data2 to unmarshal into 4th field which is an int64
field3 := uint8(uint32(3 /*fieldNumber*/)<<3 | uint32(0 /*wireType*/))
field4 := uint8(uint32(4 /*fieldNumber*/)<<3 | uint32(0 /*wireType*/))
for i, c := range data2 {
if c == field4 {
data2[i] = field3
} else if c == field3 {
data2[i] = field4
}
}
u2 := &NidOptNative{}
if err = proto.Unmarshal(data2, u2); err != nil {
t.Error(err)
}
if !u2.Equal(&NidOptNative{
Field4: -1,
}) {
t.Error("non nullable unmarshaled int32 is not the same int64")
}
//test packed repeated int32 and int64
m4 := &NinRepPackedNative{
Field3: []int32{-1},
}
data4, err := testSize(m4, "packed", 12)
if err != nil {
t.Error(err)
}
u4 := &NinRepPackedNative{}
if err := proto.Unmarshal(data4, u4); err != nil {
t.Error(err)
}
if err := u4.VerboseEqual(m4); err != nil {
t.Fatalf("%#v", u4)
}
//test repeated int32 and int64
if _, err := testSize(&NinRepNative{
Field3: []int32{-1},
}, "repeated", 11); err != nil {
t.Error(err)
}
t.Logf("tested all")
}
func TestRepeatedExtensionsMsgsIssue161(t *testing.T) {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
rep := 10
nins := make([]*NinOptNative, rep)
for i := range nins {
nins[i] = NewPopulatedNinOptNative(r, true)
}
input := &MyExtendable{}
if err := proto.SetExtension(input, E_FieldE, nins); err != nil {
t.Fatal(err)
}
data, err := proto.Marshal(input)
if err != nil {
t.Fatal(err)
}
output := &MyExtendable{}
if err := proto.Unmarshal(data, output); err != nil {
t.Fatal(err)
}
if !input.Equal(output) {
t.Fatal("expected equal")
}
data2, err2 := proto.Marshal(output)
if err2 != nil {
t.Fatal(err2)
}
if len(data) != len(data2) {
t.Fatal("expected equal length buffers")
}
}
func TestRepeatedExtensionsFieldsIssue161(t *testing.T) {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
rep := 10
ints := make([]int64, rep)
for i := range ints {
ints[i] = r.Int63()
}
input := &MyExtendable{}
if err := proto.SetExtension(input, E_FieldD, ints); err != nil {
t.Fatal(err)
}
data, err := proto.Marshal(input)
if err != nil {
t.Fatal(err)
}
output := &MyExtendable{}
if err := proto.Unmarshal(data, output); err != nil {
t.Fatal(err)
}
if !input.Equal(output) {
t.Fatal("expected equal")
}
data2, err2 := proto.Marshal(output)
if err2 != nil {
t.Fatal(err2)
}
if len(data) != len(data2) {
t.Fatal("expected equal length buffers")
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,626 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package test;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.goproto_enum_prefix_all) = false;
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.equal_all) = true;
option (gogoproto.verbose_equal_all) = true;
option (gogoproto.stringer_all) = true;
option (gogoproto.gostring_all) = true;
option (gogoproto.face_all) = true;
option (gogoproto.description_all) = true;
option (gogoproto.testgen_all) = true;
option (gogoproto.populate_all) = true;
option (gogoproto.benchgen_all) = true;
option (gogoproto.unmarshaler_all) = false;
option (gogoproto.marshaler_all) = false;
option (gogoproto.sizer_all) = true;
option (gogoproto.protosizer_all) = false;
option (gogoproto.goproto_enum_stringer_all) = false;
option (gogoproto.enum_stringer_all) = true;
option (gogoproto.unsafe_marshaler_all) = false;
option (gogoproto.unsafe_unmarshaler_all) = true;
option (gogoproto.compare_all) = true;
message NidOptNative {
optional double Field1 = 1 [(gogoproto.nullable) = false];
optional float Field2 = 2 [(gogoproto.nullable) = false];
optional int32 Field3 = 3 [(gogoproto.nullable) = false];
optional int64 Field4 = 4 [(gogoproto.nullable) = false];
optional uint32 Field5 = 5 [(gogoproto.nullable) = false];
optional uint64 Field6 = 6 [(gogoproto.nullable) = false];
optional sint32 Field7 = 7 [(gogoproto.nullable) = false];
optional sint64 Field8 = 8 [(gogoproto.nullable) = false];
optional fixed32 Field9 = 9 [(gogoproto.nullable) = false];
optional sfixed32 Field10 = 10 [(gogoproto.nullable) = false];
optional fixed64 Field11 = 11 [(gogoproto.nullable) = false];
optional sfixed64 Field12 = 12 [(gogoproto.nullable) = false];
optional bool Field13 = 13 [(gogoproto.nullable) = false];
optional string Field14 = 14 [(gogoproto.nullable) = false];
optional bytes Field15 = 15 [(gogoproto.nullable) = false];
}
message NinOptNative {
optional double Field1 = 1;
optional float Field2 = 2;
optional int32 Field3 = 3;
optional int64 Field4 = 4;
optional uint32 Field5 = 5;
optional uint64 Field6 = 6;
optional sint32 Field7 = 7;
optional sint64 Field8 = 8;
optional fixed32 Field9 = 9;
optional sfixed32 Field10 = 10;
optional fixed64 Field11 = 11;
optional sfixed64 Field12 = 12;
optional bool Field13 = 13;
optional string Field14 = 14;
optional bytes Field15 = 15;
}
message NidRepNative {
repeated double Field1 = 1 [(gogoproto.nullable) = false];
repeated float Field2 = 2 [(gogoproto.nullable) = false];
repeated int32 Field3 = 3 [(gogoproto.nullable) = false];
repeated int64 Field4 = 4 [(gogoproto.nullable) = false];
repeated uint32 Field5 = 5 [(gogoproto.nullable) = false];
repeated uint64 Field6 = 6 [(gogoproto.nullable) = false];
repeated sint32 Field7 = 7 [(gogoproto.nullable) = false];
repeated sint64 Field8 = 8 [(gogoproto.nullable) = false];
repeated fixed32 Field9 = 9 [(gogoproto.nullable) = false];
repeated sfixed32 Field10 = 10 [(gogoproto.nullable) = false];
repeated fixed64 Field11 = 11 [(gogoproto.nullable) = false];
repeated sfixed64 Field12 = 12 [(gogoproto.nullable) = false];
repeated bool Field13 = 13 [(gogoproto.nullable) = false];
repeated string Field14 = 14 [(gogoproto.nullable) = false];
repeated bytes Field15 = 15 [(gogoproto.nullable) = false];
}
message NinRepNative {
repeated double Field1 = 1;
repeated float Field2 = 2;
repeated int32 Field3 = 3;
repeated int64 Field4 = 4;
repeated uint32 Field5 = 5;
repeated uint64 Field6 = 6;
repeated sint32 Field7 = 7;
repeated sint64 Field8 = 8;
repeated fixed32 Field9 = 9;
repeated sfixed32 Field10 = 10;
repeated fixed64 Field11 = 11;
repeated sfixed64 Field12 = 12;
repeated bool Field13 = 13;
repeated string Field14 = 14;
repeated bytes Field15 = 15;
}
message NidRepPackedNative {
repeated double Field1 = 1 [(gogoproto.nullable) = false, packed = true];
repeated float Field2 = 2 [(gogoproto.nullable) = false, packed = true];
repeated int32 Field3 = 3 [(gogoproto.nullable) = false, packed = true];
repeated int64 Field4 = 4 [(gogoproto.nullable) = false, packed = true];
repeated uint32 Field5 = 5 [(gogoproto.nullable) = false, packed = true];
repeated uint64 Field6 = 6 [(gogoproto.nullable) = false, packed = true];
repeated sint32 Field7 = 7 [(gogoproto.nullable) = false, packed = true];
repeated sint64 Field8 = 8 [(gogoproto.nullable) = false, packed = true];
repeated fixed32 Field9 = 9 [(gogoproto.nullable) = false, packed = true];
repeated sfixed32 Field10 = 10 [(gogoproto.nullable) = false, packed = true];
repeated fixed64 Field11 = 11 [(gogoproto.nullable) = false, packed = true];
repeated sfixed64 Field12 = 12 [(gogoproto.nullable) = false, packed = true];
repeated bool Field13 = 13 [(gogoproto.nullable) = false, packed = true];
}
message NinRepPackedNative {
repeated double Field1 = 1 [packed = true];
repeated float Field2 = 2 [packed = true];
repeated int32 Field3 = 3 [packed = true];
repeated int64 Field4 = 4 [packed = true];
repeated uint32 Field5 = 5 [packed = true];
repeated uint64 Field6 = 6 [packed = true];
repeated sint32 Field7 = 7 [packed = true];
repeated sint64 Field8 = 8 [packed = true];
repeated fixed32 Field9 = 9 [packed = true];
repeated sfixed32 Field10 = 10 [packed = true];
repeated fixed64 Field11 = 11 [packed = true];
repeated sfixed64 Field12 = 12 [packed = true];
repeated bool Field13 = 13 [packed = true];
}
message NidOptStruct {
optional double Field1 = 1 [(gogoproto.nullable) = false];
optional float Field2 = 2 [(gogoproto.nullable) = false];
optional NidOptNative Field3 = 3 [(gogoproto.nullable) = false];
optional NinOptNative Field4 = 4 [(gogoproto.nullable) = false];
optional uint64 Field6 = 6 [(gogoproto.nullable) = false];
optional sint32 Field7 = 7 [(gogoproto.nullable) = false];
optional NidOptNative Field8 = 8 [(gogoproto.nullable) = false];
optional bool Field13 = 13 [(gogoproto.nullable) = false];
optional string Field14 = 14 [(gogoproto.nullable) = false];
optional bytes Field15 = 15 [(gogoproto.nullable) = false];
}
message NinOptStruct {
optional double Field1 = 1;
optional float Field2 = 2;
optional NidOptNative Field3 = 3;
optional NinOptNative Field4 = 4;
optional uint64 Field6 = 6;
optional sint32 Field7 = 7;
optional NidOptNative Field8 = 8;
optional bool Field13 = 13;
optional string Field14 = 14;
optional bytes Field15 = 15;
}
message NidRepStruct {
repeated double Field1 = 1 [(gogoproto.nullable) = false];
repeated float Field2 = 2 [(gogoproto.nullable) = false];
repeated NidOptNative Field3 = 3 [(gogoproto.nullable) = false];
repeated NinOptNative Field4 = 4 [(gogoproto.nullable) = false];
repeated uint64 Field6 = 6 [(gogoproto.nullable) = false];
repeated sint32 Field7 = 7 [(gogoproto.nullable) = false];
repeated NidOptNative Field8 = 8 [(gogoproto.nullable) = false];
repeated bool Field13 = 13 [(gogoproto.nullable) = false];
repeated string Field14 = 14 [(gogoproto.nullable) = false];
repeated bytes Field15 = 15 [(gogoproto.nullable) = false];
}
message NinRepStruct {
repeated double Field1 = 1;
repeated float Field2 = 2;
repeated NidOptNative Field3 = 3;
repeated NinOptNative Field4 = 4;
repeated uint64 Field6 = 6;
repeated sint32 Field7 = 7;
repeated NidOptNative Field8 = 8;
repeated bool Field13 = 13;
repeated string Field14 = 14;
repeated bytes Field15 = 15;
}
message NidEmbeddedStruct {
optional NidOptNative Field1 = 1 [(gogoproto.embed) = true];
optional NidOptNative Field200 = 200 [(gogoproto.nullable) = false];
optional bool Field210 = 210 [(gogoproto.nullable) = false];
}
message NinEmbeddedStruct {
optional NidOptNative Field1 = 1 [(gogoproto.embed) = true];
optional NidOptNative Field200 = 200;
optional bool Field210 = 210;
}
message NidNestedStruct {
optional NidOptStruct Field1 = 1 [(gogoproto.nullable) = false];
repeated NidRepStruct Field2 = 2 [(gogoproto.nullable) = false];
}
message NinNestedStruct {
optional NinOptStruct Field1 = 1;
repeated NinRepStruct Field2 = 2;
}
message NidOptCustom {
optional bytes Id = 1 [(gogoproto.customtype) = "Uuid", (gogoproto.nullable) = false];
optional bytes Value = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128", (gogoproto.nullable) = false];
}
message CustomDash {
optional bytes Value = 1 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom-dash-type.Bytes"];
}
message NinOptCustom {
optional bytes Id = 1 [(gogoproto.customtype) = "Uuid"];
optional bytes Value = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"];
}
message NidRepCustom {
repeated bytes Id = 1 [(gogoproto.customtype) = "Uuid", (gogoproto.nullable) = false];
repeated bytes Value = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128", (gogoproto.nullable) = false];
}
message NinRepCustom {
repeated bytes Id = 1 [(gogoproto.customtype) = "Uuid"];
repeated bytes Value = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"];
}
message NinOptNativeUnion {
option (gogoproto.onlyone) = true;
optional double Field1 = 1;
optional float Field2 = 2;
optional int32 Field3 = 3;
optional int64 Field4 = 4;
optional uint32 Field5 = 5;
optional uint64 Field6 = 6;
optional bool Field13 = 13;
optional string Field14 = 14;
optional bytes Field15 = 15;
}
message NinOptStructUnion {
option (gogoproto.onlyone) = true;
optional double Field1 = 1;
optional float Field2 = 2;
optional NidOptNative Field3 = 3;
optional NinOptNative Field4 = 4;
optional uint64 Field6 = 6;
optional sint32 Field7 = 7;
optional bool Field13 = 13;
optional string Field14 = 14;
optional bytes Field15 = 15;
}
message NinEmbeddedStructUnion {
option (gogoproto.onlyone) = true;
optional NidOptNative Field1 = 1 [(gogoproto.embed) = true];
optional NinOptNative Field200 = 200;
optional bool Field210 = 210;
}
message NinNestedStructUnion {
option (gogoproto.onlyone) = true;
optional NinOptNativeUnion Field1 = 1;
optional NinOptStructUnion Field2 = 2;
optional NinEmbeddedStructUnion Field3 = 3;
}
message Tree {
option (gogoproto.onlyone) = true;
optional OrBranch Or = 1;
optional AndBranch And = 2;
optional Leaf Leaf = 3;
}
message OrBranch {
optional Tree Left = 1 [(gogoproto.nullable) = false];
optional Tree Right = 2 [(gogoproto.nullable) = false];
}
message AndBranch {
optional Tree Left = 1 [(gogoproto.nullable) = false];
optional Tree Right = 2 [(gogoproto.nullable) = false];
}
message Leaf {
optional int64 Value = 1 [(gogoproto.nullable) = false];
optional string StrValue = 2 [(gogoproto.nullable) = false];
}
message DeepTree {
option (gogoproto.onlyone) = true;
optional ADeepBranch Down = 1;
optional AndDeepBranch And = 2;
optional DeepLeaf Leaf = 3;
}
message ADeepBranch {
optional DeepTree Down = 2 [(gogoproto.nullable) = false];
}
message AndDeepBranch {
optional DeepTree Left = 1 [(gogoproto.nullable) = false];
optional DeepTree Right = 2 [(gogoproto.nullable) = false];
}
message DeepLeaf {
optional Tree Tree = 1 [(gogoproto.nullable) = false];
}
message Nil {
}
enum TheTestEnum {
A = 0;
B = 1;
C = 2;
}
enum AnotherTestEnum {
option (gogoproto.goproto_enum_prefix) = false;
D = 10;
E = 11;
}
// YetAnotherTestEnum is used to test cross-package import of custom name
// fields and default resolution.
enum YetAnotherTestEnum {
option (gogoproto.goproto_enum_prefix) = false;
AA = 0;
BB = 1 [(gogoproto.enumvalue_customname) = "BetterYetBB"];
}
// YetAnotherTestEnum is used to test cross-package import of custom name
// fields and default resolution.
enum YetYetAnotherTestEnum {
option (gogoproto.goproto_enum_prefix) = true;
CC = 0;
DD = 1 [(gogoproto.enumvalue_customname) = "BetterYetDD"];
}
message NidOptEnum {
optional TheTestEnum Field1 = 1 [(gogoproto.nullable) = false];
}
message NinOptEnum {
optional TheTestEnum Field1 = 1;
optional YetAnotherTestEnum Field2 = 2;
optional YetYetAnotherTestEnum Field3 = 3;
}
message NidRepEnum {
repeated TheTestEnum Field1 = 1 [(gogoproto.nullable) = false];
repeated YetAnotherTestEnum Field2 = 2 [(gogoproto.nullable) = false];
repeated YetYetAnotherTestEnum Field3 = 3 [(gogoproto.nullable) = false];
}
message NinRepEnum {
repeated TheTestEnum Field1 = 1;
repeated YetAnotherTestEnum Field2 = 2;
repeated YetYetAnotherTestEnum Field3 = 3;
}
message NinOptEnumDefault {
option (gogoproto.goproto_getters) = true;
option (gogoproto.face) = false;
optional TheTestEnum Field1 = 1 [default=C];
optional YetAnotherTestEnum Field2 = 2 [default=BB];
optional YetYetAnotherTestEnum Field3 = 3 [default=CC];
}
message AnotherNinOptEnum {
optional AnotherTestEnum Field1 = 1;
optional YetAnotherTestEnum Field2 = 2;
optional YetYetAnotherTestEnum Field3 = 3;
}
message AnotherNinOptEnumDefault {
option (gogoproto.goproto_getters) = true;
option (gogoproto.face) = false;
optional AnotherTestEnum Field1 = 1 [default=E];
optional YetAnotherTestEnum Field2 = 2 [default=BB];
optional YetYetAnotherTestEnum Field3 = 3 [default=CC];
}
message Timer {
optional sfixed64 Time1 = 1 [(gogoproto.nullable) = false];
optional sfixed64 Time2 = 2 [(gogoproto.nullable) = false];
optional bytes Data = 3 [(gogoproto.nullable) = false];
}
message MyExtendable {
option (gogoproto.face) = false;
optional int64 Field1 = 1;
extensions 100 to 199;
}
extend MyExtendable {
optional double FieldA = 100;
optional NinOptNative FieldB = 101;
optional NinEmbeddedStruct FieldC = 102;
repeated int64 FieldD = 104;
repeated NinOptNative FieldE = 105;
}
message OtherExtenable {
option (gogoproto.face) = false;
optional int64 Field2 = 2;
extensions 14 to 16;
optional int64 Field13 = 13;
extensions 10 to 12;
optional MyExtendable M = 1;
}
message NestedDefinition {
optional int64 Field1 = 1;
message NestedMessage {
optional fixed64 NestedField1 = 1;
optional NestedNestedMsg NNM = 2;
message NestedNestedMsg {
optional string NestedNestedField1 = 10;
}
}
enum NestedEnum {
TYPE_NESTED = 1;
}
optional NestedEnum EnumField = 2;
optional NestedMessage.NestedNestedMsg NNM = 3;
optional NestedMessage NM = 4;
}
message NestedScope {
optional NestedDefinition.NestedMessage.NestedNestedMsg A = 1;
optional NestedDefinition.NestedEnum B = 2;
optional NestedDefinition.NestedMessage C = 3;
}
message NinOptNativeDefault {
option (gogoproto.goproto_getters) = true;
option (gogoproto.face) = false;
optional double Field1 = 1 [default = 1234.1234];
optional float Field2 = 2 [default = 1234.1234];
optional int32 Field3 = 3 [default = 1234];
optional int64 Field4 = 4 [default = 1234];
optional uint32 Field5 = 5 [default = 1234];
optional uint64 Field6 = 6 [default = 1234];
optional sint32 Field7 = 7 [default = 1234];
optional sint64 Field8 = 8 [default = 1234];
optional fixed32 Field9 = 9 [default = 1234];
optional sfixed32 Field10 = 10 [default = 1234];
optional fixed64 Field11 = 11 [default = 1234];
optional sfixed64 Field12 = 12 [default = 1234];
optional bool Field13 = 13 [default = true];
optional string Field14 = 14 [default = "1234"];
optional bytes Field15 = 15;
}
message CustomContainer {
optional NidOptCustom CustomStruct = 1 [(gogoproto.nullable) = false];
}
message CustomNameNidOptNative {
optional double Field1 = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldA"];
optional float Field2 = 2 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldB"];
optional int32 Field3 = 3 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldC"];
optional int64 Field4 = 4 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldD"];
optional uint32 Field5 = 5 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldE"];
optional uint64 Field6 = 6 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldF"];
optional sint32 Field7 = 7 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldG"];
optional sint64 Field8 = 8 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldH"];
optional fixed32 Field9 = 9 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldI"];
optional sfixed32 Field10 = 10 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldJ"];
optional fixed64 Field11 = 11 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldK"];
optional sfixed64 Field12 = 12 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldL"];
optional bool Field13 = 13 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldM"];
optional string Field14 = 14 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldN"];
optional bytes Field15 = 15 [(gogoproto.nullable) = false, (gogoproto.customname) = "FieldO"];
}
message CustomNameNinOptNative {
optional double Field1 = 1 [(gogoproto.customname) = "FieldA"];
optional float Field2 = 2 [(gogoproto.customname) = "FieldB"];
optional int32 Field3 = 3 [(gogoproto.customname) = "FieldC"];
optional int64 Field4 = 4 [(gogoproto.customname) = "FieldD"];
optional uint32 Field5 = 5 [(gogoproto.customname) = "FieldE"];
optional uint64 Field6 = 6 [(gogoproto.customname) = "FieldF"];
optional sint32 Field7 = 7 [(gogoproto.customname) = "FieldG"];
optional sint64 Field8 = 8 [(gogoproto.customname) = "FieldH"];
optional fixed32 Field9 = 9 [(gogoproto.customname) = "FieldI"];
optional sfixed32 Field10 = 10 [(gogoproto.customname) = "FieldJ"];
optional fixed64 Field11 = 11 [(gogoproto.customname) = "FieldK"];
optional sfixed64 Field12 = 12 [(gogoproto.customname) = "FielL"];
optional bool Field13 = 13 [(gogoproto.customname) = "FieldM"];
optional string Field14 = 14 [(gogoproto.customname) = "FieldN"];
optional bytes Field15 = 15 [(gogoproto.customname) = "FieldO"];
}
message CustomNameNinRepNative {
repeated double Field1 = 1 [(gogoproto.customname) = "FieldA"];
repeated float Field2 = 2 [(gogoproto.customname) = "FieldB"];
repeated int32 Field3 = 3 [(gogoproto.customname) = "FieldC"];
repeated int64 Field4 = 4 [(gogoproto.customname) = "FieldD"];
repeated uint32 Field5 = 5 [(gogoproto.customname) = "FieldE"];
repeated uint64 Field6 = 6 [(gogoproto.customname) = "FieldF"];
repeated sint32 Field7 = 7 [(gogoproto.customname) = "FieldG"];
repeated sint64 Field8 = 8 [(gogoproto.customname) = "FieldH"];
repeated fixed32 Field9 = 9 [(gogoproto.customname) = "FieldI"];
repeated sfixed32 Field10 = 10 [(gogoproto.customname) = "FieldJ"];
repeated fixed64 Field11 = 11 [(gogoproto.customname) = "FieldK"];
repeated sfixed64 Field12 = 12 [(gogoproto.customname) = "FieldL"];
repeated bool Field13 = 13 [(gogoproto.customname) = "FieldM"];
repeated string Field14 = 14 [(gogoproto.customname) = "FieldN"];
repeated bytes Field15 = 15 [(gogoproto.customname) = "FieldO"];
}
message CustomNameNinStruct {
optional double Field1 = 1 [(gogoproto.customname) = "FieldA"];
optional float Field2 = 2 [(gogoproto.customname) = "FieldB"];
optional NidOptNative Field3 = 3 [(gogoproto.customname) = "FieldC"];
repeated NinOptNative Field4 = 4 [(gogoproto.customname) = "FieldD"];
optional uint64 Field6 = 6 [(gogoproto.customname) = "FieldE"];
optional sint32 Field7 = 7 [(gogoproto.customname) = "FieldF"];
optional NidOptNative Field8 = 8 [(gogoproto.customname) = "FieldG"];
optional bool Field13 = 13 [(gogoproto.customname) = "FieldH"];
optional string Field14 = 14 [(gogoproto.customname) = "FieldI"];
optional bytes Field15 = 15 [(gogoproto.customname) = "FieldJ"];
}
message CustomNameCustomType {
optional bytes Id = 1 [(gogoproto.customname) = "FieldA", (gogoproto.customtype) = "Uuid"];
optional bytes Value = 2 [(gogoproto.customname) = "FieldB", (gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"];
repeated bytes Ids = 3 [(gogoproto.customname) = "FieldC", (gogoproto.customtype) = "Uuid"];
repeated bytes Values = 4 [(gogoproto.customname) = "FieldD", (gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"];
}
message CustomNameNinEmbeddedStructUnion {
option (gogoproto.onlyone) = true;
optional NidOptNative Field1 = 1 [(gogoproto.embed) = true];
optional NinOptNative Field200 = 200 [(gogoproto.customname) = "FieldA"];
optional bool Field210 = 210 [(gogoproto.customname) = "FieldB"];
}
message CustomNameEnum {
optional TheTestEnum Field1 = 1 [(gogoproto.customname) = "FieldA"];
repeated TheTestEnum Field2 = 2 [(gogoproto.customname) = "FieldB"];
}
message NoExtensionsMap {
option (gogoproto.face) = false;
option (gogoproto.goproto_extensions_map) = false;
optional int64 Field1 = 1;
extensions 100 to 199;
}
extend NoExtensionsMap {
optional double FieldA1 = 100;
optional NinOptNative FieldB1 = 101;
optional NinEmbeddedStruct FieldC1 = 102;
}
message Unrecognized {
option (gogoproto.goproto_unrecognized) = false;
optional string Field1 = 1;
}
message UnrecognizedWithInner {
message Inner {
option (gogoproto.goproto_unrecognized) = false;
optional uint32 Field1 = 1;
}
repeated Inner embedded = 1;
optional string Field2 = 2;
}
message UnrecognizedWithEmbed {
message Embedded {
option (gogoproto.goproto_unrecognized) = false;
optional uint32 Field1 = 1;
}
optional Embedded embedded = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false];
optional string Field2 = 2;
}
message Node {
optional string Label = 1;
repeated Node Children = 2;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,133 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package test
import (
"bytes"
"encoding/hex"
"encoding/json"
)
func PutLittleEndianUint64(b []byte, offset int, v uint64) {
b[offset] = byte(v)
b[offset+1] = byte(v >> 8)
b[offset+2] = byte(v >> 16)
b[offset+3] = byte(v >> 24)
b[offset+4] = byte(v >> 32)
b[offset+5] = byte(v >> 40)
b[offset+6] = byte(v >> 48)
b[offset+7] = byte(v >> 56)
}
type Uuid []byte
func (uuid Uuid) Marshal() ([]byte, error) {
if len(uuid) == 0 {
return nil, nil
}
return []byte(uuid), nil
}
func (uuid Uuid) MarshalTo(data []byte) (n int, err error) {
if len(uuid) == 0 {
return 0, nil
}
copy(data, uuid)
return 16, nil
}
func (uuid *Uuid) Unmarshal(data []byte) error {
if len(data) == 0 {
uuid = nil
return nil
}
id := Uuid(make([]byte, 16))
copy(id, data)
*uuid = id
return nil
}
func (uuid *Uuid) Size() int {
if uuid == nil {
return 0
}
if len(*uuid) == 0 {
return 0
}
return 16
}
func (uuid Uuid) MarshalJSON() ([]byte, error) {
s := hex.EncodeToString([]byte(uuid))
return json.Marshal(s)
}
func (uuid *Uuid) UnmarshalJSON(data []byte) error {
var s string
err := json.Unmarshal(data, &s)
if err != nil {
return err
}
d, err := hex.DecodeString(s)
if err != nil {
return err
}
*uuid = Uuid(d)
return nil
}
func (uuid Uuid) Equal(other Uuid) bool {
return bytes.Equal(uuid[0:], other[0:])
}
func (uuid Uuid) Compare(other Uuid) int {
return bytes.Compare(uuid[0:], other[0:])
}
type int63 interface {
Int63() int64
}
func NewPopulatedUuid(r int63) *Uuid {
u := RandV4(r)
return &u
}
func RandV4(r int63) Uuid {
uuid := make(Uuid, 16)
uuid.RandV4(r)
return uuid
}
func (uuid Uuid) RandV4(r int63) {
PutLittleEndianUint64(uuid, 0, uint64(r.Int63()))
PutLittleEndianUint64(uuid, 8, uint64(r.Int63()))
uuid[6] = (uuid[6] & 0xf) | 0x40
uuid[8] = (uuid[8] & 0x3f) | 0x80
}

View file

@ -0,0 +1,104 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/*
Package custom contains custom types for test and example purposes.
These types are used by the test structures generated by gogoprotobuf.
*/
package custom
import (
"bytes"
"encoding/json"
)
type Bytes []byte
func (b Bytes) Marshal() ([]byte, error) {
buffer := make([]byte, len(b))
_, err := b.MarshalTo(buffer)
return buffer, err
}
func (b Bytes) MarshalTo(data []byte) (n int, err error) {
copy(data, b)
return len(b), nil
}
func (b *Bytes) Unmarshal(data []byte) error {
if data == nil {
b = nil
return nil
}
pb := make([]byte, len(data))
copy(pb, data)
*b = pb
return nil
}
func (b Bytes) MarshalJSON() ([]byte, error) {
data, err := b.Marshal()
if err != nil {
return nil, err
}
return json.Marshal(data)
}
func (b *Bytes) Size() int {
return len(*b)
}
func (b *Bytes) UnmarshalJSON(data []byte) error {
v := new([]byte)
err := json.Unmarshal(data, v)
if err != nil {
return err
}
return b.Unmarshal(*v)
}
func (this Bytes) Equal(that Bytes) bool {
return bytes.Equal(this, that)
}
func (this Bytes) Compare(that Bytes) int {
return bytes.Compare(this, that)
}
type randy interface {
Intn(n int) int
}
func NewPopulatedBytes(r randy) *Bytes {
l := r.Intn(100)
data := Bytes(make([]byte, l))
for i := 0; i < l; i++ {
data[i] = byte(r.Intn(255))
}
return &data
}

147
vendor/github.com/gogo/protobuf/test/custom/custom.go generated vendored Normal file
View file

@ -0,0 +1,147 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/*
Package custom contains custom types for test and example purposes.
These types are used by the test structures generated by gogoprotobuf.
*/
package custom
import (
"bytes"
"encoding/json"
"errors"
"unsafe"
)
type Uint128 [2]uint64
func (u Uint128) Marshal() ([]byte, error) {
buffer := make([]byte, 16)
_, err := u.MarshalTo(buffer)
return buffer, err
}
func (u Uint128) MarshalTo(data []byte) (n int, err error) {
PutLittleEndianUint128(data, 0, u)
return 16, nil
}
func GetLittleEndianUint64(b []byte, offset int) uint64 {
return *(*uint64)(unsafe.Pointer(&b[offset]))
}
func PutLittleEndianUint64(b []byte, offset int, v uint64) {
b[offset] = byte(v)
b[offset+1] = byte(v >> 8)
b[offset+2] = byte(v >> 16)
b[offset+3] = byte(v >> 24)
b[offset+4] = byte(v >> 32)
b[offset+5] = byte(v >> 40)
b[offset+6] = byte(v >> 48)
b[offset+7] = byte(v >> 56)
}
func PutLittleEndianUint128(buffer []byte, offset int, v [2]uint64) {
PutLittleEndianUint64(buffer, offset, v[0])
PutLittleEndianUint64(buffer, offset+8, v[1])
}
func GetLittleEndianUint128(buffer []byte, offset int) (value [2]uint64) {
value[0] = GetLittleEndianUint64(buffer, offset)
value[1] = GetLittleEndianUint64(buffer, offset+8)
return
}
func (u *Uint128) Unmarshal(data []byte) error {
if data == nil {
u = nil
return nil
}
if len(data) == 0 {
pu := Uint128{}
*u = pu
return nil
}
if len(data) != 16 {
return errors.New("Uint128: invalid length")
}
pu := Uint128(GetLittleEndianUint128(data, 0))
*u = pu
return nil
}
func (u Uint128) MarshalJSON() ([]byte, error) {
data, err := u.Marshal()
if err != nil {
return nil, err
}
return json.Marshal(data)
}
func (u Uint128) Size() int {
return 16
}
func (u *Uint128) UnmarshalJSON(data []byte) error {
v := new([]byte)
err := json.Unmarshal(data, v)
if err != nil {
return err
}
return u.Unmarshal(*v)
}
func (this Uint128) Equal(that Uint128) bool {
return this == that
}
func (this Uint128) Compare(that Uint128) int {
thisdata, err := this.Marshal()
if err != nil {
panic(err)
}
thatdata, err := that.Marshal()
if err != nil {
panic(err)
}
return bytes.Compare(thisdata, thatdata)
}
type randy interface {
Intn(n int) int
}
func NewPopulatedUint128(r randy) *Uint128 {
data := make([]byte, 16)
for i := 0; i < 16; i++ {
data[i] = byte(r.Intn(255))
}
u := Uint128(GetLittleEndianUint128(data, 0))
return &u
}

View file

@ -0,0 +1,43 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package custom
import (
"testing"
)
func TestUint128(t *testing.T) {
var uint128a = Uint128{0, 1}
buf := make([]byte, 16)
PutLittleEndianUint128(buf, 0, uint128a)
uint128b := GetLittleEndianUint128(buf, 0)
if !uint128a.Equal(uint128b) {
t.Fatalf("%v != %v", uint128a, uint128b)
}
}

View file

@ -0,0 +1,30 @@
# Protocol Buffers for Go with Gadgets
#
# Copyright (c) 2013, The GoGo Authors. All rights reserved.
# http://github.com/gogo/protobuf
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
regenerate:
(protoc --proto_path=../../../../../:../../protobuf/:. --gogo_out=. proto.proto)

View file

@ -0,0 +1,34 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package custombytesnonstruct
import testing "testing"
func TestCustomBytesNonStruct(t *testing.T) {
}

View file

@ -0,0 +1,36 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package custombytesnonstruct
type CustomType int
func (c *CustomType) Unmarshal(data []byte) error {
data[0] = 42
return nil
}

View file

@ -0,0 +1,282 @@
// Code generated by protoc-gen-gogo.
// source: proto.proto
// DO NOT EDIT!
/*
Package custombytesnonstruct is a generated protocol buffer package.
It is generated from these files:
proto.proto
It has these top-level messages:
Object
*/
package custombytesnonstruct
import proto "github.com/gogo/protobuf/proto"
import fmt "fmt"
import math "math"
import _ "github.com/gogo/protobuf/gogoproto"
import io "io"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type Object struct {
CustomField1 *CustomType `protobuf:"bytes,1,opt,name=CustomField1,json=customField1,customtype=CustomType" json:"CustomField1,omitempty"`
CustomField2 []CustomType `protobuf:"bytes,2,rep,name=CustomField2,json=customField2,customtype=CustomType" json:"CustomField2,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *Object) Reset() { *m = Object{} }
func (m *Object) String() string { return proto.CompactTextString(m) }
func (*Object) ProtoMessage() {}
func (*Object) Descriptor() ([]byte, []int) { return fileDescriptorProto, []int{0} }
func init() {
proto.RegisterType((*Object)(nil), "custombytesnonstruct.Object")
}
func (m *Object) Unmarshal(data []byte) error {
l := len(data)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowProto
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := data[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: Object: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: Object: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field CustomField1", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowProto
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := data[iNdEx]
iNdEx++
byteLen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthProto
}
postIndex := iNdEx + byteLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
var v CustomType
m.CustomField1 = &v
if err := m.CustomField1.Unmarshal(data[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field CustomField2", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowProto
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := data[iNdEx]
iNdEx++
byteLen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthProto
}
postIndex := iNdEx + byteLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
var v CustomType
m.CustomField2 = append(m.CustomField2, v)
if err := m.CustomField2[len(m.CustomField2)-1].Unmarshal(data[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipProto(data[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthProto
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...)
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipProto(data []byte) (n int, err error) {
l := len(data)
iNdEx := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowProto
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := data[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowProto
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if data[iNdEx-1] < 0x80 {
break
}
}
return iNdEx, nil
case 1:
iNdEx += 8
return iNdEx, nil
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowProto
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := data[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
iNdEx += length
if length < 0 {
return 0, ErrInvalidLengthProto
}
return iNdEx, nil
case 3:
for {
var innerWire uint64
var start int = iNdEx
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowProto
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := data[iNdEx]
iNdEx++
innerWire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
innerWireType := int(innerWire & 0x7)
if innerWireType == 4 {
break
}
next, err := skipProto(data[start:])
if err != nil {
return 0, err
}
iNdEx = start + next
}
return iNdEx, nil
case 4:
return iNdEx, nil
case 5:
iNdEx += 4
return iNdEx, nil
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
}
panic("unreachable")
}
var (
ErrInvalidLengthProto = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowProto = fmt.Errorf("proto: integer overflow")
)
func init() { proto.RegisterFile("proto.proto", fileDescriptorProto) }
var fileDescriptorProto = []byte{
// 149 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xe2, 0x2e, 0x28, 0xca, 0x2f,
0xc9, 0xd7, 0x03, 0x93, 0x42, 0x22, 0xc9, 0xa5, 0xc5, 0x25, 0xf9, 0xb9, 0x49, 0x95, 0x25, 0xa9,
0xc5, 0x79, 0xf9, 0x79, 0xc5, 0x25, 0x45, 0xa5, 0xc9, 0x25, 0x52, 0xba, 0xe9, 0x99, 0x25, 0x19,
0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xe9, 0xf9, 0xe9, 0xf9, 0xfa, 0x60, 0xc5, 0x49, 0xa5,
0x69, 0x60, 0x1e, 0x98, 0x03, 0x66, 0x41, 0x0c, 0x51, 0x2a, 0xe0, 0x62, 0xf3, 0x4f, 0xca, 0x4a,
0x4d, 0x2e, 0x11, 0x32, 0xe2, 0xe2, 0x71, 0x06, 0x1b, 0xe8, 0x96, 0x99, 0x9a, 0x93, 0x62, 0x28,
0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0xe3, 0xc4, 0x77, 0xeb, 0x9e, 0x3c, 0x17, 0x44, 0x3c, 0xa4, 0xb2,
0x20, 0x35, 0x88, 0x27, 0x19, 0x49, 0x0d, 0x9a, 0x1e, 0x23, 0x09, 0x26, 0x05, 0x66, 0x02, 0x7a,
0x8c, 0x9c, 0x58, 0x2e, 0x3c, 0x92, 0x63, 0x04, 0x04, 0x00, 0x00, 0xff, 0xff, 0x42, 0x52, 0xad,
0x49, 0xca, 0x00, 0x00, 0x00,
}

View file

@ -0,0 +1,39 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package custombytesnonstruct;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.unmarshaler_all) = true;
message Object {
optional bytes CustomField1 = 1 [(gogoproto.customtype) = "CustomType"];
repeated bytes CustomField2 = 2 [(gogoproto.customtype) = "CustomType"];
}

Some files were not shown because too many files have changed in this diff Show more