5050 PtrS * string
5151 cantSet string
5252 DoesntExist string
53+ GoT time.Time
54+ GoTptr * time.Time
5355 T Timestamp
5456 Tptr * Timestamp
5557 SA StringArray
@@ -116,6 +118,8 @@ var values = map[string][]string{
116118 "cantSet" : {"test" },
117119 "T" : {"2016-12-06T19:09:05+01:00" },
118120 "Tptr" : {"2016-12-06T19:09:05+01:00" },
121+ "GoT" : {"2016-12-06T19:09:05+01:00" },
122+ "GoTptr" : {"2016-12-06T19:09:05+01:00" },
119123 "ST" : {"bar" },
120124}
121125
@@ -216,6 +220,28 @@ func TestBindUnmarshalParam(t *testing.T) {
216220 }
217221}
218222
223+ func TestBindUnmarshalText (t * testing.T ) {
224+ e := New ()
225+ req := httptest .NewRequest (GET , "/?ts=2016-12-06T19:09:05Z&sa=one,two,three&ta=2016-12-06T19:09:05Z&ta=2016-12-06T19:09:05Z&ST=baz" , nil )
226+ rec := httptest .NewRecorder ()
227+ c := e .NewContext (req , rec )
228+ result := struct {
229+ T time.Time `query:"ts"`
230+ TA []time.Time `query:"ta"`
231+ SA StringArray `query:"sa"`
232+ ST Struct
233+ }{}
234+ err := c .Bind (& result )
235+ ts := time .Date (2016 , 12 , 6 , 19 , 9 , 5 , 0 , time .UTC )
236+ if assert .NoError (t , err ) {
237+ // assert.Equal(t, Timestamp(reflect.TypeOf(&Timestamp{}), time.Date(2016, 12, 6, 19, 9, 5, 0, time.UTC)), result.T)
238+ assert .Equal (t , ts , result .T )
239+ assert .Equal (t , StringArray ([]string {"one" , "two" , "three" }), result .SA )
240+ assert .Equal (t , []time.Time {ts , ts }, result .TA )
241+ assert .Equal (t , Struct {"baz" }, result .ST )
242+ }
243+ }
244+
219245func TestBindUnmarshalParamPtr (t * testing.T ) {
220246 e := New ()
221247 req := httptest .NewRequest (http .MethodGet , "/?ts=2016-12-06T19:09:05Z" , nil )
@@ -230,6 +256,20 @@ func TestBindUnmarshalParamPtr(t *testing.T) {
230256 }
231257}
232258
259+ func TestBindUnmarshalTextPtr (t * testing.T ) {
260+ e := New ()
261+ req := httptest .NewRequest (GET , "/?ts=2016-12-06T19:09:05Z" , nil )
262+ rec := httptest .NewRecorder ()
263+ c := e .NewContext (req , rec )
264+ result := struct {
265+ Tptr * time.Time `query:"ts"`
266+ }{}
267+ err := c .Bind (& result )
268+ if assert .NoError (t , err ) {
269+ assert .Equal (t , time .Date (2016 , 12 , 6 , 19 , 9 , 5 , 0 , time .UTC ), * result .Tptr )
270+ }
271+ }
272+
233273func TestBindMultipartForm (t * testing.T ) {
234274 body := new (bytes.Buffer )
235275 mw := multipart .NewWriter (body )
0 commit comments