Files
gf/util/gconv/gconv_z_unit_time_test.go

26 lines
678 B
Go
Raw Normal View History

// Copyright 2018 gf Author(https://github.com/gogf/gf). All Rights Reserved.
2019-01-15 21:54:34 +08:00
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
2019-01-15 21:54:34 +08:00
package gconv_test
import (
2019-06-19 09:06:52 +08:00
"testing"
"time"
2019-07-29 21:01:19 +08:00
"github.com/gogf/gf/os/gtime"
"github.com/gogf/gf/test/gtest"
"github.com/gogf/gf/util/gconv"
2019-01-15 21:54:34 +08:00
)
func Test_Time(t *testing.T) {
2020-03-19 22:56:12 +08:00
gtest.C(t, func(t *gtest.T) {
t1 := "2011-10-10 01:02:03.456"
2020-03-19 22:56:12 +08:00
t.AssertEQ(gconv.GTime(t1), gtime.NewFromStr(t1))
t.AssertEQ(gconv.Time(t1), gtime.NewFromStr(t1).Time)
t.AssertEQ(gconv.Duration(100), 100*time.Nanosecond)
})
2019-01-15 21:54:34 +08:00
}