@@ -12,6 +12,7 @@ import (
1212 "github.com/golang/protobuf/proto"
1313 "github.com/golang/protobuf/ptypes"
1414 "github.com/golang/protobuf/ptypes/timestamp"
15+ "github.com/golang/protobuf/ptypes/wrappers"
1516 "github.com/grpc-ecosystem/grpc-gateway/runtime"
1617 "github.com/grpc-ecosystem/grpc-gateway/utilities"
1718)
@@ -32,64 +33,96 @@ func TestPopulateParameters(t *testing.T) {
3233 }{
3334 {
3435 values : url.Values {
35- "float_value" : {"1.5" },
36- "double_value" : {"2.5" },
37- "int64_value" : {"-1" },
38- "int32_value" : {"-2" },
39- "uint64_value" : {"3" },
40- "uint32_value" : {"4" },
41- "bool_value" : {"true" },
42- "string_value" : {"str" },
43- "repeated_value" : {"a" , "b" , "c" },
44- "enum_value" : {"1" },
45- "repeated_enum" : {"1" , "2" , "0" },
46- "timestamp_value" : {timeStr },
36+ "float_value" : {"1.5" },
37+ "double_value" : {"2.5" },
38+ "int64_value" : {"-1" },
39+ "int32_value" : {"-2" },
40+ "uint64_value" : {"3" },
41+ "uint32_value" : {"4" },
42+ "bool_value" : {"true" },
43+ "string_value" : {"str" },
44+ "repeated_value" : {"a" , "b" , "c" },
45+ "enum_value" : {"1" },
46+ "repeated_enum" : {"1" , "2" , "0" },
47+ "timestamp_value" : {timeStr },
48+ "wrapper_float_value" : {"1.5" },
49+ "wrapper_double_value" : {"2.5" },
50+ "wrapper_int64_value" : {"-1" },
51+ "wrapper_int32_value" : {"-2" },
52+ "wrapper_u_int64_value" : {"3" },
53+ "wrapper_u_int32_value" : {"4" },
54+ "wrapper_bool_value" : {"true" },
55+ "wrapper_string_value" : {"str" },
4756 },
4857 filter : utilities .NewDoubleArray (nil ),
4958 want : & proto3Message {
50- FloatValue : 1.5 ,
51- DoubleValue : 2.5 ,
52- Int64Value : - 1 ,
53- Int32Value : - 2 ,
54- Uint64Value : 3 ,
55- Uint32Value : 4 ,
56- BoolValue : true ,
57- StringValue : "str" ,
58- RepeatedValue : []string {"a" , "b" , "c" },
59- EnumValue : EnumValue_Y ,
60- RepeatedEnum : []EnumValue {EnumValue_Y , EnumValue_Z , EnumValue_X },
61- TimestampValue : timePb ,
59+ FloatValue : 1.5 ,
60+ DoubleValue : 2.5 ,
61+ Int64Value : - 1 ,
62+ Int32Value : - 2 ,
63+ Uint64Value : 3 ,
64+ Uint32Value : 4 ,
65+ BoolValue : true ,
66+ StringValue : "str" ,
67+ RepeatedValue : []string {"a" , "b" , "c" },
68+ EnumValue : EnumValue_Y ,
69+ RepeatedEnum : []EnumValue {EnumValue_Y , EnumValue_Z , EnumValue_X },
70+ TimestampValue : timePb ,
71+ WrapperFloatValue : & wrappers.FloatValue {1.5 },
72+ WrapperDoubleValue : & wrappers.DoubleValue {2.5 },
73+ WrapperInt64Value : & wrappers.Int64Value {- 1 },
74+ WrapperInt32Value : & wrappers.Int32Value {- 2 },
75+ WrapperUInt64Value : & wrappers.UInt64Value {3 },
76+ WrapperUInt32Value : & wrappers.UInt32Value {4 },
77+ WrapperBoolValue : & wrappers.BoolValue {true },
78+ WrapperStringValue : & wrappers.StringValue {"str" },
6279 },
6380 },
6481 {
6582 values : url.Values {
66- "floatValue" : {"1.5" },
67- "doubleValue" : {"2.5" },
68- "int64Value" : {"-1" },
69- "int32Value" : {"-2" },
70- "uint64Value" : {"3" },
71- "uint32Value" : {"4" },
72- "boolValue" : {"true" },
73- "stringValue" : {"str" },
74- "repeatedValue" : {"a" , "b" , "c" },
75- "enumValue" : {"1" },
76- "repeatedEnum" : {"1" , "2" , "0" },
77- "timestampValue" : {timeStr },
83+ "floatValue" : {"1.5" },
84+ "doubleValue" : {"2.5" },
85+ "int64Value" : {"-1" },
86+ "int32Value" : {"-2" },
87+ "uint64Value" : {"3" },
88+ "uint32Value" : {"4" },
89+ "boolValue" : {"true" },
90+ "stringValue" : {"str" },
91+ "repeatedValue" : {"a" , "b" , "c" },
92+ "enumValue" : {"1" },
93+ "repeatedEnum" : {"1" , "2" , "0" },
94+ "timestampValue" : {timeStr },
95+ "wrapperFloatValue" : {"1.5" },
96+ "wrapperDoubleValue" : {"2.5" },
97+ "wrapperInt64Value" : {"-1" },
98+ "wrapperInt32Value" : {"-2" },
99+ "wrapperUInt64Value" : {"3" },
100+ "wrapperUInt32Value" : {"4" },
101+ "wrapperBoolValue" : {"true" },
102+ "wrapperStringValue" : {"str" },
78103 },
79104 filter : utilities .NewDoubleArray (nil ),
80105 want : & proto3Message {
81- FloatValue : 1.5 ,
82- DoubleValue : 2.5 ,
83- Int64Value : - 1 ,
84- Int32Value : - 2 ,
85- Uint64Value : 3 ,
86- Uint32Value : 4 ,
87- BoolValue : true ,
88- StringValue : "str" ,
89- RepeatedValue : []string {"a" , "b" , "c" },
90- EnumValue : EnumValue_Y ,
91- RepeatedEnum : []EnumValue {EnumValue_Y , EnumValue_Z , EnumValue_X },
92- TimestampValue : timePb ,
106+ FloatValue : 1.5 ,
107+ DoubleValue : 2.5 ,
108+ Int64Value : - 1 ,
109+ Int32Value : - 2 ,
110+ Uint64Value : 3 ,
111+ Uint32Value : 4 ,
112+ BoolValue : true ,
113+ StringValue : "str" ,
114+ RepeatedValue : []string {"a" , "b" , "c" },
115+ EnumValue : EnumValue_Y ,
116+ RepeatedEnum : []EnumValue {EnumValue_Y , EnumValue_Z , EnumValue_X },
117+ TimestampValue : timePb ,
118+ WrapperFloatValue : & wrappers.FloatValue {1.5 },
119+ WrapperDoubleValue : & wrappers.DoubleValue {2.5 },
120+ WrapperInt64Value : & wrappers.Int64Value {- 1 },
121+ WrapperInt32Value : & wrappers.Int32Value {- 2 },
122+ WrapperUInt64Value : & wrappers.UInt64Value {3 },
123+ WrapperUInt32Value : & wrappers.UInt32Value {4 },
124+ WrapperBoolValue : & wrappers.BoolValue {true },
125+ WrapperStringValue : & wrappers.StringValue {"str" },
93126 },
94127 },
95128 {
@@ -428,21 +461,29 @@ func TestPopulateQueryParametersWithInvalidNestedParameters(t *testing.T) {
428461}
429462
430463type proto3Message struct {
431- Nested * proto2Message `protobuf:"bytes,1,opt,name=nested,json=nested" json:"nested,omitempty"`
432- NestedNonNull proto2Message `protobuf:"bytes,15,opt,name=nested_non_null,json=nestedNonNull" json:"nested_non_null,omitempty"`
433- FloatValue float32 `protobuf:"fixed32,2,opt,name=float_value,json=floatValue" json:"float_value,omitempty"`
434- DoubleValue float64 `protobuf:"fixed64,3,opt,name=double_value,json=doubleValue" json:"double_value,omitempty"`
435- Int64Value int64 `protobuf:"varint,4,opt,name=int64_value,json=int64Value" json:"int64_value,omitempty"`
436- Int32Value int32 `protobuf:"varint,5,opt,name=int32_value,json=int32Value" json:"int32_value,omitempty"`
437- Uint64Value uint64 `protobuf:"varint,6,opt,name=uint64_value,json=uint64Value" json:"uint64_value,omitempty"`
438- Uint32Value uint32 `protobuf:"varint,7,opt,name=uint32_value,json=uint32Value" json:"uint32_value,omitempty"`
439- BoolValue bool `protobuf:"varint,8,opt,name=bool_value,json=boolValue" json:"bool_value,omitempty"`
440- StringValue string `protobuf:"bytes,9,opt,name=string_value,json=stringValue" json:"string_value,omitempty"`
441- RepeatedValue []string `protobuf:"bytes,10,rep,name=repeated_value,json=repeatedValue" json:"repeated_value,omitempty"`
442- EnumValue EnumValue `protobuf:"varint,11,opt,name=enum_value,json=enumValue,enum=runtime_test_api.EnumValue" json:"enum_value,omitempty"`
443- RepeatedEnum []EnumValue `protobuf:"varint,12,rep,packed,name=repeated_enum,json=repeatedEnum,enum=runtime_test_api.EnumValue" json:"repeated_enum,omitempty"`
444- TimestampValue * timestamp.Timestamp `protobuf:"bytes,16,opt,name=timestamp_value,json=timestampValue" json:"timestamp_value,omitempty"`
445- OneofValue proto3Message_OneofValue `protobuf_oneof:"oneof_value"`
464+ Nested * proto2Message `protobuf:"bytes,1,opt,name=nested,json=nested" json:"nested,omitempty"`
465+ NestedNonNull proto2Message `protobuf:"bytes,15,opt,name=nested_non_null,json=nestedNonNull" json:"nested_non_null,omitempty"`
466+ FloatValue float32 `protobuf:"fixed32,2,opt,name=float_value,json=floatValue" json:"float_value,omitempty"`
467+ DoubleValue float64 `protobuf:"fixed64,3,opt,name=double_value,json=doubleValue" json:"double_value,omitempty"`
468+ Int64Value int64 `protobuf:"varint,4,opt,name=int64_value,json=int64Value" json:"int64_value,omitempty"`
469+ Int32Value int32 `protobuf:"varint,5,opt,name=int32_value,json=int32Value" json:"int32_value,omitempty"`
470+ Uint64Value uint64 `protobuf:"varint,6,opt,name=uint64_value,json=uint64Value" json:"uint64_value,omitempty"`
471+ Uint32Value uint32 `protobuf:"varint,7,opt,name=uint32_value,json=uint32Value" json:"uint32_value,omitempty"`
472+ BoolValue bool `protobuf:"varint,8,opt,name=bool_value,json=boolValue" json:"bool_value,omitempty"`
473+ StringValue string `protobuf:"bytes,9,opt,name=string_value,json=stringValue" json:"string_value,omitempty"`
474+ RepeatedValue []string `protobuf:"bytes,10,rep,name=repeated_value,json=repeatedValue" json:"repeated_value,omitempty"`
475+ EnumValue EnumValue `protobuf:"varint,11,opt,name=enum_value,json=enumValue,enum=runtime_test_api.EnumValue" json:"enum_value,omitempty"`
476+ RepeatedEnum []EnumValue `protobuf:"varint,12,rep,packed,name=repeated_enum,json=repeatedEnum,enum=runtime_test_api.EnumValue" json:"repeated_enum,omitempty"`
477+ TimestampValue * timestamp.Timestamp `protobuf:"bytes,16,opt,name=timestamp_value,json=timestampValue" json:"timestamp_value,omitempty"`
478+ OneofValue proto3Message_OneofValue `protobuf_oneof:"oneof_value"`
479+ WrapperDoubleValue * wrappers.DoubleValue `protobuf:"bytes,17,opt,name=wrapper_double_value,json=wrapperDoubleValue" json:"wrapper_double_value,omitempty"`
480+ WrapperFloatValue * wrappers.FloatValue `protobuf:"bytes,18,opt,name=wrapper_float_value,json=wrapperFloatValue" json:"wrapper_float_value,omitempty"`
481+ WrapperInt64Value * wrappers.Int64Value `protobuf:"bytes,19,opt,name=wrapper_int64_value,json=wrapperInt64Value" json:"wrapper_int64_value,omitempty"`
482+ WrapperInt32Value * wrappers.Int32Value `protobuf:"bytes,20,opt,name=wrapper_int32_value,json=wrapperInt32Value" json:"wrapper_int32_value,omitempty"`
483+ WrapperUInt64Value * wrappers.UInt64Value `protobuf:"bytes,21,opt,name=wrapper_u_int64_value,json=wrapperUInt64Value" json:"wrapper_u_int64_value,omitempty"`
484+ WrapperUInt32Value * wrappers.UInt32Value `protobuf:"bytes,22,opt,name=wrapper_u_int32_value,json=wrapperUInt32Value" json:"wrapper_u_int32_value,omitempty"`
485+ WrapperBoolValue * wrappers.BoolValue `protobuf:"bytes,23,opt,name=wrapper_bool_value,json=wrapperBoolValue" json:"wrapper_bool_value,omitempty"`
486+ WrapperStringValue * wrappers.StringValue `protobuf:"bytes,24,opt,name=wrapper_string_value,json=wrapperStringValue" json:"wrapper_string_value,omitempty"`
446487}
447488
448489func (m * proto3Message ) Reset () { * m = proto3Message {} }
0 commit comments