1// Code generated by protoc-gen-gogo. DO NOT EDIT. 2// source: enumdecl.proto 3 4package enumdecl 5 6import ( 7 fmt "fmt" 8 _ "github.com/gogo/protobuf/gogoproto" 9 github_com_gogo_protobuf_jsonpb "github.com/gogo/protobuf/jsonpb" 10 github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto" 11 proto "github.com/gogo/protobuf/proto" 12 math "math" 13 math_rand "math/rand" 14 testing "testing" 15 time "time" 16) 17 18// Reference imports to suppress errors if they are not otherwise used. 19var _ = proto.Marshal 20var _ = fmt.Errorf 21var _ = math.Inf 22 23func TestMessageProto(t *testing.T) { 24 seed := time.Now().UnixNano() 25 popr := math_rand.New(math_rand.NewSource(seed)) 26 p := NewPopulatedMessage(popr, false) 27 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 28 if err != nil { 29 t.Fatalf("seed = %d, err = %v", seed, err) 30 } 31 msg := &Message{} 32 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 33 t.Fatalf("seed = %d, err = %v", seed, err) 34 } 35 littlefuzz := make([]byte, len(dAtA)) 36 copy(littlefuzz, dAtA) 37 for i := range dAtA { 38 dAtA[i] = byte(popr.Intn(256)) 39 } 40 if err := p.VerboseEqual(msg); err != nil { 41 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 42 } 43 if !p.Equal(msg) { 44 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 45 } 46 if len(littlefuzz) > 0 { 47 fuzzamount := 100 48 for i := 0; i < fuzzamount; i++ { 49 littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256)) 50 littlefuzz = append(littlefuzz, byte(popr.Intn(256))) 51 } 52 // shouldn't panic 53 _ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg) 54 } 55} 56 57func TestMessageMarshalTo(t *testing.T) { 58 seed := time.Now().UnixNano() 59 popr := math_rand.New(math_rand.NewSource(seed)) 60 p := NewPopulatedMessage(popr, false) 61 size := p.Size() 62 dAtA := make([]byte, size) 63 for i := range dAtA { 64 dAtA[i] = byte(popr.Intn(256)) 65 } 66 _, err := p.MarshalTo(dAtA) 67 if err != nil { 68 t.Fatalf("seed = %d, err = %v", seed, err) 69 } 70 msg := &Message{} 71 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 72 t.Fatalf("seed = %d, err = %v", seed, err) 73 } 74 for i := range dAtA { 75 dAtA[i] = byte(popr.Intn(256)) 76 } 77 if err := p.VerboseEqual(msg); err != nil { 78 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 79 } 80 if !p.Equal(msg) { 81 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 82 } 83} 84 85func BenchmarkMessageProtoMarshal(b *testing.B) { 86 popr := math_rand.New(math_rand.NewSource(616)) 87 total := 0 88 pops := make([]*Message, 10000) 89 for i := 0; i < 10000; i++ { 90 pops[i] = NewPopulatedMessage(popr, false) 91 } 92 b.ResetTimer() 93 for i := 0; i < b.N; i++ { 94 dAtA, err := github_com_gogo_protobuf_proto.Marshal(pops[i%10000]) 95 if err != nil { 96 panic(err) 97 } 98 total += len(dAtA) 99 } 100 b.SetBytes(int64(total / b.N)) 101} 102 103func BenchmarkMessageProtoUnmarshal(b *testing.B) { 104 popr := math_rand.New(math_rand.NewSource(616)) 105 total := 0 106 datas := make([][]byte, 10000) 107 for i := 0; i < 10000; i++ { 108 dAtA, err := github_com_gogo_protobuf_proto.Marshal(NewPopulatedMessage(popr, false)) 109 if err != nil { 110 panic(err) 111 } 112 datas[i] = dAtA 113 } 114 msg := &Message{} 115 b.ResetTimer() 116 for i := 0; i < b.N; i++ { 117 total += len(datas[i%10000]) 118 if err := github_com_gogo_protobuf_proto.Unmarshal(datas[i%10000], msg); err != nil { 119 panic(err) 120 } 121 } 122 b.SetBytes(int64(total / b.N)) 123} 124 125func TestMessageJSON(t *testing.T) { 126 seed := time.Now().UnixNano() 127 popr := math_rand.New(math_rand.NewSource(seed)) 128 p := NewPopulatedMessage(popr, true) 129 marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{} 130 jsondata, err := marshaler.MarshalToString(p) 131 if err != nil { 132 t.Fatalf("seed = %d, err = %v", seed, err) 133 } 134 msg := &Message{} 135 err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg) 136 if err != nil { 137 t.Fatalf("seed = %d, err = %v", seed, err) 138 } 139 if err := p.VerboseEqual(msg); err != nil { 140 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 141 } 142 if !p.Equal(msg) { 143 t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p) 144 } 145} 146func TestMessageProtoText(t *testing.T) { 147 seed := time.Now().UnixNano() 148 popr := math_rand.New(math_rand.NewSource(seed)) 149 p := NewPopulatedMessage(popr, true) 150 dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p) 151 msg := &Message{} 152 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 153 t.Fatalf("seed = %d, err = %v", seed, err) 154 } 155 if err := p.VerboseEqual(msg); err != nil { 156 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 157 } 158 if !p.Equal(msg) { 159 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 160 } 161} 162 163func TestMessageProtoCompactText(t *testing.T) { 164 seed := time.Now().UnixNano() 165 popr := math_rand.New(math_rand.NewSource(seed)) 166 p := NewPopulatedMessage(popr, true) 167 dAtA := github_com_gogo_protobuf_proto.CompactTextString(p) 168 msg := &Message{} 169 if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { 170 t.Fatalf("seed = %d, err = %v", seed, err) 171 } 172 if err := p.VerboseEqual(msg); err != nil { 173 t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err) 174 } 175 if !p.Equal(msg) { 176 t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) 177 } 178} 179 180func TestMessageVerboseEqual(t *testing.T) { 181 popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) 182 p := NewPopulatedMessage(popr, false) 183 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 184 if err != nil { 185 panic(err) 186 } 187 msg := &Message{} 188 if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { 189 panic(err) 190 } 191 if err := p.VerboseEqual(msg); err != nil { 192 t.Fatalf("%#v !VerboseEqual %#v, since %v", msg, p, err) 193 } 194} 195func TestMessageSize(t *testing.T) { 196 seed := time.Now().UnixNano() 197 popr := math_rand.New(math_rand.NewSource(seed)) 198 p := NewPopulatedMessage(popr, true) 199 size2 := github_com_gogo_protobuf_proto.Size(p) 200 dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) 201 if err != nil { 202 t.Fatalf("seed = %d, err = %v", seed, err) 203 } 204 size := p.Size() 205 if len(dAtA) != size { 206 t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA)) 207 } 208 if size2 != size { 209 t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2) 210 } 211 size3 := github_com_gogo_protobuf_proto.Size(p) 212 if size3 != size { 213 t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3) 214 } 215} 216 217func BenchmarkMessageSize(b *testing.B) { 218 popr := math_rand.New(math_rand.NewSource(616)) 219 total := 0 220 pops := make([]*Message, 1000) 221 for i := 0; i < 1000; i++ { 222 pops[i] = NewPopulatedMessage(popr, false) 223 } 224 b.ResetTimer() 225 for i := 0; i < b.N; i++ { 226 total += pops[i%1000].Size() 227 } 228 b.SetBytes(int64(total / b.N)) 229} 230 231//These tests are generated by github.com/gogo/protobuf/plugin/testgen 232