github.com/zhongdalu/gf@v1.0.0/g/util/gconv/gconv_z_unit_time_test.go (about)

     1  // Copyright 2018 gf Author(https://github.com/zhongdalu/gf). All Rights Reserved.
     2  //
     3  // This Source Code Form is subject to the terms of the MIT License.
     4  // If a copy of the MIT was not distributed with this file,
     5  // You can obtain one at https://github.com/zhongdalu/gf.
     6  
     7  package gconv_test
     8  
     9  import (
    10  	"github.com/zhongdalu/gf/g/os/gtime"
    11  	"github.com/zhongdalu/gf/g/test/gtest"
    12  	"github.com/zhongdalu/gf/g/util/gconv"
    13  	"testing"
    14  	"time"
    15  )
    16  
    17  func Test_Time(t *testing.T) {
    18  	gtest.Case(t, func() {
    19  		t1 := "2011-10-10 01:02:03.456"
    20  		gtest.AssertEQ(gconv.GTime(t1), gtime.NewFromStr(t1))
    21  		gtest.AssertEQ(gconv.Time(t1), gtime.NewFromStr(t1).Time)
    22  		gtest.AssertEQ(gconv.Duration(100), 100*time.Nanosecond)
    23  	})
    24  }