From eba97277b2feb771d72114f509acdf275788f264 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 1 Oct 2019 09:33:26 +0800 Subject: [PATCH] add more unit test cases for ghttp --- net/ghttp/ghttp_unit_param_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/ghttp/ghttp_unit_param_test.go b/net/ghttp/ghttp_unit_param_test.go index 66063bb0d..523663d5a 100644 --- a/net/ghttp/ghttp_unit_param_test.go +++ b/net/ghttp/ghttp_unit_param_test.go @@ -188,6 +188,11 @@ func Test_Params_Basic(t *testing.T) { r.Response.Write(user.Id, user.Name, user.Pass1, user.Pass2) } }) + s.BindHandler("/struct-with-nil", func(r *ghttp.Request) { + user := (*User)(nil) + err := r.GetPostToStruct(&user) + r.Response.Write(err) + }) s.BindHandler("/struct-with-base", func(r *ghttp.Request) { type Base struct { Pass1 string `params:"password1"` @@ -295,6 +300,7 @@ func Test_Params_Basic(t *testing.T) { // Struct gtest.Assert(client.GetContent("/struct", `id=1&name=john&password1=123&password2=456`), `1john123456`) gtest.Assert(client.PostContent("/struct", `id=1&name=john&password1=123&password2=456`), `1john123456`) + gtest.Assert(client.PostContent("/struct-with-nil", ``), ``) gtest.Assert(client.PostContent("/struct-with-base", `id=1&name=john&password1=123&password2=456`), "1john1234561john123456") }) }