aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Symonds <dsymonds@golang.org>2012-12-06 15:51:11 +1100
committerDavid Symonds <dsymonds@golang.org>2012-12-06 15:51:11 +1100
commit31faaca69d0e8f015c2756eb12e722ad5302394c (patch)
tree5b62fda6c4d4a7f092944c1edfcd40e8a16ff413
parentbe02a4a20fa460d8c68e31df9d6df1906abe6255 (diff)
downloadprotobuf-31faaca69d0e8f015c2756eb12e722ad5302394c.tar.gz
goprotobuf: Missing test data from a previous CL.
R=iant CC=golang-dev https://codereview.appspot.com/6883048
-rw-r--r--proto/testdata/test.pb.go8
-rw-r--r--proto/text_parser_test.go36
-rw-r--r--protoc-gen-go/descriptor/Makefile2
-rw-r--r--protoc-gen-go/plugin/Makefile2
4 files changed, 46 insertions, 2 deletions
diff --git a/proto/testdata/test.pb.go b/proto/testdata/test.pb.go
index 67c3dc2..cfd1dfd 100644
--- a/proto/testdata/test.pb.go
+++ b/proto/testdata/test.pb.go
@@ -982,6 +982,7 @@ type MyMessage struct {
Bikeshed *MyMessage_Color `protobuf:"varint,7,opt,name=bikeshed,enum=testdata.MyMessage_Color" json:"bikeshed,omitempty"`
Somegroup *MyMessage_SomeGroup `protobuf:"group,8,opt,name=SomeGroup" json:"somegroup,omitempty"`
RepBytes [][]byte `protobuf:"bytes,10,rep,name=rep_bytes" json:"rep_bytes,omitempty"`
+ Bigfloat *float64 `protobuf:"fixed64,11,opt,name=bigfloat" json:"bigfloat,omitempty"`
XXX_extensions map[int32]proto.Extension `json:"-"`
XXX_unrecognized []byte `json:"-"`
}
@@ -1046,6 +1047,13 @@ func (this *MyMessage) GetSomegroup() *MyMessage_SomeGroup {
return nil
}
+func (this *MyMessage) GetBigfloat() float64 {
+ if this != nil && this.Bigfloat != nil {
+ return *this.Bigfloat
+ }
+ return 0
+}
+
type MyMessage_SomeGroup struct {
GroupField *int32 `protobuf:"varint,9,opt,name=group_field" json:"group_field,omitempty"`
}
diff --git a/proto/text_parser_test.go b/proto/text_parser_test.go
index 7ae0759..0821a7d 100644
--- a/proto/text_parser_test.go
+++ b/proto/text_parser_test.go
@@ -32,6 +32,7 @@
package proto_test
import (
+ "math"
"reflect"
"testing"
@@ -194,6 +195,24 @@ var unMarshalTextTests = []UnmarshalTextTest{
},
},
+ // Floating point positive infinity
+ {
+ in: "count: 4 bigfloat: inf",
+ out: &MyMessage{
+ Count: Int32(4),
+ Bigfloat: Float64(math.Inf(1)),
+ },
+ },
+
+ // Floating point negative infinity
+ {
+ in: "count: 4 bigfloat: -inf",
+ out: &MyMessage{
+ Count: Int32(4),
+ Bigfloat: Float64(math.Inf(-1)),
+ },
+ },
+
// Number too large for float32
{
in: "others:< weight: 12345678901234567890123456789012345678901234567890 >",
@@ -296,6 +315,23 @@ var unMarshalTextTests = []UnmarshalTextTest{
},
},
+ // Semicolon between fields
+ {
+ in: `count:3;name:"Calvin"`,
+ out: &MyMessage{
+ Count: Int32(3),
+ Name: String("Calvin"),
+ },
+ },
+ // Comma between fields
+ {
+ in: `count:4,name:"Ezekiel"`,
+ out: &MyMessage{
+ Count: Int32(4),
+ Name: String("Ezekiel"),
+ },
+ },
+
// Extension
buildExtStructTest(`count: 42 [testdata.Ext.more]:<data:"Hello, world!" >`),
buildExtStructTest(`count: 42 [testdata.Ext.more] {data:"Hello, world!"}`),
diff --git a/protoc-gen-go/descriptor/Makefile b/protoc-gen-go/descriptor/Makefile
index e8b454f..dadec21 100644
--- a/protoc-gen-go/descriptor/Makefile
+++ b/protoc-gen-go/descriptor/Makefile
@@ -35,7 +35,7 @@ regenerate:
echo WARNING! THIS RULE IS PROBABLY NOT RIGHT FOR YOUR INSTALLATION
cd $(HOME)/src/protobuf-2.3.0/src && \
protoc --go_out=. ./google/protobuf/descriptor.proto && \
- cp ./google/protobuf/descriptor.pb.go $(GOROOT)/src/pkg/code.google.com/p/goprotobuf/protoc-gen-go/descriptor/descriptor.pb.go
+ cp ./google/protobuf/descriptor.pb.go $(GOPATH)/src/code.google.com/p/goprotobuf/protoc-gen-go/descriptor/descriptor.pb.go
restore:
cp descriptor.pb.golden descriptor.pb.go
diff --git a/protoc-gen-go/plugin/Makefile b/protoc-gen-go/plugin/Makefile
index cc92562..53876cf 100644
--- a/protoc-gen-go/plugin/Makefile
+++ b/protoc-gen-go/plugin/Makefile
@@ -37,7 +37,7 @@ regenerate:
cd $(HOME)/src/protobuf-2.3.0/src && \
protoc --go_out=. ./google/protobuf/compiler/plugin.proto && \
cat ./google/protobuf/compiler/plugin.pb.go | \
- sed '/^import/s;google/protobuf/descriptor.pb;code.google.com/p/goprotobuf/protoc-gen-go/descriptor;' >$(GOROOT)/src/pkg/code.google.com/p/goprotobuf/protoc-gen-go/plugin/plugin.pb.go
+ sed '/^import/s;google/protobuf/descriptor.pb;code.google.com/p/goprotobuf/protoc-gen-go/descriptor;' > $(GOPATH)/src/code.google.com/p/goprotobuf/protoc-gen-go/plugin/plugin.pb.go
restore:
cp plugin.pb.golden plugin.pb.go