From e90f72b538ebf3ce7e1553b72d71bf5e67e9f25e Mon Sep 17 00:00:00 2001 From: John Guo Date: Wed, 19 Jan 2022 18:23:04 +0800 Subject: [PATCH] improve UT cases for package gtime --- os/gtime/gtime_z_unit_feature_json_test.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/os/gtime/gtime_z_unit_feature_json_test.go b/os/gtime/gtime_z_unit_feature_json_test.go index 05af8bc9a..ccdf85a78 100644 --- a/os/gtime/gtime_z_unit_feature_json_test.go +++ b/os/gtime/gtime_z_unit_feature_json_test.go @@ -27,6 +27,13 @@ func Test_Json_Pointer(t *testing.T) { t.AssertNil(err) t.Assert(b, `{"MyTime":"2006-01-02 15:04:05"}`) }) + gtest.C(t, func(t *gtest.T) { + b, err := json.Marshal(g.Map{ + "MyTime": gtime.NewFromStr("2006-01-02 15:04:05"), + }) + t.AssertNil(err) + t.Assert(b, `{"MyTime":"2006-01-02 15:04:05"}`) + }) gtest.C(t, func(t *gtest.T) { b, err := json.Marshal(g.Map{ "MyTime": *gtime.NewFromStr("2006-01-02 15:04:05"), @@ -64,7 +71,7 @@ func Test_Json_Pointer(t *testing.T) { } func Test_Json_Struct(t *testing.T) { - // Marshal + // Marshal struct. gtest.C(t, func(t *gtest.T) { type MyTime struct { MyTime gtime.Time @@ -75,7 +82,7 @@ func Test_Json_Struct(t *testing.T) { t.AssertNil(err) t.Assert(b, `{"MyTime":"2006-01-02 15:04:05"}`) }) - // Marshal + // Marshal pointer. gtest.C(t, func(t *gtest.T) { type MyTime struct { MyTime gtime.Time