mirror of
https://gitee.com/johng/gf.git
synced 2024-11-30 11:18:02 +08:00
improve UT cases for package gtime
This commit is contained in:
parent
07c5ce0bbc
commit
9efc2894d4
@ -21,14 +21,12 @@ func Test_Json_Pointer(t *testing.T) {
|
||||
type MyTime struct {
|
||||
MyTime *gtime.Time
|
||||
}
|
||||
myTime := MyTime{
|
||||
b, err := json.Marshal(MyTime{
|
||||
MyTime: gtime.NewFromStr("2006-01-02 15:04:05"),
|
||||
}
|
||||
b, err := json.Marshal(myTime)
|
||||
})
|
||||
t.AssertNil(err)
|
||||
t.Assert(b, `{"MyTime":"2006-01-02 15:04:05"}`)
|
||||
})
|
||||
// Marshal with interface{} type.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
b, err := json.Marshal(g.Map{
|
||||
"MyTime": *gtime.NewFromStr("2006-01-02 15:04:05"),
|
||||
@ -77,6 +75,17 @@ func Test_Json_Struct(t *testing.T) {
|
||||
t.AssertNil(err)
|
||||
t.Assert(b, `{"MyTime":"2006-01-02 15:04:05"}`)
|
||||
})
|
||||
// Marshal
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
type MyTime struct {
|
||||
MyTime gtime.Time
|
||||
}
|
||||
b, err := json.Marshal(&MyTime{
|
||||
MyTime: *gtime.NewFromStr("2006-01-02 15:04:05"),
|
||||
})
|
||||
t.AssertNil(err)
|
||||
t.Assert(b, `{"MyTime":"2006-01-02 15:04:05"}`)
|
||||
})
|
||||
// Marshal nil
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
type MyTime struct {
|
||||
|
Loading…
Reference in New Issue
Block a user